def RunToolByDialog(tool, enable_debug, set_breakpoint, opts=None): dia = wx.Dialog(None, wx.ID_ANY, 'Set Tool Options') sizer = wx.BoxSizer(wx.VERTICAL) bsizer = wx.BoxSizer(wx.VERTICAL) sizer.AddSizer(bsizer, 0, wx.ALL, 5) butsizer = dia.CreateButtonSizer(wx.OK | wx.CANCEL) sizer.AddSizer(butsizer, 0, wx.ALIGN_CENTER_HORIZONTAL, 5) for o in tool.OPT_LIST: v = tool.OPT_LIST_ARG[o] show = o if v['require'] is True: show = o + '(*)' v['key'] = o avui.new_inputctl(dia, bsizer, [[show, (80, 25)], v]) if opts is not None: avui.set_inputctrl(dia, o, opts[o]) if opts is None: avui.new_inputctl( dia, bsizer, [[_('Schedule'), (80, 25)], { 'key': 'is_auto_schedule', 'type': avui.ui.OPT_TYPE_CHECK, 'label': _('If add a schedule automatically')}]) dia.SetSizer(sizer) sizer.Fit(dia) sizer.SetSizeHints(dia) if dia.ShowModal() != wx.ID_OK: return if opts is None: opts = {} for o in tool.OPT_LIST: v = tool.OPT_LIST_ARG[o] opts[o] = avui.get_inputctrl(dia, o, v['type']) if getattr(dia, 'is_auto_schedule', None) is not None: is_schedule = avui.get_inputctrl( dia, 'is_auto_schedule', avui.ui.OPT_TYPE_CHECK) if is_schedule: avschedule.AddSchedule(tool.NAME, opts) RunToolOpts(tool, opts, enable_debug, set_breakpoint)
def OpenToolsDialog(): tools = GetTools() if len(tools) == 0: return dia = wx.Dialog(None, wx.ID_ANY, 'Select Tool') sizer = wx.BoxSizer(wx.VERTICAL) bsizer = wx.BoxSizer(wx.VERTICAL) sizer.AddSizer(bsizer, 0, wx.ALL, 5) toolnames = [t.NAME for t in tools] avui.new_inputctl(dia, bsizer, [['Tool', (80, 25)], {'type': 'select', 'key': 'type', 'size': (300, 25), 'selects': toolnames}]) avui.new_inputctl(dia, bsizer, [['Debug', (80, 25)], {'type': avui.ui.OPT_TYPE_CHECK, 'key': 'in_debug', 'label': 'If enable debug'}]) avui.new_inputctl(dia, bsizer, [['BreakPoint', (80, 25)], {'type': avui.ui.OPT_TYPE_CHECK, 'key': 'set_breakpoint', 'label': 'If Set BreakPoint'}]) butsizer = dia.CreateButtonSizer(wx.OK | wx.CANCEL) sizer.AddSizer(butsizer, 0, wx.ALIGN_CENTER_HORIZONTAL, 5) dia.SetSizer(sizer) sizer.Fit(dia) sizer.SetSizeHints(dia) if dia.ShowModal() == wx.ID_OK: cid = dia.type.GetSelection() debug = dia.in_debug.IsChecked() breakpoint = dia.set_breakpoint.IsChecked() RunToolByDialog(tools[cid], debug, breakpoint)