Disabling tkinter ttk scale widget

后端 未结 2 1583
遥遥无期
遥遥无期 2020-12-12 01:20

I am trying to disable all of the (ttk) widgets in a frame, but it appears that the scale widget is giving me some trouble, as it throws the following exception:

2条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-12 01:32

    For ttk widgets you use the state method. The state method for buttons and entry widgets are just a convenience function to mimic the standard button and entry widgets.

    You can rewrite your function like this:

    def disable_widgets(parent):
        for child in parent.winfo_children():
            child.state(["disabled"])
    

    ttk states are mentioned in the ttk documentation here (though the description borders on useless): https://docs.python.org/3.1/library/tkinter.ttk.html#widget-states

提交回复
热议问题