这篇blog主要是描述python中tkinter的单选按钮操作

下面是我做的demo

运行效果:

======================================

代码部分:

======================================

 from tkinter import *

 # This is a demo program that shows how to
# create radio buttons and how to get other widgets to
# share the information in a radio button.
#
# There are other ways of doing this too, but
# the "variable" option of radiobuttons seems to be the easiest.
#
# note how each button has a value it sets the variable to as it gets hit. class Test(Frame):
def printit(self):
print("hi") def createWidgets(self): self.flavor = StringVar()
self.flavor.set("chocolate") self.radioframe = Frame(self)
self.radioframe.pack() # 'text' is the label
# 'variable' is the name of the variable that all these radio buttons share
# 'value' is the value this variable takes on when the radio button is selected
# 'anchor' makes the text appear left justified (default is centered. ick)
self.radioframe.choc = Radiobutton(
self.radioframe, text="Chocolate Flavor",
variable=self.flavor, value="chocolate",
anchor=W)
self.radioframe.choc.pack(fill=X) self.radioframe.straw = Radiobutton(
self.radioframe, text="Strawberry Flavor",
variable=self.flavor, value="strawberry",
anchor=W)
self.radioframe.straw.pack(fill=X) self.radioframe.lemon = Radiobutton(
self.radioframe, text="Lemon Flavor",
variable=self.flavor, value="lemon",
anchor=W)
self.radioframe.lemon.pack(fill=X) # this is a text entry that lets you type in the name of a flavor too.
self.entry = Entry(self, textvariable=self.flavor)
self.entry.pack(fill=X)
self.QUIT = Button(self, text='QUIT', foreground='red',
command=self.quit)
self.QUIT.pack(side=BOTTOM, fill=BOTH) def __init__(self, master=None):
Frame.__init__(self, master)
Pack.config(self)
self.createWidgets() test = Test() test.mainloop()

========================================================

More reading,and english is important.

I'm Hongten

大哥哥大姐姐,觉得有用打赏点哦!多多少少没关系,一分也是对我的支持和鼓励。谢谢。
Hongten博客排名在100名以内。粉丝过千。
Hongten出品,必是精品。

E | hongtenzone@foxmail.com  B | http://www.cnblogs.com/hongten

========================================================

python开发_tkinter_单选按钮的更多相关文章

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

    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_多级子菜单

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

  5. python开发_tkinter_单选菜单_不可用菜单操作

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

  6. python开发_tkinter_复选菜单

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

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

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

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

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

  9. python开发_tkinter_小球完全弹性碰撞游戏_源码下载

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

随机推荐

  1. MVC Ajax Form & Ajax Valida(笔记)

    1.引入必要的文件 <script src=.min.js")" type="text/javascript"></script> &l ...

  2. shell 数组基础->

    数组其实也算是变量, 传统的变量只能存储一个值, 但数组可以存储多个值. 普通数组:只能使用整数 作为数组索引 [有序 0 1 2 3 4 ]关联数组:可以使用字符串 作为数组索引 [无序 name ...

  3. 激活Win10内置版Linux (ubuntu)

    微软自从14316版本后,就开始原生支持Linux  Bash命令行. 1.首先到系统设置——更新和安全——针对开发人员——选择开发者模式. 2.控制面板→程序和功能→启用或关闭Windows功能,勾 ...

  4. 组件化表单解决方案AForm 1.3 发布

    v1.3 更新日志 输入控件的实现改为实例化模式,同类型多个输入控件在同一个表单不会冲突 输入控件实现了继承 可以使用AForm.create创建表单,和使用new AForm创建实例的参数和结果一样 ...

  5. UVA10212 【The Last Non-zero Digit.】

    暴力可做!!!(十秒还不打暴力!!!)暴力算阶乘边算边取余上代码 #include<iostream> #define int long long //开long long using n ...

  6. Ubuntu Touch On Nexus4 Manual Install (手动安装) under Gentoo

    Table of Contents 1. 准备工作: 2. Saucy Salamander 3. 刷入 最新 版Touch 最近手里的 Nexus 4 手机一直闲置,它的配置要比我六年前买的笔记本还 ...

  7. Python中super的应用

    约定 单继承 多继承 super 是个类 多继承中 super 的工作方式 参考资料 约定 在开始之前我们来约定一下本文所使用的 Python 版本.默认用的是 Python 3,也就是说:本文所定义 ...

  8. WeifenLuo.WinFormsUI.Docking"的使用

    要用 WeifenLuo.WinFormsUI.Docking 首先要下载: WeifenLuo.WinFormsUI.Docking 在当前工程“解决方案 - 引用”中 >> 右击引用 ...

  9. Ansible常见模块介绍

    本节内容: ansible命令基础 常见模块举例 一.ansible命令基础 语法: ansible <host-pattern> [-f forks] [-m module_name] ...

  10. [python selenium] 操作方法整理

    个人笔记,摘抄自虫师python selenum,仅供个人参考 1.安装: pip install selenium 下载webdriver # webdriver 下载并放置在python主目录 · ...