好吧,这是文档,看wxWidget文档,下面有一段我写得代码
wxToolBar::ToggleTool
void ToggleTool(int toolId, const bool toggle)
Toggles a tool on or off. This does not cause any event to get emitted.
Parameters
toolId
Tool in question.
toggle
If true, toggles the tool on, otherwise toggles it off.
Remarks
Only applies to a tool that has been specified as a toggle tool.
#-----------------------------------------------
import wx
ID_ToggleTest = wx.NewId()
class MyFrame(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, parent=None)
self.toolbar = self.CreateToolBar(wx.TB_HORIZONTAL|wx.NO_BORDER|wx.TB_FLAT)
self.toolbar.AddCheckLabelTool(ID_ToggleTest, 'ToggleTest', wx.ArtProvider.GetBitmap(wx.ART_NEW), wx.NullBitmap, '')
self.toolbar.Realize()
button = wx.Button(self, -1, 'Toggle ToolButton')
self.Bind(wx.EVT_BUTTON, self.OnToggleToolButton, button)
def OnToggleToolButton(self, event):
self.toolbar.ToggleTool(ID_ToggleTest, (not self.toolbar.GetToolState(ID_ToggleTest)))
if __name__ == '__main__':
app = wx.PySimpleApp()
frame = MyFrame()
frame.Show()
app.MainLoop()