一、参数说明

语法 作用
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单选框标签的更多相关文章

  1. tkinter中Radiobutton单选框控件(七)

    Radiobutton控件 由于本次内容中好多知识都是之前重复解释过的,本次就不做解释了.不太清楚的内容请参考tkinter1-6节中的内容 import tkinter wuya = tkinter ...

  2. RadioGroup和RadioButton(单选框)

    1.布局文件 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:t ...

  3. tkiner中Radiobutton单选框控件(七)

    Radiobutton控件 由于本次内容中好多知识都是之前重复解释过的,本次就不做解释了.不太清楚的内容请参考tkinter1-6节中的内容 import tkinter wuya = tkinter ...

  4. Qt Quick 常用元素:RadioButton(单选框),CheckBox(复选框) 与 GroupBox(分组框)

    先介绍一下 ExclusiveGroup. ExclusiveGroup (互斥分组)本身是不可见元素,用于将若干个可选择元素组合在一起, 供用户选择其中的一个选项.你可以在 ExclusiveGro ...

  5. Tkinter 之Text文本框标签

    一.参数说明 语法 作用 t=tk.Text()t.insert(END,'插入的文本信息') INSERT:光标的插入点CURRENT:鼠标的当前位置所对应的字符位置END:这个Textbuffer ...

  6. TagHelper+Layui封装组件之Radio单选框

    TagHelper+Layui封装组件之Radio单选框 标签名称:cl-radio 标签属性: asp-for:绑定的字段,必须指定 asp-items:绑定单选项 类型为:IEnumerable& ...

  7. Tkinter单选框及滚动条

    界面:左侧是单选框,右侧是信息显示框,下方是按扭 功能:点击开始爬取按扭,则会自动执行函数,显示在文本框中 indicatoron = 0 改变单选框按扭样式 效果图一: 效果图二: 效果图三: 示例 ...

  8. 可分组的选择框控件(MVVM下)(Toggle样式 仿造单选框RadioButton,复选框CheckBox功能)

    原地址: http://www.cnblogs.com/yk250/p/5660340.html 效果图如下:支持分组的单选框,复选框样式和MVVM下功能的实现.这是项目中一个快捷键功能的扩展. 1, ...

  9. WPF中单选框RadioButton

    单选框RadioButton的基本使用: <StackPanel Margin="10"> <Label FontWeight="Bold"& ...

随机推荐

  1. Spring循环依赖的三种方式以及解决办法

    一. 什么是循环依赖? 循环依赖其实就是循环引用,也就是两个或者两个以上的bean互相持有对方,最终形成闭环.比如A依赖于B,B依赖于C,C又依赖于A.如下图: 注意,这里不是函数的循环调用,是对象的 ...

  2. mongodb 备份与还原操作

    环境信息: 版本: mongodb 3.2 备份: mongodump 恢复: mongorestore 本文参考官方文档:https://docs.mongodb.com/manual/refere ...

  3. OpenStack kilo版(8) 部署cinder

    直接将cinder服务和块设备都部署在controller节点上 在controller节点添加一块100G的块设备/dev/sdb 配置数据库 (root@localhost) [(none)]&g ...

  4. 【leetcode】496. Next Greater Element I

    原题 You are given two arrays (without duplicates) nums1 and nums2 where nums1's elements are subset o ...

  5. mysql案例分析

    工作中,需要设计一个数据库存储,项目的需求大致如下: (1)对于每个用户,需要存储一个或多个库, 每个库, 由一个用户标识来标识,这里成为clientFlag. (2) 对于每一个库,结构如下: 1) ...

  6. 第四篇:python基础之杂货铺

    在这一篇中我们将对上几篇的Python零碎的知识进行补充,即字符串的格式化输出,以及深浅拷贝,接下来我们将对这两种进行一一介绍. 一.字符串格式化输出 关于字符串的格式化输出,我们需要了解为什么需要字 ...

  7. 创建第一kubernetes应用以及基本操作(六)

    1.创建一个测试用的deployment kubectl run net-test --image=alpine --replicas= sleep 2.查看获取IP情况 [root@linux ~] ...

  8. 0017SpringBoot注册Servlet三大组件(Servlet、Filter、Listener)

    由于SpringBoot默认是以jar包的形式启动嵌入式servlet容器来启动SpringBoot的web应用,所以没有web.xml文件,那么如何配置Servlet.Filter.Listener ...

  9. virtual box启动error

      启动 VirtualBox 的时候提示 “获取 VirtualBox COM 对象失败” 错误详情 “获取 VirtualBox COM 对象失败” 的错误详情: 获取 VirtualBox CO ...

  10. BZOJ1257: [CQOI2007]余数之和——整除分块

    题意 求 $\sum _{i=1}^n k \ mod \ i$($1\leq n,k\leq 10^9$). 分析 数据范围这么大 $O(n)$ 的复杂度也挺不住啊 根据取模的意义,$k \ mod ...