有没有办法只设置Toplevel的最大宽度而不设置高度?
答案 0 :(得分:2)
当然有一个,只需为0
参数留下height
值:
# import
try:
import tkinter as tk
except ImportError:
import Tkinter as tk
root = tk.Tk()
top = tk.Toplevel(root)
# check-print maxsize
print(top.maxsize())
# change only width to 300
top.maxsize(width=300, height=0)
# check-print maxsize again
print(top.maxsize())
# show only Toplevel and handle closing
top.protocol('WM_DELETE_WINDOW', root.destroy)
root.withdraw()
root.mainloop()