![](/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.