Python Tkinter Menu
本人想开发一个简易的搜图GUI,基于此,选择用Tkinter模块开发。
需要开发出菜单栏

1 from Tkinter import *
2
3
4 root = Tk()
5 root.title("搜图助手")
6 root.geometry("500x500+600+200")
7 help = tkMessageBox.showinfo("欢迎", "欢迎使用搜图助手!\nBy Johnson")
8 def hello():
9 print "Hello "
10 menubar = Menu(root)
11 filemenu = Menu(menubar, tearoff=0)
12 filemenu.add_command(label="上一张", command=hello)
13 filemenu.add_command(label="下一张",command=hello)
14 filemenu.add_separator()
15 filemenu.add_command(label="保存",command=hello)
16 filemenu.add_command(label="查看",command=hello)
17 menubar.add_cascade(label="菜单",menu=filemenu)
18 helpmenu = Menu(menubar, tearoff=0)
19 helpmenu.add_command(label="关于", command=hello)
20 helpmenu.add_separator()
21 helpmenu.add_command(label="使用方法",command=hello)
22 menubar.add_cascade(label="帮助", menu=helpmenu)
23 root.config(menu=menubar)
24 root.mainloop()

代码如上
add_cascade方法添加菜单栏和下拉栏
add_separator方法添加分割线
congfig配置菜单栏
效果如图
1万+

被折叠的 条评论
为什么被折叠?



