![](/img/trans.png)
[英]How can I get the Temperature to display in the top left corner while having the time and date in the top right?
[英]how can I get a tkinter window in the top right corner of any computer?
我嘗試使用屏幕大小和窗口大小方法,但是由於它們不提供數值,因此我無法將它們彼此相減。 這是我的代碼:
from tkinter import *
statistics = Tk()
screenwidth = statistics.winfo_screenwidth
windowwidth = statistics.winfo_width
distance = screenwidth - windowwidth
statistics.geometry(+distance+'0')
winfo_screenwidth
和winfo_width
都是函數,因此您需要調用它們而不是引用它們。 因此,要獲得這些值,您應該這樣做:
screenwidth = statistics.winfo_screenwidth()
windowwidth = statistics.winfo_width()
請注意,在窗口實際出現在屏幕上之前,其寬度和高度將為1。
根據您所運行的平台,您不需要執行任何這些計算。 如果為幾何提供負值,則它將引用窗口右下角相對於屏幕右下角的位置。 可以混合使用正數和負數,因此“ -1 + 1”表示將應用放在右上角。
對於OSX,FWIW,似乎並非如此。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.