Kivy应用程序窗口总是在屏幕上打开一半

时间:2016-06-27 00:16:16

标签: python kivy

如何将窗口设置为在桌面左上角按预期打开?

from kivy.config import Config
Config.set('graphics', 'resizable', '0')
Config.set('graphics', 'top', '0') ### This doesn't seem to do anything
Config.set('graphics', 'left', '0') ### This doesn't seem to do anything
from kivy.app import App
from kivy.uix.floatlayout import FloatLayout
from kivy.uix.behaviors import ButtonBehavior
from kivy.uix.image import Image
from kivy.core.window import Window
from kivy.uix.button import Button

Window.size = (1200, 800)

class ImageButton(ButtonBehavior, Image):
    pass

class ContainerView(FloatLayout):   
    pass

class ScoreboardApp(App):

    def build(self):
        cView = ContainerView()
        return cView

enter image description here

1 个答案:

答案 0 :(得分:0)

还需要一行:

Config.set('graphics', 'position', 'custom')

略高于top且低于left

  

如果使用自动,则无法控制初始位置:忽略顶部和左侧。

正如文档中提到的那样,默认情况下它实际上是auto,因此您的设置会被忽略。将其设置为custom可以解决您的问题。 :)