>>> from tkinter import *
>>> from tkinter import ttk
>>> root=Tk()
>>> progressbar=ttk.Progressbar(root,orient=HORIZONTAL,length=200) #创建一个横向的长度为200像素?的进度条
>>> progressbar.pack() #排版
>>> progressbar.config(mode='indeterminate')  #不明确的
>>> progressbar.start() #左边其实位置 随便乱动
>>> progressbar.stop() #输入该命令后自动停止
>>> progressbar.config(mode='determinate',maximum=11.0,value=4.2)  #换一个模式。 最大值是11.0 当前value为4.2 停留在4.2位置
>>> progressbar.config(value=10) #设置值为10 ,从4.2 移动到10
>>> progressbar.step() #每次增加1
>>> progressbar.config(mode='determinate',maximum=11.0,value=5.5)
>>> progressbar.step()
>>> progressbar.step()
>>> progressbar.step()
>>> progressbar.step()
>>> progressbar.config(mode='determinate',maximum=11.0,value=5.5)
>>> progressbar.config(value=4)
>>> progressbar.step(5)
>>> value=DoubleVar()   #新建一个变量叫value ,变量类型为DoubleVar
>>> progressbar.config(variable=value)

>>> scale=ttk.Scale(root,orient=HORIZONTAL,length=400,variable=value,from_=0.0,to=11.0) #新建一个Scale 
>>> scale.pack()
>>> scale.set(4.2)
>>> scale.get()
5.841968911917099
>>>

 

 

The Tkinter Scale Widget

The Scale widget allows the user to select a numerical value by moving a “slider” knob along a scale. You can control the minimum and maximum values, as well as the resolution.

 

posted on 2017-09-23 21:15  uxiuxi  阅读(211)  评论(0)    收藏  举报