在之前的blog中有提到python的tkinter中的菜单操作

python开发_tkinter_窗口控件_自己制作的Python IDEL_博主推荐

python开发_tkinter_窗口控件_自己制作的Python IDEL_博主推荐(二)

python开发_tkinter_菜单选项中英文切换_菜单选项不可用操作_博主推荐

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_单选菜单_不可用菜单操作的更多相关文章

  1. python开发_tkinter_获取文本框内容_给文本框添加键盘输入事件

    在之前的blog中有提到python的tkinter中的菜单操作 python开发_tkinter_窗口控件_自己制作的Python IDEL_博主推荐 python开发_tkinter_窗口控件_自 ...

  2. python开发_tkinter_获取单选菜单值

    在之前的blog中有提到python的tkinter中的菜单操作 python开发_tkinter_窗口控件_自己制作的Python IDEL_博主推荐 python开发_tkinter_窗口控件_自 ...

  3. python开发_tkinter_多级子菜单

    在之前的blog中有提到python的tkinter中的菜单操作 python开发_tkinter_窗口控件_自己制作的Python IDEL_博主推荐 python开发_tkinter_窗口控件_自 ...

  4. python开发_tkinter_菜单选项中英文切换_菜单选项不可用操作_博主推荐

    我使用的python版本为:3.3.2 如果你对python中tkinter模块的菜单操作不是很了解,你可以看看: python开发_tkinter_窗口控件_自己制作的Python IDEL_博主推 ...

  5. python开发_tkinter_复选菜单

    在之前的blog中有提到python的tkinter中的菜单操作 python开发_tkinter_窗口控件_自己制作的Python IDEL_博主推荐 python开发_tkinter_窗口控件_自 ...

  6. python开发_tkinter_窗口控件_自己制作的Python IDEL_博主推荐(二)

    在上一篇blog:python开发_tkinter_窗口控件_自己制作的Python IDEL_博主推荐 中介绍了python中的tkinter的一些东西,你可能对tkinter有一定的了解了.这篇b ...

  7. python开发_tkinter_小球完全弹性碰撞游戏

    python开发_tkinter_小球完全弹性碰撞游戏   完成这个小球的完全弹性碰撞游戏灵感来自于: 下面是我花了一周下班时间所编写的一个小球完全弹性碰撞游戏: 游戏初始化状态: 最下面的游标和修改 ...

  8. python开发_tkinter_菜单的不同选项

    python的tkinter模块中,菜单也可以由你自定义你的风格 下面是我做的demo 运行效果: ====================================== 代码部分: ===== ...

  9. python开发_tkinter_窗口控件_自己制作的Python IDEL_博主推荐

    在了解python中的tkinter模块的时候,你需要了解一些tkinter的相关知识 下面是python的API文档中的一个简单例子: import tkinter as tk class Appl ...

随机推荐

  1. 41 - 数据库-pymysql41 - 数据库-pymysql-DBUtils

    目录 1 Python操作数据库 2 安装模块 3 基本使用 3.1 创建一个连接 3.2 连接数据库 3.3 游标 3.3.1 利用游标操作数据库 3.3.2 事务管理 3.3.3 执行SQL语句 ...

  2. ClientDataset 三层 var and out arguments must match parameter

    ​​​将Delphi升级到10.1.2后,从客户端传ClientDataset的Delta数据到服务端程序时,出现var and out arguments must match parameter错 ...

  3. Focal Loss笔记

    论文:<Focal Loss for Dense Object Detection> Focal Loss 是何恺明设计的为了解决one-stage目标检测在训练阶段前景类和背景类极度不均 ...

  4. 09 Command Documentation 命令文档

    Command Documentation 命令文档   There is a suite of programs to build and process Go source code. Inste ...

  5. linux创建新用户

    服务器只用root账号会有风险,最好是每个人使用一个账号. 1. 添加用户名 adduser linuxidc 2. 给这个用户名设置新密码 passwd linuxidc 3.授权 个人用户的权限只 ...

  6. 字符串匹配算法之 kmp算法 (python版)

    字符串匹配算法之 kmp算法 (python版) 1.什么是KMP算法 KMP是三位大牛:D.E.Knuth.J.H.MorriT和V.R.Pratt同时发现的.其中第一位就是<计算机程序设计艺 ...

  7. python网络编程-socket“粘包”(小数据发送问题)

    一:什么是粘包 “粘包”, 即服务器端你调用时send 2次,但你send调用时,数据其实并没有立刻被发送给客户端,而是放到了系统的socket发送缓冲区里,等缓冲区满了.或者数据等待超时了,数据才会 ...

  8. sublime Text快捷键(超级全)

    sublime Text快捷键(超级全) Ctrl+Shift+P:打开命令面板 Ctrl+P:搜索项目中的文件 Ctrl+G:跳转到第几行 Ctrl+W:关闭当前打开文件 Ctrl+Shift+W: ...

  9. vue系列之项目优化

    webpack中的Code Splitting Code Splitting是什么以及为什么 在以前,为了减少HTTP请求,通常地,我们会把所有的代码都打包成一个单独的JS文件,但是,如果这个文件体积 ...

  10. (一)问候 Log4j 你好

    第一节: Log4j 简介 Log4j -------- log for java(java的日志) 是java主流的日志框架,提供各种类型,各种存储,各种格式,多样化的日志服务: 在爬虫领域,主要用 ...