Event loop management¶
- kivy.base.EventLoop = <kivy.base.EventLoopBase object at 0x2772a10>¶
EventLoop instance
- class kivy.base.EventLoopBase¶
Bases: kivy.event.EventDispatcher
Main event loop. This loop handle update of input + dispatch event
- add_event_listener(listener)¶
Add a new event listener for getting touch event
- add_input_provider(provider, auto_remove=False)¶
Add a new input provider to listen for touch event
- add_postproc_module(mod)¶
Add a postproc input module (DoubleTap, RetainTouch are default)
- close()¶
Exit from the main loop, and stop all configured input providers.
- dispatch_input()¶
Called by idle() to read events from input providers, pass event to postproc, and dispatch final events.
- ensure_window()¶
Ensure that we have an window
- exit()¶
Close the main loop, and close the window
- idle()¶
This function is called every frames. By default : * it “tick” the clock to the next frame * read all input and dispatch event * dispatch on_update + on_draw + on_flip on window
- on_pause()¶
Event handler for on_pause, will be fired when the event loop is paused.
- on_start()¶
Event handler for on_start, will be fired right after all input providers have been started.
- on_stop()¶
Event handler for on_stop, will be fired right after all input providers have been stopped.
- post_dispatch_input(etype, me)¶
This function is called by dispatch_input() when we want to dispatch a input event. The event is dispatched into all listeners, and if grabbed, it’s dispatched through grabbed widgets
- remove_event_listener(listener)¶
Remove a event listener from the list
- remove_input_provider(provider)¶
Remove an input provider
- remove_postproc_module(mod)¶
Remove a postproc module
- run()¶
Main loop
- set_window(window)¶
Set the window used for event loop
- start()¶
Must be call only one time before run(). This start all configured input providers.
- stop()¶
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 state
- class kivy.base.ExceptionHandler¶
Base handler that catch exception in runTouchApp(). You can derivate and use it like this:
class E(ExceptionHandler): def handle_exception(self, inst): Logger.exception(inst) return ExceptionManager.PASS ExceptionManager.add_handler(E())
All exceptions will be set to PASS, and logged to console !
- handle_exception(exception)¶
Handle one exception, default return ExceptionManager.STOP
- class kivy.base.ExceptionManagerBase¶
ExceptionManager manage exceptions handlers.
- add_handler(cls)¶
Add a new exception handler in the stack
- handle_exception(inst)¶
Called when an exception happend in runTouchApp() main loop
- remove_handler(cls)¶
Remove a exception handler from the stack
- kivy.base.ExceptionManager = <kivy.base.ExceptionManagerBase instance at 0x2a74950>¶
Kivy Exception Manager instance
- kivy.base.runTouchApp(widget=None, slave=False)¶
Static main function that starts the application loop. You got some magic things, if you are using argument like this :
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 on the window as the root widget.
- slave
No event dispatching are done. This will be your job.
- widget + slave
No event dispatching are done. This will be your job, but we are trying to get the window (must be created by you before), and add the widget on it. Very usefull for embedding Kivy in another toolkit. (like Qt, check kivy-designed)
- kivy.base.stopTouchApp()¶
Stop the current application by leaving the main loop