tkinter 学习3

python tkinter资源归纳

ttk部分文档翻译

ttk官方英文文档

tkinter简单功能介绍(ttk内容介绍太少,但重在全面)

csdn:使用tkinter做简单五子棋游戏

csdn:tkinter详细用法(tkinter介绍比较详细,但是没有ttk部分)

csdn:tkinter详解(没有ttk)

tkinter布局详解
ttk详解


ttk组件状态-states

state描述
activeThe mouse cursor is over the widget and pressing a mouse button will cause some action to occur
disabledWidget is disabled under program control
focusWidget has keyboard focus
pressedWidget is being pressed
selected“On”, “true”, or “current” for things like Checkbuttons and radiobuttons
backgroundWindows and Mac have a notion of an “active” or foreground window. The background state is set for widgets in a background window, and cleared for those in the foreground window
readonlyWidget should not allow user modification
alternateA widget-specific alternate display format
invalidThe widget’s value is invalid

ttk组件–下拉列表框(Combobox)

使用前导入模块:from tkinter.ttk import *

在这里插入图片描述

var=StringVar()
var.set("python")
Combobox(root,values=["python","c++","c","java","vb"],width=10,textvariable=var).pack()

Combobox参数详解

  • values :传递一个要在下拉框中显示的列表
  • width、height
  • postcommand:点击下拉列表框的那个箭头前发生的事件
  • state:列表框状态:“normal”:默认,列表框可以手动输入值,“readonly”:不能输入值,“disabled”:列表框不可选中
  • testvariable:将列表框的值绑定给一个变量
  • justify:指定文本对齐方式,参数有“left”,“center”,“right”

Spinbox–entry的子类

OptionDescription
from_
to
incrementFloat value. Specifies the amount which the increment/decrement buttons change the value. Defaults to 1.0.
valuesSequence of string or float values. If specified, the increment/decrement buttons will cycle through the items in this sequence rather than incrementing or decrementing numbers.
wrapBoolean value. If True, increment and decrement buttons will cycle from the to value to the from value or the from value to the to value, respectively.
formatString value. This specifies the format of numbers set by the increment/decrement buttons. It must be in the form “%W.Pf”, where W is the padded width of the value, P is the precision, and ‘%’ and ‘f’ are literal.
command每当上升箭头或下降箭头被按下时就会执行此命令

Progressbar–进度条

from tkinter import *
from tkinter import ttk
import time
 

def manu_increment(*args):
    for i in range(100):
        p1["value"] = i+1
        root.update()
        time.sleep(0.1)

 
root = Tk()
root.title("Progressbar组件")
# 定量进度条
p1 = ttk.Progressbar(root, length=200, mode="determinate", orient=HORIZONTAL)
p1.grid(row=1,column=1)
p1["maximum"] = 100
p1["value"] = 0
btn = ttk.Button(root,text="开始动画",command=manu_increment)
btn.grid(row=1,column=0)
root.mainloop()

在这里插入图片描述

Progressbar参数

  • orient :“horizontal”:水平,“vertical”:竖直

  • maximum:最大值:默认是100

  • length:长度

  • value:进度条加载数值
    sbar参数**

  • orient :“horizontal”:水平,“vertical”:竖直

  • maximum:最大值:默认是100

  • length:长度

  • value:进度条加载数值

  • variable:可以绑定变量

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值