python开发_tkinter_单选菜单_不可用菜单操作
在之前的blog中有提到python的tkinter中的菜单操作
python开发_tkinter_窗口控件_自己制作的Python IDEL_博主推荐
python开发_tkinter_窗口控件_自己制作的Python IDEL_博主推荐(二)
python开发_tkinter_菜单选项中英文切换_菜单选项不可用操作_博主推荐
下面是单选菜单和不可用菜单操作
运行效果:
============================================================
代码部分:
============================================================
from tkinter import * __author__ = {'name' : 'Hongten',
'mail' : 'hongtenzone@foxmail.com',
'blog' : 'http://www.cnblogs.com/',
'QQ': '',
'created' : '2013-09-10'}
#global var
checked_box = [False, False, False, False, False, False, False, False, False, False]
radio_items = ['Republican', 'Democrat', 'Libertarian', 'Commie',
'Facist', 'Labor Party', 'Torie', 'Independent',
'Anarchist', 'No Opinion']
opinion = False
#################################################
#### Main starts here ...
root = Tk()
root.geometry('250x400')
root.title('menu demo')
root.iconname('menu demo') def print_info(index):
global checked_box
global radio_items
n = [x for x in range(0, len(checked_box))]
if index in n:
checked_box[index - 1] = not checked_box[index - 1]
print(radio_items[index - 1], '?', checked_box[index - 1])
else:
pass def print_opinion():
global opinion
opinion = not opinion
print('opinion ? ', opinion) def makeRadiobuttonMenu():
# make menu button
Radiobutton_button = Menubutton(mBar, text='Radiobutton Menus',
underline=0)
Radiobutton_button.pack(side=LEFT, padx='2m') # the primary pulldown
Radiobutton_button.menu = Menu(Radiobutton_button) # and all the Radio buttons. Note that the "variable" "onvalue" and "offvalue" options
# are not supported correctly at present. You have to do all your application
# work through the calback.
Radiobutton_button.menu.add_radiobutton(label='Republican', command=print_info(1))
Radiobutton_button.menu.add_radiobutton(label='Democrat', command=print_info(2))
Radiobutton_button.menu.add_radiobutton(label='Libertarian', command=print_info(3))
Radiobutton_button.menu.add_radiobutton(label='Commie', command=print_info(4))
Radiobutton_button.menu.add_radiobutton(label='Facist', command=print_info(5))
Radiobutton_button.menu.add_radiobutton(label='Labor Party', command=print_info(6))
Radiobutton_button.menu.add_radiobutton(label='Torie', command=print_info(7))
Radiobutton_button.menu.add_radiobutton(label='Independent', command=print_info(8))
Radiobutton_button.menu.add_radiobutton(label='Anarchist', command=print_info(9))
Radiobutton_button.menu.add_radiobutton(label='No Opinion', command=print_opinion()) # set up a pointer from the file menubutton back to the file menu
Radiobutton_button['menu'] = Radiobutton_button.menu return Radiobutton_button def makeDisabledMenu():
Dummy_button = Menubutton(mBar, text='Dead Menu', underline=0)
Dummy_button.pack(side=LEFT, padx='2m') # this is the standard way of turning off a whole menu
Dummy_button["state"] = DISABLED
return Dummy_button # make a menu bar
mBar = Frame(root, relief=RAISED, borderwidth=2)
mBar.pack(fill=X) Radiobutton_button = makeRadiobuttonMenu()
NoMenu = makeDisabledMenu() mBar.tk_menuBar(Radiobutton_button, NoMenu) root.mainloop()
python开发_tkinter_单选菜单_不可用菜单操作的更多相关文章
- python开发_tkinter_获取文本框内容_给文本框添加键盘输入事件
在之前的blog中有提到python的tkinter中的菜单操作 python开发_tkinter_窗口控件_自己制作的Python IDEL_博主推荐 python开发_tkinter_窗口控件_自 ...
- python开发_tkinter_获取单选菜单值
在之前的blog中有提到python的tkinter中的菜单操作 python开发_tkinter_窗口控件_自己制作的Python IDEL_博主推荐 python开发_tkinter_窗口控件_自 ...
- python开发_tkinter_多级子菜单
在之前的blog中有提到python的tkinter中的菜单操作 python开发_tkinter_窗口控件_自己制作的Python IDEL_博主推荐 python开发_tkinter_窗口控件_自 ...
- python开发_tkinter_菜单选项中英文切换_菜单选项不可用操作_博主推荐
我使用的python版本为:3.3.2 如果你对python中tkinter模块的菜单操作不是很了解,你可以看看: python开发_tkinter_窗口控件_自己制作的Python IDEL_博主推 ...
- python开发_tkinter_复选菜单
在之前的blog中有提到python的tkinter中的菜单操作 python开发_tkinter_窗口控件_自己制作的Python IDEL_博主推荐 python开发_tkinter_窗口控件_自 ...
- python开发_tkinter_窗口控件_自己制作的Python IDEL_博主推荐(二)
在上一篇blog:python开发_tkinter_窗口控件_自己制作的Python IDEL_博主推荐 中介绍了python中的tkinter的一些东西,你可能对tkinter有一定的了解了.这篇b ...
- python开发_tkinter_小球完全弹性碰撞游戏
python开发_tkinter_小球完全弹性碰撞游戏 完成这个小球的完全弹性碰撞游戏灵感来自于: 下面是我花了一周下班时间所编写的一个小球完全弹性碰撞游戏: 游戏初始化状态: 最下面的游标和修改 ...
- python开发_tkinter_菜单的不同选项
python的tkinter模块中,菜单也可以由你自定义你的风格 下面是我做的demo 运行效果: ====================================== 代码部分: ===== ...
- python开发_tkinter_窗口控件_自己制作的Python IDEL_博主推荐
在了解python中的tkinter模块的时候,你需要了解一些tkinter的相关知识 下面是python的API文档中的一个简单例子: import tkinter as tk class Appl ...
随机推荐
- ProtocolBuffer 使用及 一些坑
Protocol Buffers,是Google公司开发的一种数据描述语言,类似于XML能够将结构化数据序列化,可用于数据存储.通信协议等方面. ProtocolBuffer的优势 跨平台: Prot ...
- Webmin试玩
安装: # cd /opt # wget http://www.webmin.com/jcameron-key.asc # wget http://www.webmin.com/download/rp ...
- Dropout caffe源码
GPU和CPU实现的不一样,这里贴的是CPU中的drop out 直接看caffe里面的源码吧:(产生满足伯努利分布的随机数mask,train的时候,data除以p,...... scale_ = ...
- 读书笔记--C陷阱与缺陷(六)
第六章 1.预处理器:预处理器先对代码进行必要的转换处理,简化编程者的工作. 它的重要原因有以下两点: a. 假如要将程序中出现的所有实例都加以修改,但希望只改动程序一处数值,重新编译实现. 预处理器 ...
- ThinkPHP文件目录说明
1.ThinkPHP文件包下目录结构说明 2.ThinkPHP文件目录下文件说明 3.Conf目录下 4.Library目录
- 四B象限图
- 洛谷P1331 海战 题解
题目传送门 思路 肯定食用dfs啦... 但关键是两条船接触了怎么判断呢?? 上图: 可以发现一下规律 当两条船接触时,必有一条直线连续穿过两条船 当一条船不与另一条船接触时,没有一条直线连续穿过两条 ...
- 在Visio里加上、下标方法
添加上标:选中要成为上标的文字,ctrl+shift+“=” 添加下标:选中要成为下标的文字,ctrl+“=”
- 《精通Python设计模式》学习之工厂方法
小书,在我以前作数据库的连接时,就用了这个工厂方法的. 归纳总结一下,更有利于成长吧. import xml.etree.ElementTree as etree import json class ...
- Android开发——子线程操作UI的几种方法(待续)
方法2 Handler andler mHandler = new Handler() { @Override public void handleMessage(Message msg) { su ...