Tkinter 之RadioButton单选框标签
一、参数说明
| 语法 | 作用 |
|---|---|
| Radiobutton(root,text='xxxx') | 单选框文本显示内容 |
| Radiobutton(root,variable=color) | 单选框索引变量,通过变量的值确定哪个单选框被选中 |
| Radiobutton(root,variable=color,value='red') | 单选框选中时设定变量的值 |
| Radiobutton(root,variable=color,value='red',command=函数) | 单选框选中时执行的命令(函数) |
| Radiobutton(root,indicatoron=False) | 设置单选框类型(默认为True) |
二、代码示例
import tkinter as tk window = tk.Tk() def main():
global window
# 设置主窗体大小
winWidth = 600
winHeight = 400
# 获取屏幕分辨率
screenWidth = window.winfo_screenwidth()
screenHeight = window.winfo_screenheight()
# 计算主窗口在屏幕上的坐标
x = int((screenWidth - winWidth)/ 2)
y = int((screenHeight - winHeight) / 2) # 设置主窗口标题
window.title("RadioButton参数说明")
# 设置主窗口大小
window.geometry("%sx%s+%s+%s" % (winWidth, winHeight, x, y))
# 设置窗口宽高固定
window.resizable(0,0)
# 设置窗口图标
window.iconbitmap("./image/icon.ico") """radiobutton参数. Valid resource names: activebackground, activeforeground, anchor,
background, bd, bg, bitmap, borderwidth, command, cursor,
disabledforeground, fg, font, foreground, height,
highlightbackground, highlightcolor, highlightthickness, image,
indicatoron, justify, padx, pady, relief, selectcolor, selectimage,
state, takefocus, text, textvariable, underline, value, variable,
width, wraplength.""" # 设置默认选中
v=tk.IntVar()
v.set(2)
tk.Radiobutton(window, text="男", font=("Arial", 16), value=2, variable=v, indicatoron=False ).pack()
tk.Radiobutton(window, text="女", font=("Arial", 16),value=1, variable=v, indicatoron=False ).pack() window.mainloop() def click():
print("click") if __name__ == '__main__':
main()
三、效果图

Tkinter 之RadioButton单选框标签的更多相关文章
- tkinter中Radiobutton单选框控件(七)
Radiobutton控件 由于本次内容中好多知识都是之前重复解释过的,本次就不做解释了.不太清楚的内容请参考tkinter1-6节中的内容 import tkinter wuya = tkinter ...
- RadioGroup和RadioButton(单选框)
1.布局文件 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:t ...
- tkiner中Radiobutton单选框控件(七)
Radiobutton控件 由于本次内容中好多知识都是之前重复解释过的,本次就不做解释了.不太清楚的内容请参考tkinter1-6节中的内容 import tkinter wuya = tkinter ...
- Qt Quick 常用元素:RadioButton(单选框),CheckBox(复选框) 与 GroupBox(分组框)
先介绍一下 ExclusiveGroup. ExclusiveGroup (互斥分组)本身是不可见元素,用于将若干个可选择元素组合在一起, 供用户选择其中的一个选项.你可以在 ExclusiveGro ...
- Tkinter 之Text文本框标签
一.参数说明 语法 作用 t=tk.Text()t.insert(END,'插入的文本信息') INSERT:光标的插入点CURRENT:鼠标的当前位置所对应的字符位置END:这个Textbuffer ...
- TagHelper+Layui封装组件之Radio单选框
TagHelper+Layui封装组件之Radio单选框 标签名称:cl-radio 标签属性: asp-for:绑定的字段,必须指定 asp-items:绑定单选项 类型为:IEnumerable& ...
- Tkinter单选框及滚动条
界面:左侧是单选框,右侧是信息显示框,下方是按扭 功能:点击开始爬取按扭,则会自动执行函数,显示在文本框中 indicatoron = 0 改变单选框按扭样式 效果图一: 效果图二: 效果图三: 示例 ...
- 可分组的选择框控件(MVVM下)(Toggle样式 仿造单选框RadioButton,复选框CheckBox功能)
原地址: http://www.cnblogs.com/yk250/p/5660340.html 效果图如下:支持分组的单选框,复选框样式和MVVM下功能的实现.这是项目中一个快捷键功能的扩展. 1, ...
- WPF中单选框RadioButton
单选框RadioButton的基本使用: <StackPanel Margin="10"> <Label FontWeight="Bold"& ...
随机推荐
- 每周分享五个 PyCharm 使用技巧(三)
文章首发于 微信公众号:Python编程时光 PyCharm 是大多数 Python 开发者的首选 IDE,每天我们都在上面敲着熟悉的代码,写出一个又一个奇妙的功能. 一个每天都在使用的工具,如果能掌 ...
- VBA事件(十七)
在VBA中,要手动更改单元格或单元格值范围时,可以触发事件驱动的编程. 更改事件可能会使事情变得更容易,但您可以非常快速地结束一个完整的格式化页面.VBA中有两种事件 - 工作表事件 工作簿事件 工作 ...
- 【转载】C#使用Except方法求取两个List集合的差集数据
在C#语言的编程开发中,针对List集合的运算有时候需要计算两个List集合的差集数据,集合的差集是取在该集合中而不在另一集合中的所有的项.A集合针对B集合的差集数据指的是所有在A集合但不在B集合的元 ...
- pyhton中map和reduce
from functools import reduce import numpy as np ''' reduce[function, sequence[, initial]]使用 1.functi ...
- LVS工作原理及集群类型
Cluster概念 Cluster:集群,为解决某个特定问题将多台计算机组合起来形成的单个系统 Linux Cluster类型: LB:Load Balancing,负载均衡 HA:High ...
- Django中使用JWT
JWT """ 1.组成: header.payload.signature 头.载荷.签名 2.距离: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1 ...
- spring--分类索引
1.过时api Spring(一)解决XmlBeanFactory过时问题 元素 'ref' 中不允许出现属性 'local' Spring学习笔记 关于spring 2.x中dependency-c ...
- cuda实现向量相加
cuda实现向量相加 博客最后附上整体代码 如果有说的不对的地方还请前辈指出, 因为cuda真的接触没几天 一些总结(建议看) cuda 并不纯GPU在运行程序, 而是 cpu 与 gpu 一起在运行 ...
- The New Stack:KubeEdge将Kubernetes的能力延伸至边缘
3月29日,权威技术分析网站The New Stack在Edge/IoT专栏发表了关于边缘计算项目KubeEdge的最新调研报告.原文观点如下: https://github.com/kubeedge ...
- evpp return index.html
https://github.com/yuqingtong1990/ggtalk_server/blob/99f0f85c683dc0a0c3e76dcae611f60f6456eed6/server ...