[英]How to specify only the place but not the size of a tkinter window?
现在,我正在使用类似这样的东西来放置我的窗口:
def center_win(self):
screen_width = self.master.winfo_screenwidth()
screen_height = self.master.winfo_screenheight()
win_width = int(screen_width / 2)
win_height = int(screen_height / 3)
x_pos = int((screen_width - win_width) / 2 )
y_pos = int((screen_height - win_height) / 2)
self.master.geometry('{}x{}+{}+{}'.format(win_width, win_height,
x_pos, y_pos))
我只想提供窗口的X和Y坐标,而不是大小。 大小ist由pack()自动确定,可以。 有没有一种方法只能将x_pos和y_pos参数传递给.geometry方法?
确保只设置"+{}+{}"
部分:
root.geometry("+{}+{}".format(256, 512))
#or more generally
#widget.winfo_toplevel().geometry("+{}+{}".format(256, 512))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.