固定Kivy程序的窗口大小 [英] Fixed window size for Kivy programs

查看:290
本文介绍了固定Kivy程序的窗口大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么方法可以保持Kivy程序的窗口大小固定吗?在固定的意义上,不能增加或减小其窗口大小.例如,我想要一个窗口大小为500x500的Kivy程序,而最终用户不能更改窗口大小或将其变成全屏显示.我尝试将高度,宽度,minimum_height和minimum_width设置为相同的值,但仍然可以更改窗口大小并全屏显示.

Is there any way to keep the window size for Kivy programs fixed? Fixed in the sense its window size cannot be increased or decreased. For example, I want a Kivy program whose window size is 500x500 and the end user cannot either change the window size or turn it into fullscreen. I tried setting the height, width, minimum_height and minimum_width all with same values and still I can change window size and fullscreen it.

推荐答案

有一种方法可以将应用配置为禁用调整大小

There is a way to configure the app to disable resizing

from kivy.config import Config
Config.set('graphics', 'resizable', False)

此外,可以使用相同的方法来设置窗口的默认宽度-高度.
记住一点.在您的应用程序开始时像这样进行操作,它将仅保留该应用程序的设置.但是,如果随后运行Config.write(),则会将设置保存在配置文件中.

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.

导入任何其他Kivy模块之前,应使用

Config.set.理想情况下,这意味着将它们设置在main.py脚本的开头. 或者,您可以使用以下方式永久保存这些设置: Config.set然后Config.write.在这种情况下,您将需要重新启动 该应用程序才能使更改生效.请注意,此方法将 在系统范围内影响所有Kivy应用.

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 using Config.set then Config.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.

请阅读这篇 Wiki文章以了解更多信息.

Read this wiki article for more info.

这篇关于固定Kivy程序的窗口大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆