6 python user-interface tkinter
我是 Python 初学者。最近,我完成了基础知识,现在我正在尝试制作一些 GUI 应用程序。我发现很多情况下我们使用config()和configure()。但是config()和configure()有什么区别呢?
我的意思是,什么情况下应该config()用,什么情况下应该configure()用?我这里有一小部分代码。
使用Configure的代码:
fontStyle = tkFont.Font(family="comic sans ms", size=15)
def zoomin_1():
fontsize=fontStyle['size']
fontStyle.configure(size=fontsize+5)
def zoomout_1():
fontsize = fontStyle['size']
fontStyle.configure(size=fontsize - 5)
def default_1():
fontStyle.configure(size=10)
Run Code Online (Sandbox Code Playgroud)
config使用代码:
root.config(menu=mainmenu)
mainmenu.add_cascade(label="Edit", menu=Edit_menu)
Format_menu = Menu(mainmenu, tearoff = False)
Format_menu.add_command(label="Word Wrap", command= test_fun)
Format_menu.add_command(label="Font", command= test_fun)
root.config(menu=mainmenu)
mainmenu.add_cascade(label="Format", menu=Format_menu)
Run Code Online (Sandbox Code Playgroud)
如果有人能消除这个疑问,那将会有很大帮助。