简体   繁体   English

设置工具栏按钮切换状态wxpython

[英]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. 这确实取消了切换,但是似乎破坏了按钮的行为-似乎使上面的检查始终返回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. 我相信不推荐使用toolbar.AddLabelTool(..., kind=wx.ITEM_CHECK)
Use toolbar.AddCheckTool(..., kind=wx.ITEM_CHECK) instead. 请改用toolbar.AddCheckTool(..., kind=wx.ITEM_CHECK)
Then use GetToolState() to return the state of the tool. 然后使用GetToolState()返回工具的状态。
Documented here Toolbar 在此处记录工具栏

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM