Python - Tkinter Menubutton: 一个菜单按钮是一个下拉菜单,在屏幕上停留时间的一部分。菜单的小工具,可以显示该菜单按钮的选择,当用户点击它与每个menubutton时.
 
一个菜单按钮是一个下拉菜单,在屏幕上停留时间的一部分。菜单的小工具,可以显示该菜单按钮的选择,当用户点击它与每个menubutton时.

语法:

这里是一个简单的语法来创建这个widget:

  w = Menubutton ( master, option, ... )

参数:

  • master: 这代表了父窗口.

  • options: 下面是这个小工具最常用的选项列表。这些选项可以作为键 - 值对以逗号分隔.

Option Description
activebackground The background color when the mouse is over the menubutton.
activeforeground The foreground color when the mouse is over the menubutton.
anchor This options controls where the text is positioned if the widget has more space than the text needs. The default is anchor=CENTER, which centers the text.
bg The normal background color displayed behind the label and indicator.
bitmap To display a bitmap on the menubutton, set this option to a bitmap name.
bd The size of the border around the indicator. Default is 2 pixels.
cursor The cursor that appears when the mouse is over this menubutton.
direction Set direction=LEFT to display the menu to the left of the button; use direction=RIGHT to display the menu to the right of the button; or use direction='above' to place the menu above the button.
disabledforeground 前景色显示在此菜单按钮时,它被禁用.
fg The foreground color when the mouse is not over the menubutton.
height The height of the menubutton in lines of text (not pixels!). The default is to fit the menubutton's size to its contents.
highlightcolor Color shown in the focus highlight when the widget has the focus.
image To display an image on this menubutton,
justify This option controls where the text is located when the text doesn't fill the menubutton: use justify=LEFT to left-justify the text (this is the default); use justify=CENTER to center it, or justify=RIGHT to right-justify.
menu To associate the menubutton with a set of choices, set this option to the Menu object containing those choices. That menu object must have been created by passing the associated menubutton to the constructor as its first argument.
padx 多少空间留下的左边和右边的菜单按钮的文本。默认是1.
pady How much space to leave above and below the text of the menubutton. Default is 1.
relief Selects three-dimensional border shading effects. The default is RAISED.
state Normally, menubuttons respond to the mouse. Set state=DISABLED to gray out the menubutton and make it unresponsive.
text To display text on the menubutton, set this option to the string containing the desired text. Newlines ("\n") within the string will cause line breaks.
textvariable You can associate a control variable of class StringVar with this menubutton. Setting that control variable will change the displayed text.
underline Normally, no underline appears under the text on the menubutton. To underline one of the characters, set this option to the index of that character.
width The width of the widget in characters. The default is 20.
wraplength Normally, lines are not wrapped. You can set this option to a number of characters and all lines will be broken into pieces no longer than that number.

例子:

自行尝试下面的例子:

from Tkinter import *
import tkMessageBox
import Tkinter top = Tk() mb= Menubutton ( top, text="condiments", relief=RAISED )
mb.grid()
mb.menu = Menu ( mb, tearoff = 0 )
mb["menu"] = mb.menu mayoVar = IntVar()
ketchVar = IntVar() mb.menu.add_checkbutton ( label="mayo",
variable=mayoVar )
mb.menu.add_checkbutton ( label="ketchup",
variable=ketchVar ) mb.pack()
top.mainloop()

这将产生以下结果:

 

Tkinter Menubutton(菜单按钮)的更多相关文章

  1. 菜单和按钮-EasyUI Menu 菜单、EasyUI Linkbutton 链接按钮、EasyUI Menubutton 菜单按钮、EasyUI Splitbutton 分割按钮

    EasyUI Menu 菜单 通过 $.fn.menu.defaults 重写默认的 defaults. 菜单(Menu)通常用于上下文菜单.它是创建其他菜单组件(比如:menubutton.spli ...

  2. 第二百零七节,jQuery EasyUI,MenuButton(菜单按钮)组件

    jQuery EasyUI,MenuButton(菜单按钮)组件 学习要点: 1.加载方式 2.属性列表 3.方法列表 本节课重点了解 EasyUI 中 MenuButton(菜单按钮)组件的使用方法 ...

  3. 项目一:项目第二天 Jquery ztree使用展示菜单数据 2、 基础设置需求分析 3、 搭建项目框架环境--ssh(复习) 4、 SpringData-JPA持久层入门案例(重点) 5、 Easyui menubutton菜单按钮使用 6、 Easyui messager消息框使用

    1. Jquery ztree使用展示菜单数据 2. 基础设置需求分析 3. 搭建项目框架环境--ssh(复习) 4. SpringData-JPA持久层入门案例(重点) 5. Easyui menu ...

  4. MenuButton( 菜单按钮)

    一. 加载方式//class 加载方式<a href="javascript:void(0)" id="edit" class="easyui- ...

  5. menu菜单项和menubutton菜单按钮的结合使用

    <!--创建需要显示的菜单按钮(munebutton),menu指定的是菜单项--><a href="javascript:void(0)" id="m ...

  6. jQuery EasyUI API 中文文档 - 菜单按钮(menubutton)

    <html> <head> <script src="jquery-easyui/jquery.min.js"></script> ...

  7. tkinter学习-菜单与画布

    阅读目录 Menu 菜单控件 Menubutton 菜单按钮控件 OptionMenu 选项菜单 Canvas 画布控件 Menu: 说明:菜单控件,显示菜单栏,下拉菜单和弹出菜单 属性:创建一个顶级 ...

  8. easyui源码翻译1.32--MenuButton(菜单按钮)

    前言 扩展自$.fn.linkbutton.defaults.使用$.fn.menubutton.defaults重写默认值对象..下载该插件翻译源码 菜单按钮是下拉菜单的一部分.它伴随着linkbu ...

  9. cocos2dx 菜单按钮回调方法传参 tag传参

    .h文件 void menuCallBack(CCObject* pSender); .cpp CCMenuItemSprite* item = CCMenuItemSprite::create( m ...

随机推荐

  1. Android常见问题——Genymotion无法启动问题

    在官网下载了Genymotion和VirturalBox的合集安装之后启动模拟器的时候发现启动不了(默认下载,啥都没干),在网上找了一些方法,也没有解决,最后偶然看到一种方法才解决的,先看一下具体的问 ...

  2. 物体识别重要指标——平均准确率(Average Precision, AP )

    师兄的截图,不知道出处,仅用于学习,多多包涵.

  3. Nodejs下express+ejs模板的搭建

    nodejs的环境配置,这里就不做说明了.在nodejs安装后的步骤在这里说明一下 首先 全局安装express  npm install -g express-generator 安装ok后,接着 ...

  4. sudo 运行 npm或node时,出现找不到命令

    sudo 运行 npm或node时,出现找不到命令的情况,运行下面这些命令, sudo ln -s /usr/local/bin/node /usr/bin/node sudo ln -s /usr/ ...

  5. win8.1下安装双系统ubuntu14.04.3

    一.去ubuntu官网下载长期支持版的系统,64位还是32位由物理内存而定,4G以下用32位,4G以上(包括4G)使用64位. 二.若64位的系统,下载下来的文件名应该是ubuntukylin-14. ...

  6. 关于altera fpga的io时序优化问题

    chip planner中一个io的结构如下图所示 其中左边是输出部分右边是输入部分,但是会注意到两个结构:1,寄存器,2,delay模块 以下是我的推测:这两个结构是为了做时序优化时用的,在alte ...

  7. kong nginx 配置文件说明&&借鉴

    备注:     只是简单的进行说明配置文件,不会牵扯到源码   1.  配置文件位置 // 通过ps 查找 ps -ef |grep nginx /usr/local/openresty/nginx/ ...

  8. Java NIO简单介绍(二)

    上一篇<NIO简单介绍(一)>中讲解了NIO中本地IO相关的内容,这篇重点介绍的NIO的非阻塞式网络通信 一.阻塞与非阻塞 传统的 IO 流都是阻塞式的.也就是说,当一个线程调用 read ...

  9. 运维命令:tcpdump

    tcpdump命令  tcpdump 命令是一款sniffer工具,它可以打印所有经过网络接口的数据包的头信息,也可以使用 -w 选项将数据包保存到文件中,方便以后分析. 常用参数: -a:尝试将网络 ...

  10. 『备忘录』elasticsearch 去重分页查询

    一开始数据结构设计的很复杂,又是父子关系又是嵌套关系,结果发现不能通过简单的查询得到想要的结果:比如一个商店只出现一件符合条件的商品,弄得查询语句就变成这样了 curl -XPOST http://l ...