Table Of Contents

Related Topics

Window

Core class for create the default Kivy window. Kivy support only one window creation. Don’t try to create more than one.

class kivy.core.window.WindowBase(**kwargs)

Bases: kivy.event.EventDispatcher

WindowBase is a abstract window widget, for any window implementation.

Warning

The parameters are not working in normal case. Because at import, Kivy create a default OpenGL window, to add the ability to use OpenGL directives, texture creation.. before creating Window. If you don’t like this behavior, you can include before the very first import of Kivy

import os
os.environ['KIVY_SHADOW'] = '0'

This will forbid Kivy to create the default window !

Parameters :
fullscreen: bool

Make window as fullscreen

width: int

Width of window

height: int

Height of window

Events :
on_motion: etype, motionevent

Fired when a new MotionEvent is dispatched

on_touch_down:

Fired when a new touch appear

on_touch_move:

Fired when an existing touch is moved

on_touch_down:

Fired when an existing touch disapear

on_draw:

Fired when the Window is beeing drawed

on_flip:

Fired when the Window GL surface is beeing flipped

on_rotate: rotation

Fired when the Window is beeing rotated

on_close:

Fired when the Window is closed

on_keyboard: key, scancode, unicode

Fired when the keyboard is in action

on_key_down: key, scancode, unicode

Fired when a key is down

on_key_up: key, scancode, unicode

Fired when a key is up

add_widget(widget)

Add a widget on window

center

Rotated window center

clear()

Clear the window with background color

close()

Close the window

create_window()

Will create the main window and configure it.

Warning

This method is called automatically at runtime. If you call it, it will recreate a RenderContext and Canvas. This mean you’ll have a new graphics tree, and the old one will be unusable.

This method exist to permit the creation of a new OpenGL context AFTER closing the first one. (Like using runTouchApp() and stopTouchApp()).

This method have been only tested in unittest environment, and will be not suitable for Applications.

Again, don’t use this method unless you know exactly what you are doing !

flip()

Flip between buffers

height

Rotated window height

on_close(*largs)

Event called when the window is closed

on_flip()

Flip between buffers (event)

on_key_down(key, scancode=None, unicode=None)

Event called when a key is down (same arguments as on_keyboard)

on_key_up(key, scancode=None, unicode=None)

Event called when a key is up (same arguments as on_keyboard)

on_keyboard(key, scancode=None, unicode=None)

Event called when keyboard is in action

Warning

Some providers can skip scancode or unicode !!

on_motion(etype, me)

Event called when a Motion Event is received.

Parameters :
etype: str

One of ‘begin’, ‘update’, ‘end’

me: MotionEvent

Motion Event currently dispatched

on_mouse_down(x, y, button, modifiers)

Event called when mouse is in action (press/release)

on_mouse_move(x, y, modifiers)

Event called when mouse is moving, with buttons pressed

on_mouse_up(x, y, button, modifiers)

Event called when mouse is moving, with buttons pressed

on_resize(width, height)

Event called when the window is resized

on_rotate(rotation)

Event called when the screen have been rotated

on_touch_down(touch)

Event called when a touch is down

on_touch_move(touch)

Event called when a touch move

on_touch_up(touch)

Event called when a touch up

remove_widget(widget)

Remove a widget from window

screenshot(name='screenshot%(counter)04d.jpg')

Save the actual displayed image in a file

size

Rotated size of the window

system_size

Real size of the window, without taking care of the rotation

toggle_fullscreen()

Toggle fullscreen on window

width

Rotated window width

kivy.core.window.Window

Instance of a WindowBase implementation