Quick search

Table Of Contents

Kivy Base

This module contains core Kivy functionality and is not intended for end users. Feel free to look though it, but calling any of these methods directly may well result in unpredictable behavior.

Event loop management

kivy.base.EventLoop = <kivy.base.EventLoopBase object at 0x061E1D88>

EventLoop instance

class kivy.base.EventLoopBase[ソース]

ベースクラス: kivy.event.EventDispatcher

Main event loop. This loop handles the updating of input and dispatching events.

add_event_listener(listener)[ソース]

Add a new event listener for getting touch events.

add_input_provider(provider, auto_remove=False)[ソース]

Add a new input provider to listen for touch events.

add_postproc_module(mod)[ソース]

Add a postproc input module (DoubleTap, TripleTap, DeJitter RetainTouch are defaults).

close()[ソース]

Exit from the main loop and stop all configured input providers.

dispatch_input()[ソース]

Called by idle() to read events from input providers, pass events to postproc, and dispatch final events.

ensure_window()[ソース]

Ensure that we have a window.

exit()[ソース]

Close the main loop and close the window.

idle()[ソース]

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_pause()[ソース]

Event handler for on_pause which will be fired when the event loop is paused.

on_start()[ソース]

Event handler for on_start which will be fired right after all input providers have been started.

on_stop()[ソース]

Event handler for on_stop events which 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 an input event. The event is dispatched to all listeners and if grabbed, it’s dispatched to grabbed widgets.

remove_android_splash(*args)[ソース]

Remove android presplash in SDL2 bootstrap.

remove_event_listener(listener)[ソース]

Remove an 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 the event loop.

start()[ソース]

Must be called only once before run(). This starts 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 states.

class kivy.base.ExceptionHandler[ソース]

ベースクラス: 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!

handle_exception(exception)[ソース]

Handle one exception, defaults to returning ExceptionManager.STOP.

class kivy.base.ExceptionManagerBase[ソース]

ベースクラス: builtins.object

ExceptionManager manages exceptions handlers.

add_handler(cls)[ソース]

Add a new exception handler to the stack.

handle_exception(inst)[ソース]

Called when an exception occurred in the runTouchApp() main loop.

remove_handler(cls)[ソース]

Remove a exception handler from the stack.

kivy.base.ExceptionManager = <kivy.base.ExceptionManagerBase object at 0x06157FB0>

Instance of a ExceptionManagerBase implementation.

kivy.base.runTouchApp(widget=None, slave=False)[ソース]

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)

kivy.base.stopTouchApp()[ソース]

Stop the current application by leaving the main loop