Tkinter 之CheckButton复选框标签
一、参数说明
| 语法 | 作用 |
|---|---|
| Checkbutton(root,text='xxxx') | 复选框显示的文本 |
| Checkbutton(root,variable=id) | 通过变量的值确定哪些复选框被选中 |
| Checkbutton(root,variable=id,onvalue=1) | 复选框选中(有效)时变量的值 |
| Checkbutton(root,variable=id,onvalue=1,offvalue=0) | 复选框未选中(无效)时变量的值 |
| Checkbutton(root,variable=id,onvalue=1,offvalue=0,command=函数) | 复选框选中时执行的命令(函数) |
二、代码示例
import tkinter as tk window = tk.Tk() def main():
global window
window.title("CheckButton参数说明")
winWidth = 600
winHeight = 400
# 获取屏幕宽高
screenWidth = window.winfo_screenwidth()
screenHeight = window.winfo_screenheight() x = int((screenWidth - winWidth) / 2)
y = int((screenHeight - winHeight) / 2)
# 设置窗口居中
window.geometry("%sx%s+%s+%s" % (winWidth, winHeight, x, y))
window.iconbitmap("./image/icon.ico") """checkbutton参数. Valid resource names: activebackground, activeforeground, anchor,
background, bd, bg, bitmap, borderwidth, command, cursor,
disabledforeground, fg, font, foreground, height,
highlightbackground, highlightcolor, highlightthickness, image,
indicatoron, justify, offvalue, onvalue, padx, pady, relief,
selectcolor, selectimage, state, takefocus, text, textvariable,
underline, variable, width, wraplength."""
var1 = tk.IntVar()
var2 = tk.IntVar()
tk.Checkbutton(window, text="篮球", onvalue=1, offvalue=0,
variable=var1, command=callBack, activebackground="#f00",
foreground="#666").pack()
tk.Checkbutton(window, text="足球", onvalue=1, offvalue=0,
variable=var2, command=callBack, activebackground="#f00",
foreground="#bbb").pack()
window.mainloop() def callBack():
print(1)
if __name__ == '__main__':
main()
三、效果图

Tkinter 之CheckButton复选框标签的更多相关文章
- tkinter中checkbutton多选框控件和variable用法(六)
checkbutton控件 简单的实现多选: import tkinter wuya = tkinter.Tk() wuya.title("wuya") wuya.geometry ...
- 复选框input:checkbox
复选框 CreateTime--2017年6月5日14:04:55Author:Marydon 五.复选框 (一)语法 <input type="checkbox" /& ...
- python之tkinter使用-复选框操作
# tkinter复选框操作 import tkinter as tk root = tk.Tk() root.title('问卷调查') root.geometry('220x80') # 设置窗口 ...
- js之全选即点击全选标签可选择全部复选框
目标效果:网页全选功能,即点击全选标签可选择全部复选框 实现代码如下 <!DOCTYPE html> <html lang="en"> <head&g ...
- JAVA个人小程序GUI篇-收银(标签、按钮、复选框、下拉标、文本域、表格······)
如果用eclipse需先装载windowsbuild //导入包 import java.awt.BorderLayout; import java.awt.EventQueue; import ja ...
- spring mvc:常用标签库(文本框,密码框,文本域,复选框,单选按钮,下拉框隐藏于,上传文件等)
在jsp页面需要引入:<%@taglib uri="http://www.springframework.org/tags/form" prefix="form&q ...
- Spring MVC-表单(Form)标签-复选框集合(Checkboxes)示例(转载实践)
以下内容翻译自:https://www.tutorialspoint.com/springmvc/springmvc_checkboxes.htm 说明:示例基于Spring MVC 4.1.6. 以 ...
- Spring MVC-表单(Form)标签-复选框(Checkbox)示例(转载实践)
以下内容翻译自:https://www.tutorialspoint.com/springmvc/springmvc_checkbox.htm 说明:示例基于Spring MVC 4.1.6. 以下示 ...
- input check复选框选择后修改<a>标签超链接href
1. 给复选框添加onclick事件 获取标签id <tbody> <c:forEach var="file" items="${files}" ...
随机推荐
- NEST指定id
1.默认以Id属性为Id,无Id属性则自动生成 2.可通过属性标签指定Id [ElasticsearchType(IdProperty = nameof(last_name))] public cla ...
- hadoop入门-centos7.2安装hadoop2.8
1. 安装准备 (1)必须安装jdk: 因为hadoop是基于Java实现的,所有必须安装jdk 是JDK不是jre jdk1.7 jdk1.8 (2)系统位数 (3)创建专用用户 useradd h ...
- MonkeyRunner——Mac
1. MonkeyRunner介绍: Android的SDK中集成了三个可用来进行自动化测试的工具:Monkey.MonkeyRunner和Robotium.这三个测试工具都是基于黑盒测试. Monk ...
- 父类调用子类的常量 lumen查询数据库方式
我要在一个基类里面实例化所有的model 要根据集成的对象定义的model实例化 BaseRepository.php <?php namespace App\Repository; class ...
- Linux开机自动启动服务
当我们的Linux,关机后,或者重启后,有些服务需要人工启动才能有.为了解决这个问题,我找了一个办法,用一个脚本,开机启动想启动的服务. 方法一:(强烈推荐) 1.写一个脚本auto.sh vim ...
- 极度舒适的 Python 入门教程,小猪佩奇也能学会~
编程几乎已经成为现代人的一门必修课,特别是 Python ,不仅长期霸占编程趋势榜.薪资榜第一,还屡屡进入小学教材,甚至成为浙江省信息技术高考项目-- 今天,小编带来了一门极度舒适的 Python 入 ...
- Linux安装java环境和maven
安装OpenJDK软件包: apt-get install openjdk-8-jdk 查看版本信息java -version 则代表安装成功 安装maven可以使用自己本机下载好的mavan使用Xf ...
- 解决mybatis实体类和数据库列名不匹配的两种办法
我们在实际开发中,会遇到实体类与数据库类不匹配的情况,在开发中就会产生各种各样的错误,那么我们应该怎么去解决这一类的错误呢?很简单,下面我们介绍两种解决方法: 首先我们看一下数据库和实体类不匹配的情况 ...
- 【OF框架】框架Cache/Session在负载均衡部署时,切换Memory/Redis测试
一.切换Memory/Redis 第一步:安装运行Redis服务,获得连接参数. 第二步:在appsettings.json中配置 EnableRedisCache 和 Redisconnection ...
- 商汤开源的mmdetection技术报告
目录 1. 简介 2. 支持的算法 3. 框架与架构 6. 相关链接 前言:让我惊艳的几个库: ultralytics的yolov3,在一众yolov3的pytorch版本实现算法中脱颖而出,收到开发 ...