简体   繁体   English

将 Kivy 设置为全屏的问题

[英]Issue setting Kivy to fullscreen

I'm trying to write an application that runs kivy at full screen.我正在尝试编写一个全屏运行 kivy 的应用程序。 But these are my issues:但这些是我的问题:

1) When I run the command: 1)当我运行命令时:

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

Then kivy appears to go full time, but the window has a lot of black spaces around the background image.然后 kivy 似乎全职工作,但窗口的背景图像周围有很多黑色空间。 Even if I elongate the image, kivy just cuts the image when showing it.即使我拉长了图像,kivy 在显示图像时也会剪切图像。

2) When I run this command to set the window size to the size of my screen: 2)当我运行此命令将窗口大小设置为我的屏幕大小时:

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

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

My screen resolution is 1366x768我的屏幕分辨率是 1366x768

How can I solve this issue and make my kivy app go real full screen?如何解决这个问题并使我的 kivy 应用程序真正全屏显示?

Thank you very much非常感谢

Try尝试

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

Do this before you App.run() method, and it should switch to fullscreen mode.App.run()方法之前执行此操作,它应该切换到全屏模式。

Cheers干杯

Had a similar problem.有类似的问题。 Using the 'auto' option got rid of the bands for me.使用“自动”选项为我摆脱了乐队。

Window.fullscreen = 'auto'

Quote from Kivy Configuration Object documentation: " If set to auto, your current display's resolution will be used instead. This is most likely what you want. "引用自 Kivy 配置对象文档:“如果设置为自动,则将使用您当前的显示器分辨率。这很可能是您想要的。

I just want to complement:我只想补充:

from kivy.core.window import Window
Window.size = (1366, 768)
Window.fullscreen = True

I managed to do it as follows:我设法做到了如下:

from kivy.core.window import Window
Window.maximize()

这对我有用:

Config.set('graphics', 'fullscreen', 'auto')

Answering lately For those who are still struggling to figure out how to have the true fullscreen.最近回答对于那些仍在努力弄清楚如何拥有真正的全屏的人。 I have managed to get the rid of those black strip by adding Config.set('graphics','window_state'_'maximized' just after the fullscreen call. the whole code looks like我设法通过在全屏调用之后添加Config.set('graphics','window_state'_'maximized'来摆脱那些黑条。整个代码看起来像

from kivy.config import Config

# ...

if __name__ == "__main__":

    Config.set('graphics', 'fullscreen', 'auto')
    Config.set('graphics', 'window_state', 'maximized')
    Config.write()
    YourApp().run()

This will work no matter what is your resolution.无论您的分辨率如何,这都将起作用。

from kivy.core.window import Window
Window.fullscreen = True
Window.maximize()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM