wxpython: how to programmatically select a radio tool?
In wxpython I have a radio tool, i.e., a group of tools where one and only only one tool is selected (shown as depressed in the tool bar). When I create the tool bar at app startup, by default the first tool in the group is selected. I want to make the second tool in the group be selected at startup. How can I make that happen?
class Tool_bar( wx.ToolBar ):
def __init__( self ):
self.pan_id = wx.NewId()
self.AddRadioLabelTool( self.pan_id, "Pan", self.bmp1 )
self.add_points_id = wx.NewId()
self.AddRadioLabelTool( self.add_points_id, "Add Points", self.bmp2 )
self.add_lines_id = wx.NewId()
sel开发者_运维百科f.AddRadioLabelTool( self.add_lines_id, "Add Lines", self.bmp3 )
How to make add_points_id, not pan_id, be the default selected tool?
Bonus for showing me where it's documented how to do that.
I think you are looking for the toggle command wx.Toolbar.ToggleTool(toolId, toggle). In your program, just add:
self.ToggleTool(self.add_points_id, True)
Documentation: http://xoomer.virgilio.it/infinity77/wxPython/Widgets/wx.ToolBar.html
精彩评论