Fixed window size for Kivy programs
There is a way to configure the app to disable resizing
from kivy.config import Config
Config.set('graphics', 'resizable', False)
Also, the same way you can set the default width-height of the window.
Keep something in mind. Doing it like that in the beginning of your app, it will keep the settings only for that app. However, if you then run a Config.write()
, you'll save the settings in a configuration file.
Config.set
should be used before importing any other Kivy modules. Ideally, this means setting them right at the start of your main.py script. Alternatively, you can save these settings permanently usingConfig.set
thenConfig.write
. In this case, you will need to restart the app for the changes to take effect. Note that this approach will effect all Kivy apps system wide.
Read this wiki article for more info.
There are actually a bunch of ways you can do this, that said many of them are dependent on how you're writing your code and since you've not given us an example I can only show you basic examples...
Say for instance your'e not using the kivy deign language and you're doing your project in straight python you could for instance setup a Root widget in the following way
Root = Widget(size = (500,500))
You could also avoid that and simply do for instance
Window.size = (500, 500)
Now if you're using the kv design language it's just eas easy except you'd be setting the size of your canvas, Rectangles etc.. inside the .kv file.
And as mentioned by @Leva7 you could also use for instance
from kivy.config import Config
Config.set('graphics', 'resizable', '0') #0 being off 1 being on as in true/false
Config.set('graphics', 'width', '500')
Config.set('graphics', 'height', '500')
Note that the above (Ie, Config.set()) should be placed at the top of the source code near the import section!
You can give like this on kivy-1.10.0+
import kivy
from kivy.app import App
from kivy.core.window import Window
from kivy.config import Config
kivy.config.Config.set('graphics','resizable', False)
class MyApp(App):
def build(self):
Window.size = (1280,720)
MyApp().run()