Python: ttk: disable/enable a button

后端 未结 1 1579
难免孤独
难免孤独 2021-01-11 17:41

I want to change ttk.Button\'s state according to some internal logic. I create a button and associate a style with it:

cardBtnStyle = ttk.Style()
cardBtnSty         


        
相关标签:
1条回答
  • 2021-01-11 18:31

    The button state is not part of its style. You can use the state() method to modify it:

    cardBtn.state(["disabled"])   # Disable the button.
    cardBtn.state(["!disabled"])  # Enable the button.
    
    0 讨论(0)
提交回复
热议问题