Tkinter 允许 window 调整大小从 - 到一定数量
Tkinter allow window resizing from-to a certain amount
我想要一个 window,可以调整大小,但不能 "anyhow"。
我的意思是有一个点,比方说 200x200 像素之后 window 不再可调整大小,所以它不会变小,而像 1000x1000 这样的上限点,之后它不能变大。
self.resizable(0, 0)
禁用任何大小更改并且不好。
你应该看看 minsize(width, height)
和 maxsize(width, height)
import tkinter as tk
def get_size():
w = root.winfo_width()
h = root.winfo_height()
print(w, h)
root = tk.Tk()
root.minsize(200, 200)
root.maxsize(1000, 1000)
btn = tk.Button(root, text = 'Get Current Window Size',\
command = get_size)
btn.pack(expand = True)
root.mainloop()
我想要一个 window,可以调整大小,但不能 "anyhow"。 我的意思是有一个点,比方说 200x200 像素之后 window 不再可调整大小,所以它不会变小,而像 1000x1000 这样的上限点,之后它不能变大。
self.resizable(0, 0)
禁用任何大小更改并且不好。
你应该看看 minsize(width, height)
和 maxsize(width, height)
import tkinter as tk
def get_size():
w = root.winfo_width()
h = root.winfo_height()
print(w, h)
root = tk.Tk()
root.minsize(200, 200)
root.maxsize(1000, 1000)
btn = tk.Button(root, text = 'Get Current Window Size',\
command = get_size)
btn.pack(expand = True)
root.mainloop()