- 環(huán)境python3.x 3.x之后tkinter自帶让腹,jupyter notebook
Scale----范圍控件;顯示一個數(shù)值刻度招刨,為輸出限定范圍的數(shù)字區(qū)間
實例1--設(shè)置兩個Scale條
- orient =HORIZONTAL(該參數(shù)設(shè)置為水平范圍條,沒有默認為豎直)
from tkinter import *
root =Tk()
Scale(root, from_=0, to =42).pack()
Scale(root, from_=0, to =200,orient =HORIZONTAL).pack()
mainloop()
豎直從0-42肆良,水平從0-200,長條實際長度及像素默認揖庄,可以設(shè)置,看下面的例子3风题。
實例2--獲取Scale確定范圍坐標(biāo)
from tkinter import *
root =Tk()
s1 =Scale(root, from_=0, to =42)
s1.pack()
s2 = Scale(root, from_=0, to =200)
s2.pack()
def show():
print(s1.get(),s2.get())
Button(root,text="獲取位置",command = show).pack()
mainloop()
無精度,沒規(guī)定步進精度嫉父,沒走一下為1沛硅,也沒有設(shè)置顯示像素,0-42和0-200像素都一樣绕辖,看起來十分不美觀摇肌,點擊獲取可以獲取到兩個范圍值。
實例3--獲取Scale確定范圍坐標(biāo)
from tkinter import *
app = Tk()
#tickinterval步進刻度仪际,resolution精度每一步走5围小,length = 200像素
S1 = Scale(app, from_= 0, to = 42, tickinterval = 5, resolution =5, length = 200)
S1.pack()#包裝
S2 =Scale(app, from_ = 0, to = 200, tickinterval = 10, orient = HORIZONTAL, length = 600)
S2.pack()
def show():
print(S1.get(), S2.get())
Button(app, text = "獲取位置",command = show).pack()
mainloop()
Scale中的幾個參數(shù)設(shè)置,你會了嗎树碱?