Table Of Contents
Kivy Base¶
This module contains the Kivy core functionality and is not intended for end users. Feel free to look through it, but bare in mind that calling any of these methods directly may result in an unpredictable behavior as the calls access directly the event loop of an application.
-
kivy.base.
EventLoop
= <kivy.base.EventLoopBase object>¶ EventLoop instance
-
class
kivy.base.
EventLoopBase
[source]¶ Bases:
kivy.event.EventDispatcher
Main event loop. This loop handles the updating of input and dispatching events.
-
add_input_provider
(provider, auto_remove=False)[source]¶ Add a new input provider to listen for touch events.
-
add_postproc_module
(mod)[source]¶ Add a postproc input module (DoubleTap, TripleTap, DeJitter RetainTouch are defaults).
-
dispatch_input
()[source]¶ Called by
EventLoopBase.idle()
to read events from input providers, pass events to postproc, and dispatch final events.
-
idle
()[source]¶ This function is called after every frame. By default:
it “ticks” the clock to the next frame.
it reads all input and dispatches events.
it dispatches on_update, on_draw and on_flip events to the window.
-
on_start
()[source]¶ Event handler for on_start which will be fired right after all input providers have been started.
-
on_stop
()[source]¶ Event handler for on_stop events which will be fired right after all input providers have been stopped.
-
post_dispatch_input
(etype, me)[source]¶ This function is called by
EventLoopBase.dispatch_input()
when we want to dispatch an input event. The event is dispatched to all listeners and if grabbed, it’s dispatched to grabbed widgets.
-
start
()[source]¶ Must be called only once before
EventLoopBase.run()
. This starts all configured input providers.
-
stop
()[source]¶ Stop all input providers and call callbacks registered using EventLoop.add_stop_callback().
-
touches
¶ Return the list of all touches currently in down or move states.
-
-
class
kivy.base.
ExceptionHandler
[source]¶ Bases:
builtins.object
Base handler that catches exceptions in
runTouchApp()
. You can subclass and extend it as follows:class E(ExceptionHandler): def handle_exception(self, inst): Logger.exception('Exception catched by ExceptionHandler') return ExceptionManager.PASS ExceptionManager.add_handler(E())
All exceptions will be set to PASS, and logged to the console!
-
class
kivy.base.
ExceptionManagerBase
[source]¶ Bases:
builtins.object
ExceptionManager manages exceptions handlers.
-
handle_exception
(inst)[source]¶ Called when an exception occurred in the
runTouchApp()
main loop.
-
-
kivy.base.
ExceptionManager
= <kivy.base.ExceptionManagerBase object>¶ Instance of a
ExceptionManagerBase
implementation.
-
kivy.base.
runTouchApp
(widget=None, slave=False)[source]¶ Static main function that starts the application loop. You can access some magic via the following arguments:
- Parameters
- <empty>
To make dispatching work, you need at least one input listener. If not, application will leave. (MTWindow act as an input listener)
- widget
If you pass only a widget, a MTWindow will be created and your widget will be added to the window as the root widget.
- slave
No event dispatching is done. This will be your job.
- widget + slave
No event dispatching is done. This will be your job but we try to get the window (must be created by you beforehand) and add the widget to it. Very useful for embedding Kivy in another toolkit. (like Qt, check kivy-designed)