简体   繁体   中英

How to set the state of a tkinter Scale widget to disabled?

I have been looking around for a way to disable the Scale widget of tkinter but I couldn't find one.

I tried a few things but none seem to work:

w = Scale(master, from_=0, to=100)
w.pack()
w.state(statespec=DISABLED)
w.config(state=DISABLED)
w.config(state='disabled')
w.configure(state='disabled')

Does anyone know if it possible or if there is a workaround ? I managed to get it to work fine for Button and Checkbutton widgets.

w.config(state=DISABLED,takefocus=0)

will make scale widget disabled.It nolonger move

from Tkinter import *

master=Tk()
w = Scale(master, from_=1, to=10)
w.config(state=DISABLED,takefocus=0)
w.pack()

master.mainloop()

Its works perfect for me.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM