python开发_tkinter_多级子菜单
2013-09-11 16:19
686 查看
在之前的blog中有提到python的tkinter中的菜单操作
python开发_tkinter_窗口控件_自己制作的Python IDEL_博主推荐
python开发_tkinter_窗口控件_自己制作的Python IDEL_博主推荐(二)
python开发_tkinter_菜单选项中英文切换_菜单选项不可用操作_博主推荐
python开发_tkinter_复选菜单
python开发_tkinter_单选菜单_不可用菜单操作
下面是tkinter的多级子菜单操作
运行效果:
==========================================================
代码部分:
==========================================================
python开发_tkinter_窗口控件_自己制作的Python IDEL_博主推荐
python开发_tkinter_窗口控件_自己制作的Python IDEL_博主推荐(二)
python开发_tkinter_菜单选项中英文切换_菜单选项不可用操作_博主推荐
python开发_tkinter_复选菜单
python开发_tkinter_单选菜单_不可用菜单操作
下面是tkinter的多级子菜单操作
运行效果:
==========================================================
代码部分:
==========================================================
from tkinter import * __author__ = {'name' : 'Hongten', 'mail' : 'hongtenzone@foxmail.com', 'blog' : 'http://www.cnblogs.com/', 'QQ': '648719819', 'created' : '2013-09-10'} def makeCascadeMenu(): # make menu button Cascade_button = Menubutton(mBar, text='Cascading Menus', underline=0) Cascade_button.pack(side=LEFT, padx="2m") # the primary pulldown Cascade_button.menu = Menu(Cascade_button) # this is the menu that cascades from the primary pulldown.... Cascade_button.menu.choices = Menu(Cascade_button.menu) # ...and this is a menu that cascades from that. Cascade_button.menu.choices.weirdones = Menu(Cascade_button.menu.choices) # then you define the menus from the deepest level on up. Cascade_button.menu.choices.weirdones.add_command(label='avacado', command=lambda:print('hello')) Cascade_button.menu.choices.weirdones.add_command(label='belgian endive') Cascade_button.menu.choices.weirdones.add_command(label='beefaroni') # definition of the menu one level up... Cascade_button.menu.choices.add_command(label='Chocolate') Cascade_button.menu.choices.add_command(label='Vanilla') Cascade_button.menu.choices.add_command(label='TuttiFruiti') Cascade_button.menu.choices.add_command(label='WopBopaLoopBapABopBamBoom') Cascade_button.menu.choices.add_command(label='Rocky Road') Cascade_button.menu.choices.add_command(label='BubbleGum') Cascade_button.menu.choices.add_cascade( label='Weird Flavors', menu=Cascade_button.menu.choices.weirdones) # and finally, the definition for the top level Cascade_button.menu.add_cascade(label='more choices', menu=Cascade_button.menu.choices) Cascade_button['menu'] = Cascade_button.menu return Cascade_button ################################################# #### Main starts here ... root = Tk() root.geometry('600x300') # make a menu bar mBar = Frame(root, relief=RAISED, borderwidth=2) mBar.pack(fill=X) Cascade_button = makeCascadeMenu() mBar.tk_menuBar(Cascade_button) root.title('menu demo') root.iconname('menu demo') root.mainloop()
相关文章推荐
- Python Tkinter界面应用开发-05 拉出
- python开发_tkinter_图形随鼠标移动
- python开发之tkinter实现图形随鼠标移动的方法
- Python3 Tkinter基础 Menu add_cascade 多级菜单 add_separator 分割线
- python开发_tkinter_复选菜单
- python3.3使用tkinter开发猜数字游戏示例
- python开发_tkinter_窗口控件_自己制作的Python IDEL_博主推荐
- python开发_tkinter_修改tkinter窗口的红色图标'Tk'
- python开发_tkinter_图片操作
- Python GUI开发初步——安装和使用Tkinter
- python开发_tkinter
- python开发_tkinter_单选按钮
- Python Tkinter界面应用开发-04 开始和结束
- python3.3使用tkinter开发猜数字游戏示例
- Python Tkinter界面应用开发-02 开始番茄钟应用开发
- python开发之Tkinter可视化
- python开发_tkinter_自己做的猜数字小程序
- python开发之tkinter
- Python Tkinter界面应用开发-06 结束
- Python Tkinter界面应用开发-01 简介