Kivy: How to change window size?
There're currently two ways:
-
Before the window is created:
import kivy kivy.require('1.9.0') from kivy.config import Config Config.set('graphics', 'width', '200') Config.set('graphics', 'height', '200')
-
Dynamically after the Window was created:
from kivy.core.window import Window Window.size = (300, 100)
Use this:
from kivy.core.window import Window
Window.size = (300, 100)
If you use
from kivy.config import Config
Config.set('graphics', 'width', '200')
Config.set('graphics', 'height', '200')
Config.write()
this will lead to loss of default screen size! Default screen size is really useful.
I would comment on martin's answer, but I don't have the reputation. When setting the config file, be sure to "write" your changes:
from kivy.config import Config
Config.set('graphics', 'width', '200')
Config.set('graphics', 'height', '200')
Config.write()
It's exactly like committing info to a database, if you know anything about that.
Using Config.write()
will set your changes to the default settings. If you accidentally run this and want to revert the changes, you can either run Config.write()
again with the default values (therefore reverting your changes) or you can open up $HOME/.kivy/config.ini
with a text editor and edit it.