tkinter 05 Scale scale

  •  
    Running result: https://s1.ax1x.com/2018/04/16/Cewt6P.gif
  • # coding=gbk 
    #Note : The Sacle scale will automatically pass the scale value to the line parameter of print_selection v 
    #Running result: https://s1.ax1x.com/2018/04/16/Cewt6P.gif 
    import tkinter as tk
    
    window = tk.Tk()
    window.title('my window')
    window.geometry('200x200')
    
    l = tk.Label(window, bg='yellow', width=20, text='empty')
    l.pack()
    
    # Sacle scale will automatically pass the scale value to the line parameter of print_selection v 
    def print_selection(v):
        l.config(text='you have selected ' + v)
    
    s = tk.Scale(window, label='try me', from_=5, to=11,
                 orient =tk.VERTICAL, #Set the direction of the scroll bar, vertical 
                 length=200, #Length is 200 pixels 
                 showvalue=1, #The value displayed above the progress bar 
                 tickinterval=2, #The coordinate interval is 2, 5.00, 7.00, 9.00, 11.00 
                 resolution=0.01, #Keep 2 decimal places 
                 command= print_selection
    )
    s.pack()
    
    window.mainloop ()

     

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324521223&siteId=291194637