wxpython:如何以编程方式选择无线电工具?
在wxpython中,我有一个单选工具,即一组工具,其中只有一个工具被选择(在工具栏中显示为按下状态)。当我在应用程序启动时创建工具栏时,默认情况下会选择组中的第一个工具。我想在启动时选择组中的第二个工具。我怎样才能做到这一点?
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()
self.AddRadioLabelTool( self.add_lines_id, "Add Lines", self.bmp3 )
如何使 add_points_id 而不是 pan_id 成为默认选择的工具?
向我展示了哪里记录了如何做到这一点的奖励。
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()
self.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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为您正在寻找切换命令wx.Toolbar.ToggleTool(toolId,toggle)。在您的程序中,只需添加:
文档:http://xoomer.virgilio。 it/infinity77/wxPython/Widgets/wx.ToolBar.html
I think you are looking for the toggle command wx.Toolbar.ToggleTool(toolId, toggle). In your program, just add:
Documentation: http://xoomer.virgilio.it/infinity77/wxPython/Widgets/wx.ToolBar.html