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}" ...
随机推荐
- The Art Of Loving
The Art Of Loving 来源 https://www.zhihu.com/question/23720541 ----------------------------- 茫然的蒲公英 有书 ...
- Spring循环依赖的三种方式以及解决办法
一. 什么是循环依赖? 循环依赖其实就是循环引用,也就是两个或者两个以上的bean互相持有对方,最终形成闭环.比如A依赖于B,B依赖于C,C又依赖于A.如下图: 注意,这里不是函数的循环调用,是对象的 ...
- iOS - 处理通话或录音状态中界面错乱的重布局
iphone设备在通话或录音状态中,状态栏下移了20个像素,这时controller的view的frame的高度就减少了20个像素,所以我们需要根据view的frame去布局子view.但是是,当状态 ...
- Python Web 程序使用 uWSGI 部署
Python Web 程序使用 uWSGI 部署 WSGI是什么? WSGI,全称 Web Server Gateway Interface,或者 Python Web Server Gateway ...
- SAP云平台上的ABAP编程环境里如何消费第三方服务
在ABAP On-Premises环境下,使用ABAP编程消费第三方服务,相信很多ABAP顾问都已经非常熟悉了,无非就是使用CL_HTTP_CLIENT或者CL_REST_HTTP_CLIENT来发送 ...
- 6.JUC之ReentrantReadWriteLock
一.概述: Java纪年1.5年,ReentrantReadWriteLock诞生于JUC,此后,国人一般称它为读写锁.人如其名,他就是一个可重入锁,同时他还是一个读写锁 a)跟ReentrantLo ...
- SQLSEVER刚建表时主键自增
alter table 表名 drop column ID alter table 表名 add ID int identity(1,1)
- NTFS文件系统概述
NTFS简介 NTFS是Windows NT家族1的限制级专用的文件系统2.Win95.Win98识别不了NTFS,只有支持NT内核的OS才能识别NTFS文件系统.当前,NTFS取代了老式的FAT文件 ...
- 【深度学习】基于Pytorch的ResNet实现
目录 1. ResNet理论 2. pytorch实现 2.1 基础卷积 2.2 模块 2.3 使用ResNet模块进行迁移学习 1. ResNet理论 论文:https://arxiv.org/pd ...
- <<构建之法>>--第二次作业
GIT地址 https://github.com/Panghu98/AchaoCalculator.git GIT用户名 Panghu98 学号后五位 62632 博客地址 https://www.c ...