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}" ...
随机推荐
- vue 鼠标移入移出事件执行多次(尤其ie)
来自:https://www.cnblogs.com/myfirstboke/p/9150809.html 侵删 <p @mouseover="over($event)" ...
- MySQL 数据库的安装与卸载
一.安装 (1)打开下载的 mysql 安装文件双击解压缩,运行“mysql-5.5.40-win32.msi” (2)选择安装类型, 有“Typical(默认) ”. “Complete(完全) ” ...
- UI5-技术篇-SAPUI5创建自定义控件
转载:https://www.nabisoft.com/tutorials/sapui5/creating-custom-controls-in-sapui5 https://sapui5.h ...
- java.sql.Date和java.sql.Timestamp转换
转自:https://www.xuebuyuan.com/1479399.html 在开发web应用中,针对不同的数据库日期类型,我们需要在我们的程序中对日期类型做各种不同的转换.若对应数据库数据是o ...
- 大学毕业时成都SAP和深圳腾讯的Offer,我是怎么选择的
2006年校园招聘,我拿到了SAP成都研究院和深圳腾讯的offer,而我最后选择了前者. 当时我主要是基于以下四点考虑. SAP成都有最优秀的人才 2006年SAP成都研究院刚刚成立,对人才的挑选非常 ...
- [LeetCode] 671. 二叉树中第二小的节点 ☆(递归 合并)
描述 给定一个非空特殊的二叉树,每个节点都是正数,并且每个节点的子节点数量只能为 2 或 0.如果一个节点有两个子节点的话,那么这个节点的值不大于它的子节点的值. 给出这样的一个二叉树,你需要输出所有 ...
- [Jenkins][GitHub]2 持续集成环境初探
预计阅读时间:30分钟 部署环境:Jenkins ver. 2.61 + Centos7 + Java 1.8 参考链接: http://www.jianshu.com/p/22b7860b4e81 ...
- Linux学习笔记之二
vim编辑器 :三种工作模式 vim /tmp/xueying.txt 命令模式 a.i.o/esc \ :wq 保存并退出 / \ 输入模式 ...
- Ansible批量自动化管理工具
一,工具与环境介绍 1.1 ansible简介 批量管理服务器的工具 无需部署agent,通过ssh进行管理 流行的自动化运维工具:https://github.com/ansible/ansible ...
- 用js刷剑指offer(二叉搜索树的后序遍历序列)
题目描述 输入一个整数数组,判断该数组是不是某二叉搜索树的后序遍历的结果.如果是则输出Yes,否则输出No.假设输入的数组的任意两个数字都互不相同. 牛客网链接 js代码 function Verif ...