简体   繁体   中英

Set toolbar button toggle state wxpython

the question looks quite basic, but I cannot manage to set the state of the toolbar toggle button to not toggled, without breaking it.

I create the toolbar toggle button using

button = toolbar.AddLabelTool(..., kind=wx.ITEM_CHECK)

Then I check the its state using

button.IsToggled()

These all work fine. The problem comes when I want to manually un-toggle the button.

I have tried

button.SetToggle(False)

which does un-toggle it but seems to break the behaviour of the button - seems to make the check above always return False.

button.IsToggled = False

and

toolbar.ToggleTool(11, False)

don't seem to work.

Any ideas ? thanks

toolbar.AddLabelTool(..., kind=wx.ITEM_CHECK) I believe is deprecated.
Use toolbar.AddCheckTool(..., kind=wx.ITEM_CHECK) instead.
Then use GetToolState() to return the state of the tool.
Documented here Toolbar

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