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"& ...
随机推荐
- TextBox 显示横线
public class Xtxt3 : TextBox { private bool m_underLine; public bool UnderLine { get { return m_unde ...
- springcloud源码解析(目录)
springcloud是一个基于springboot的一站式企业级分布式应用开发框架.springboot为其提供了创建单一项目的便利性,springcloud组合了现有的.常用的分布式项目的解决方案 ...
- python+django早教课程
虚拟环境安装项目中需要安装许多插件,为不影响系统的环境,可以为项目新建一个虚拟环境,所有的早教课程安装包在该虚拟环境中独有,以防影响其他项目.1. 安装虚拟环境:pip install virtual ...
- vue中组件之间的通信
一.vue中组件通信的种类 父组件向子组件的通信 子组件向父组件的通信 隔代组件之间的通信 兄弟 组件 之间的通信 二.实现通信的方式 props vue自定义的事件 消息订阅与发布 vuex sl ...
- Linux三剑客及使用介绍
Linux 三剑客是(grep,sed,awk)三者的简称,熟练使用这三个工具可以提升运维效率.Linux 三剑客以正则表达式作为基础,而在Linux系统中,支持两种正则表达式,分别为"标准 ...
- spice在桌面虚拟化中的应用系列之三(USB映射实现,SSL加密,密码认证,多客户端支持)
本系列其它文章 spice在桌面虚拟化中的应用系列之一(spice简介,性能优化等) spice在桌面虚拟化中的应用系列之二(Linux平台spice客户端的编译安装,支持USB映射) 1.spice ...
- JSON【1】
http://repo1.maven.org/maven2/com/fasterxml/jackson/core/ JSON[jar]包下载 JSON是什么? 是一种轻量级的数据交换格式,完全独 ...
- Spring Boot 2发送邮件手把手图文教程
原文:http://www.itmuch.com/spring-boot/send-email/ 本文基于:Spring Boot 2.1.3,理论支持Spring Boot 2.x所有版本. 最近有 ...
- 从excel 导入数据绘制 散点图
import xlrdimport matplotlib.pyplot as plt bok = xlrd.open_workbook(r'test.xls') sht = bok.sheets()[ ...
- 基于Java+Selenium的WebUI自动化测试框架(六)---浏览器初始化
本篇我们来讨论,如何写一个浏览器初始化的类.在写之前,先思考一下,我们需要一个什么样的初始化? 先来看看使用原生的Java + selenium是怎么做的.(以firefox为例) System.se ...