Set size of Tkinter window in Python
本问题已经有最佳答案,请猛点这里访问。
您好,我确定这应该很简单,但是我是tkinter的新手。 我想知道如何设置Tkinter窗口的大小。 这是我到目前为止的内容:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | from tkinter import * root = Tk() menu = Menu(root) root.config(menu=menu) subMenu = Menu(menu) menu.add_cascade(label="File",menu=subMenu) subMenu.add_command(label="New", command=donothing) subMenu.add_command(label="Open File...", command=donothing) subMenu.add_command(label="Close", command=donothing) subMenu.add_separator() subMenu.add_command(label="Exit", command=quit) editMenu = Menu(menu) menu.add_cascade(label="Edit",menu=editMenu) editMenu.add_command(label="Undo", command=donothing) editMenu.add_command(label="Redo", command=donothing) editMenu = Menu(menu) menu.add_cascade(label="?",menu=editMenu) editMenu.add_command(label="Check For Updates", command=update) editMenu.add_command(label="Change log", command=change_log) editMenu.add_command(label="About", command=donothing) root.mainloop() |
try a search for tkinter geometry for other examples.
good reference is http://infohost.nmt.edu/tcc/help/lang/python/tkinter.pdf
page 15 geometry strings
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | from tkinter import * root = Tk() menu = Menu(root) root.config(menu=menu) # try fiddling with these root.geometry values root.title('My tkinter size experiment') root.minsize(width=100, height=100) root.geometry('1000x920+0+0') subMenu = Menu(menu) menu.add_cascade(label="File",menu=subMenu) subMenu.add_command(label="New") subMenu.add_command(label="Open File...") subMenu.add_command(label="Close") subMenu.add_separator() subMenu.add_command(label="Exit", command=quit) editMenu = Menu(menu) menu.add_cascade(label="Edit",menu=editMenu) editMenu.add_command(label="Undo") editMenu.add_command(label="Redo") editMenu = Menu(menu) menu.add_cascade(label="?",menu=editMenu) editMenu.add_command(label="Check For Updates") editMenu.add_command(label="Change log") editMenu.add_command(label="About") root.mainloop() |