問題描述
有沒有其他方法可以改變窗口位置而不使用:
from kivy.config import Config
Config.set('graphics', 'position', 'custom')
Config.set('graphics', 'left', 100)
Config.set('graphics', 'top', 100)
我不想使用這個(gè),因?yàn)楫?dāng)我用我的屬性更改最后一個(gè)參數(shù) (100
) 時(shí),它不起作用.
I don't want to use this because when i change the last parameter (100
) with my property it doesn't work.
推薦答案
可以使用當(dāng)前具有 這個(gè)改變.
更新:當(dāng)前的 Kivy 穩(wěn)定版本可以實(shí)現(xiàn) → 1.10.0
.
Update: It's possible with the current Kivy stable version → 1.10.0
.
有了它,您可以訪問 Window.top
和 Window.left
屬性并在運(yùn)行時(shí)更改 Window
位置以及獲取實(shí)際窗口
的位置.如果沒有該更改(例如版本 1.9.1),就無法做到這一點(diǎn).
With that you can access the Window.top
and Window.left
properties and change Window
position at runtime as well as get the actual position of the Window
. Without that change (e.g. version 1.9.1), there's no way how to do that.
另外,Config
基本上是在應(yīng)用程序?qū)嶋H運(yùn)行之前進(jìn)行 single 更改,例如將位置設(shè)置為 [0, 0],窗口將在 App().run()
之后顯示在該位置.僅此而已.
Also, Config
is basically for a single change before the application actually runs e.g. set the position to [0, 0] and the Window will display at that position after App().run()
. Nothing more really.
這篇關(guān)于我怎樣才能改變kivy窗口的位置的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!