问题将 Kivy 设置为全屏

2022-01-15 00:00:00 python kivy fullscreen resolution

问题描述

我正在尝试编写一个全屏运行 kivy 的应用程序.但这些是我的问题:

I'm trying to write an application that runs kivy at full screen. But these are my issues:

1) 当我运行命令时:

1) When I run the command:

#Config.set('graphics', 'fullscreen', 1)

然后 kivy 似乎全时运行,但窗口的背景图像周围有很多黑色空间.即使我拉长了图像,kivy 也只是在显示时剪切了图像.

Then kivy appears to go full time, but the window has a lot of black spaces around the background image. Even if I elongate the image, kivy just cuts the image when showing it.

2) 当我运行此命令将窗口大小设置为我的屏幕大小时:

2) When I run this command to set the window size to the size of my screen:

Config.set('graphics', 'width', '1366')
Config.set('graphics', 'height', '768')

这种方式实际上给了我比全屏更好的结果,但是 kivy 返回的高度参数仅为 715 而不是 768,这是我告诉 kivy 使用的值(如您所见在上面的 Config.set() 函数中).

This way actually gives me a better result than full screen, but kivy returns a height parameter of only 715 instead of the 768, which is the value I told kivy to use (as you can see in the Config.set() function above).

我的屏幕分辨率是 1366x768

My screen resolution is 1366x768

如何解决这个问题并让我的 kivy 应用真正全屏显示?

How can I solve this issue and make my kivy app go real full screen?

非常感谢


解决方案

试试

from kivy.core.window import Window
Window.fullscreen = True

App.run() 方法之前执行此操作,它应该切换到全屏模式.

Do this before you App.run() method, and it should switch to fullscreen mode.

干杯

相关文章