Tkinter 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(菜单按钮)的更多相关文章
- 菜单和按钮-EasyUI Menu 菜单、EasyUI Linkbutton 链接按钮、EasyUI Menubutton 菜单按钮、EasyUI Splitbutton 分割按钮
EasyUI Menu 菜单 通过 $.fn.menu.defaults 重写默认的 defaults. 菜单(Menu)通常用于上下文菜单.它是创建其他菜单组件(比如:menubutton.spli ...
- 第二百零七节,jQuery EasyUI,MenuButton(菜单按钮)组件
jQuery EasyUI,MenuButton(菜单按钮)组件 学习要点: 1.加载方式 2.属性列表 3.方法列表 本节课重点了解 EasyUI 中 MenuButton(菜单按钮)组件的使用方法 ...
- 项目一:项目第二天 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 ...
- MenuButton( 菜单按钮)
一. 加载方式//class 加载方式<a href="javascript:void(0)" id="edit" class="easyui- ...
- menu菜单项和menubutton菜单按钮的结合使用
<!--创建需要显示的菜单按钮(munebutton),menu指定的是菜单项--><a href="javascript:void(0)" id="m ...
- jQuery EasyUI API 中文文档 - 菜单按钮(menubutton)
<html> <head> <script src="jquery-easyui/jquery.min.js"></script> ...
- tkinter学习-菜单与画布
阅读目录 Menu 菜单控件 Menubutton 菜单按钮控件 OptionMenu 选项菜单 Canvas 画布控件 Menu: 说明:菜单控件,显示菜单栏,下拉菜单和弹出菜单 属性:创建一个顶级 ...
- easyui源码翻译1.32--MenuButton(菜单按钮)
前言 扩展自$.fn.linkbutton.defaults.使用$.fn.menubutton.defaults重写默认值对象..下载该插件翻译源码 菜单按钮是下拉菜单的一部分.它伴随着linkbu ...
- cocos2dx 菜单按钮回调方法传参 tag传参
.h文件 void menuCallBack(CCObject* pSender); .cpp CCMenuItemSprite* item = CCMenuItemSprite::create( m ...
随机推荐
- IOS开发 多线程编程 - NSOperation
一.NSOperation 1.简介 NSOperation实例封装了需要执行的操作和执行操作所需的数据,并且能够以并发或非并发的方式执行这个操作. NSOperation本身是抽象基类,因此必须使用 ...
- python 生成器推导式与列表推导式的区别
生成器表达式现用现生成,列表推导式一次性生成静态数据 L = [2, 3, 5, 7] L2 = (x**2+1 for x in L) it = iter(L2) print(next(it)) L ...
- 一个MySql Sql 优化技巧分享
有天发现一个带inner join的sql 执行速度虽然不是很慢(0.1-0.2),但是没有达到理想速度.两个表关联,且关联的字段都是主键,查询的字段是唯一索引. sql如下: SELECT p_it ...
- Django项目部署(阿里云)(2)--扩展
新博客地址:http://muker.net/django-server-two.html 前面的只是最简单的部署,真实情况总是更复杂一点实际流程大概是这么操作的(我这种菜鸟的想法):本地写代码-&g ...
- object references an unsaved transient instance - save the transient instance before flushing: com.jspxcms.core.domain.ScTeam
object references an unsaved transient instance - save the transient instance before flushing: com.j ...
- maven搭建ssm框架是使用最新mysql 6.0jar遇到的问题
作者:blouc@qq.com本文为作者原创,转载请注明出处:https://www.cnblogs.com/oucbl/p/5940556.html 今天学习SSM框架整合,完成Spring和myb ...
- Java并发--Timer和TimerTask
下面内容转载自: http://blog.csdn.net/xieyuooo/article/details/8607220 其实就Timer来讲就是一个调度器,而TimerTask呢只是一个实现了r ...
- bzoj 5288 游戏
bzoj 5288 游戏 显然从点 \(x\) 出发,能到达的点是包含 \(x\) 的一段区间.用 \(L,R\) 两个数组记录每个点对应的区间端点. 如果能预处理出 \(L,R\) ,询问显然可以 ...
- 深入了解 WPF Dispatcher 的工作原理(PushFrame 部分)
在上一篇文章 深入了解 WPF Dispatcher 的工作原理(Invoke/InvokeAsync 部分) 中我们发现 Dispatcher.Invoke 方法内部是靠 Dispatcher.Pu ...
- scrapy 伪装代理和fake_userAgent的使用
伪装浏览器代理 在爬取网页是有些服务器对请求过滤的不是很高可以不用ip来伪装请求直接将自己的浏览器信息给伪装也是可以的. 第一中方法: 1.在setting.py文件中加入以下内容,这是一些浏览器的头 ...