Shifty Scales Shifty Scales - 2 months ago 8x
Python Question

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


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

I have tried


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


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