马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
这个我确实在新手乐园发过了,可是没人回答所以我只能在这里看看有没有人
问题:小甲鱼python第73讲讲的菜单为什么不用pack?
其中一个课上随堂代码:import tkinter as tk
root = tk.Tk()
def callback():
print("你好~")
menubar = tk.Menu(root)
openVar = tk.IntVar()
saveVar = tk.IntVar()
quitVar = tk.IntVar()
filemenu = tk.Menu(menubar, tearoff = False)
filemenu.add_checkbutton(label = "打开", command = callback, variable = openVar)
filemenu.add_checkbutton(label = "保存", command = callback, variable = saveVar)
filemenu.add_separator()
filemenu.add_checkbutton(label = "退出", command = root.quit, variable = quitVar)
menubar.add_cascade(label = "文件", menu = filemenu)
editVar = tk.IntVar()
editmenu = tk.Menu(menubar, tearoff = False)
editmenu.add_radiobutton(label = "剪切", command = callback, variable = editVar, value = 1)
editmenu.add_radiobutton(label = "拷贝", command = callback, variable = editVar, value = 2)
editmenu.add_radiobutton(label = "粘贴", command = root.quit, variable = editVar, value = 3)
menubar.add_cascade(label = "编辑", menu = editmenu)
root.config(menu = menubar)
root.mainloop()
root.config(menu = menubar) 这一句已经设置了菜单了,不能用 pack(),加上了反而报错
|