Kyle Anderson
Kyle Anderson

Reputation: 91

Selecting and deselecting tkinter Menu Checkbutton widgets

I have a checkbutton inside of a menu widget in python with tkinter. (Using python 3.5.2). I know that with normal checkbuttons you can select or deselect the checkbuttons using checkbutton.select() and checkbutton.deselect(). I need to know how to do this with the checkbuttons that I have in the menu object.

I have tried the menu.entrybutton.configure(id, coption) method but there is no coption for selecting and deselecting checkbuttons within the menu.

Any help would be appreciated.

Upvotes: 0

Views: 2976

Answers (1)

jasonharper
jasonharper

Reputation: 9597

You should assign an IntVar (or possibly StringVar) to the checkbutton when you create it, via its variable= configuration option. You call .get() on this var to check the button's state, and .set() to change its state.

Upvotes: 2

Related Questions