def _do_layout(self): STD_LAYOUT = (0, wx.LEFT | wx.RIGHT | wx.EXPAND, PADDING) container = wx.BoxSizer(wx.VERTICAL) container.AddSpacer(15) if self.title: container.Add(wx_util.h0(self, self.title), 0, wx.LEFT | wx.RIGHT, PADDING) container.AddSpacer(30) if self.widgets.required_args: container.Add(wx_util.h1(self, i18n._("required_args_msg")), 0, wx.LEFT | wx.RIGHT, PADDING) container.AddSpacer(5) container.Add(wx_util.horizontal_rule(self), *STD_LAYOUT) container.AddSpacer(20) self.CreateComponentGrid(container, self.widgets.required_args, cols=self._num_req_cols) container.AddSpacer(10) if self.widgets.optional_args: # container.AddSpacer(10) container.Add(wx_util.h1(self, i18n._("optional_args_msg")), 0, wx.LEFT | wx.RIGHT, PADDING) container.AddSpacer(5) container.Add(wx_util.horizontal_rule(self), *STD_LAYOUT) container.AddSpacer(20) self.CreateComponentGrid(container, self.widgets.optional_args, cols=self._num_opt_cols) self.SetSizer(container)
def add_subparsers(self, **kwargs): if self._subparsers is not None: self.error(_('cannot have multiple subparser arguments')) # add the parser class to the arguments if it's not present kwargs.setdefault('parser_class', type(self)) if 'title' in kwargs or 'description' in kwargs: title = _(kwargs.pop('title', 'subcommands')) description = _(kwargs.pop('description', None)) self._subparsers = self.add_argument_group(title, description) else: self._subparsers = self._positionals # prog defaults to the usage message of this parser, skipping # optional arguments and with no "usage:" prefix if kwargs.get('prog') is None: formatter = self._get_formatter() positionals = self._get_positional_actions() groups = self._mutually_exclusive_groups formatter.add_usage(self.usage, positionals, groups, '') kwargs['prog'] = formatter.format_help().strip() # create the parsers action and add it to the positionals list parsers_class = self._pop_action_class(kwargs, 'parsers') action = parsers_class(option_strings=[], **kwargs) self._subparsers._add_action(action) # return the created parsers action return action
def getDialog(self): return wx.FileDialog( self, style=wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT, defaultFile=_("enter_filename"), message=_('choose_file') )
def on_start(self): if not self.skipping_config() and not self.required_section_complete(): return self.show_dialog(i18n._('error_title'), i18n._('error_required_fields'), wx.ICON_ERROR) cmd_line_args = self.core_gui.GetOptions() command = '{0} --ignore-gooey {1}'.format(self.build_spec['target'], cmd_line_args) pub.send_message(events.WINDOW_CHANGE, view_name=views.RUNNING_SCREEN) self.run_client_code(command)
def running(): self._header.SetLabel(i18n._("running_title")) self._subheader.SetLabel(i18n._('running_msg')) self._check_mark.Hide() self._settings_img.Hide() self._running_img.Show() self._error_symbol.Hide() self.Layout()
def on_cancel(self): msg = i18n._('sure_you_want_to_exit') dlg = wx.MessageDialog(None, msg, i18n._('close_program'), wx.YES_NO) result = dlg.ShowModal() if result == YES: dlg.Destroy() self.core_gui.Destroy() sys.exit() dlg.Destroy()
def showConsole(self): self.navbar.Show(False) self.console.Show(True) self.header.setImage('running_img') self.header.setTitle(_("running_title")) self.header.setSubtitle(_('running_msg')) self.footer.showButtons('stop_button') self.footer.progress_bar.Show(True) if not self.buildSpec['progress_regex']: self.footer.progress_bar.Pulse()
def __init__(self, parent, req_cols=1, opt_cols=3, title=None, **kwargs): ScrolledPanel.__init__(self, parent, **kwargs) self.SetupScrolling(scroll_x=False, scrollToTop=False) self.SetDoubleBuffered(True) self.title = title self._num_req_cols = req_cols self._num_opt_cols = opt_cols self.required_section = WidgetContainer(self, i18n._("required_args_msg")) self.optional_section = WidgetContainer(self, i18n._("optional_args_msg")) self._do_layout() self.Bind(wx.EVT_SIZE, self.OnResize)
def ask_stop(self): if not self.running(): return True if self.build_spec["disable_stop_button"]: return False msg = i18n._("sure_you_want_to_stop") dlg = wx.MessageDialog(None, msg, i18n._("stop_task"), wx.YES_NO) result = dlg.ShowModal() dlg.Destroy() if result == YES: self.stop() return True return False
def __init__(self, parent, *args, **kwargs): super(Chooser, self).__init__(parent) buttonLabel = kwargs.pop('label', _('browse')) self.widget = TextInput(self, *args, **kwargs) self.button = wx.Button(self, label=buttonLabel) self.button.Bind(wx.EVT_BUTTON, self.spawnDialog) self.layout()
def button(self, label=None, style=None, event_id=-1): return wx.Button( parent=self, id=event_id, size=(90, 24), label=i18n._(label), style=style)
def showForceStopped(self): self.showComplete() if self.buildSpec.get('force_stop_is_error', True): self.showError() else: self.showSuccess() self.header.setSubtitle(_('finished_forced_quit'))
def _init_components(self): self.text = wx.StaticText(self, label=i18n._("status")) self.cmd_textbox = wx.TextCtrl(self, -1, "", style=wx.TE_MULTILINE | wx.TE_READONLY | wx.TE_RICH) if self.build_spec.get("monospace_display"): pointsize = self.cmd_textbox.GetFont().GetPointSize() font = wx.Font(pointsize, wx.FONTFAMILY_MODERN, wx.FONTWEIGHT_NORMAL, wx.FONTWEIGHT_BOLD, False) self.cmd_textbox.SetFont(font)
def getWidget(self, parent, *args, **options): default = _('select_option') return wx.ComboBox( parent=parent, id=-1, value=default, choices=[default] + self._meta['choices'], style=wx.CB_DROPDOWN)
def showSettings(self): self.navbar.Show(True) self.console.Show(False) self.header.setImage('settings_img') self.header.setTitle(_("settings_title")) self.header.setSubtitle(self.buildSpec['program_description']) self.footer.showButtons('cancel_button', 'start_button') self.footer.progress_bar.Show(False)
def getWidget(self, parent, *args, **options): default = _('select_option') return wx.ListBox( parent=parent, choices=self._meta['choices'], size=(-1,60), style=wx.LB_MULTIPLE )
def _init_components(self): # init gui _desc = self.build_spec['program_description'] self.head_panel = header.FrameHeader( heading=i18n._("settings_title"), subheading=_desc or '', parent=self) self.runtime_display = RuntimeDisplay(self) self.foot_panel = footer.Footer(self) self.panels = [self.head_panel, self.config_panel, self.foot_panel]
def process_result(self, process): process.communicate() if self._stop_pressed_times > 0: wx.CallAfter(self.core_gui.PublishConsoleMsg, i18n._('terminated')) pub.send_message(events.WINDOW_CHANGE, view_name=views.ERROR_SCREEN) self.terminated_dialog() elif process.returncode == 0: pub.send_message(events.WINDOW_CHANGE, view_name=views.SUCCESS_SCREEN) self.success_dialog() else: pub.send_message(events.WINDOW_CHANGE, view_name=views.ERROR_SCREEN) self.error_dialog()
def verifyAutoStart(self, app, buildSpec): """ When the auto_start flag == True Gooey should skip the configuration screen """ time.sleep(1) try: # Gooey should NOT be showing the name/description headers # present on the config page title = app.TopWindow.header._header.GetLabel() subtitle = app.TopWindow.header._subheader.GetLabel() self.assertNotEqual(title, buildSpec['program_name']) self.assertNotEqual(subtitle, buildSpec['program_description']) # Gooey should be showing the console messages straight away # without manually starting the program title = app.TopWindow.header._header.GetLabel() subtitle = app.TopWindow.header._subheader.GetLabel() self.assertEqual(title,_("running_title")) self.assertEqual(subtitle, _('running_msg')) # Wait for Gooey to swap the header to the final screen while app.TopWindow.header._header.GetLabel() == _("running_title"): time.sleep(.1) # verify that we've landed on the success screen title = app.TopWindow.header._header.GetLabel() subtitle = app.TopWindow.header._subheader.GetLabel() self.assertEqual(title, _("finished_title")) self.assertEqual(subtitle, _('finished_msg')) # and that output was actually written to the console self.assertIn("Success", app.TopWindow.console.textbox.GetValue()) except: app.TopWindow.Destroy() raise else: app.TopWindow.Destroy() return None
def __init__(self, data): self.data = data # parent self.panel = None self.button_text = i18n._('browse') # Widgets self.title = None self.help_msg = None self.text_box = None self.button = None self.panel = None
def gooeySanityTest(self, app, buildSpec): time.sleep(1) try: # Check out header is present and showing data title = app.TopWindow.header._header.GetLabel() subtitle = app.TopWindow.header._subheader.GetLabel() self.assertEqual(title, buildSpec['program_name']) self.assertEqual(subtitle, buildSpec['program_description']) # switch to the run screen app.TopWindow.onStart() # Should find the expected test in the header title = app.TopWindow.header._header.GetLabel() subtitle = app.TopWindow.header._subheader.GetLabel() self.assertEqual(title,_("running_title")) self.assertEqual(subtitle, _('running_msg')) # Wait for Gooey to swap the header to the final screen while app.TopWindow.header._header.GetLabel() == _("running_title"): time.sleep(.1) # verify that we've landed on the success screen title = app.TopWindow.header._header.GetLabel() subtitle = app.TopWindow.header._subheader.GetLabel() self.assertEqual(title, _("finished_title")) self.assertEqual(subtitle, _('finished_msg')) # and that output was actually written to the console self.assertIn("Success", app.TopWindow.console.textbox.GetValue()) except: app.TopWindow.Destroy() raise else: app.TopWindow.Destroy() return None
def __init__(self, parent): wx.Dialog.__init__(self, parent) self.SetBackgroundColour('#ffffff') self.ok_button = wx.Button(self, wx.ID_OK, label=_('Ok')) self.datepicker = Classes.DatePickerCtrl(self, style=Constants.WX_DP_DROPDOWN) vertical_container = wx.BoxSizer(wx.VERTICAL) vertical_container.AddSpacer(10) vertical_container.Add(wx_util.h1(self, label=_('Select a Date')), 0, wx.LEFT | wx.RIGHT, 15) vertical_container.AddSpacer(10) vertical_container.Add(self.datepicker, 0, wx.EXPAND | wx.LEFT | wx.RIGHT, 15) vertical_container.AddSpacer(10) button_sizer = wx.BoxSizer(wx.HORIZONTAL) button_sizer.AddStretchSpacer(1) button_sizer.Add(self.ok_button, 0) vertical_container.Add(button_sizer, 0, wx.LEFT | wx.RIGHT, 15) vertical_container.AddSpacer(20) self.SetSizerAndFit(vertical_container) self.Bind(wx.EVT_BUTTON, self.OnOkButton, self.ok_button)
def arrange(self, *args, **kwargs): title = getin(self.widgetInfo, ['options', 'title'], _('choose_one')) if getin(self.widgetInfo, ['options', 'show_border'], False): boxDetails = wx.StaticBox(self, -1, title) boxSizer = wx.StaticBoxSizer(boxDetails, wx.VERTICAL) else: boxSizer = wx.BoxSizer(wx.VERTICAL) boxSizer.AddSpacer(10) boxSizer.Add(wx_util.h1(self, title), 0) for btn, widget in zip(self.radioButtons, self.widgets): sizer = wx.BoxSizer(wx.HORIZONTAL) sizer.Add(btn,0, wx.RIGHT, 4) sizer.Add(widget, 1, wx.EXPAND) boxSizer.Add(sizer, 1, wx.ALL | wx.EXPAND, 5) self.SetSizer(boxSizer)
def __init__(self, build_spec): self.current_state = States.CONFIGURING self.build_spec = build_spec self.layout_type = self.build_spec.get('layout_type') self.auto_start = self.build_spec.get('auto_start') self.progress_regex = self.build_spec.get('progress_regex') self.progress_expr = self.build_spec.get('progress_expr') self.disable_progress_bar_animation = self.build_spec['disable_progress_bar_animation'] self.program_name = self.build_spec.get('program_name') self.default_size = self.build_spec.get('default_size') self.heading_title = _("settings_title") self.heading_subtitle = self.build_spec['program_description'] or '' self.use_monospace_font = self.build_spec.get('monospace_display') self.stop_button_disabled = self.build_spec['disable_stop_button'] self.argument_groups = self.wrap(self.build_spec.get('widgets', {})) self.active_group = iter(self.argument_groups).next() self.num_required_cols = self.build_spec['num_required_cols'] self.num_optional_cols = self.build_spec['num_optional_cols'] self.text_states = { States.CONFIGURING: { 'title': _("settings_title"), 'subtitle': self.build_spec['program_description'] or '' }, States.RUNNNING: { 'title': _("running_title"), 'subtitle': _('running_msg') }, States.SUCCESS: { 'title': _('finished_title'), 'subtitle': _('finished_msg') }, States.ERROR: { 'title': _('finished_title'), 'subtitle': _('finished_error') } }
def _init_components(self): self.cancel_button = self.button(i18n._('cancel'), wx.ID_CANCEL, event_id=int(events.WINDOW_CANCEL)) self.stop_button = self.button(i18n._('stop'), wx.ID_OK, event_id=int(events.WINDOW_STOP)) self.start_button = self.button(i18n._('start'), wx.ID_OK, event_id=int(events.WINDOW_START)) self.close_button = self.button(i18n._("close"), wx.ID_OK, event_id=int(events.WINDOW_CLOSE)) self.restart_button = self.button(i18n._('restart'), wx.ID_OK, event_id=int(events.WINDOW_RESTART)) self.edit_button = self.button(i18n._('edit'), wx.ID_OK, event_id=int(events.WINDOW_EDIT)) self.running_animation = wx.animate.GIFAnimationCtrl(self, -1, image_repository.loader) self.buttons = [self.cancel_button, self.start_button, self.stop_button, self.close_button, self.restart_button, self.edit_button]
def _init_components(self): self.cancel_button = self.button(i18n._('cancel'), wx.ID_CANCEL, event_id=int(events.WINDOW_CANCEL)) self.stop_button = self.button(i18n._('stop'), wx.ID_OK, event_id=int(events.WINDOW_STOP)) self.start_button = self.button(i18n._('start'), wx.ID_OK, event_id=int(events.WINDOW_START)) self.close_button = self.button(i18n._("close"), wx.ID_OK, event_id=int(events.WINDOW_CLOSE)) self.restart_button = self.button(i18n._('restart'), wx.ID_OK, event_id=int(events.WINDOW_RESTART)) self.edit_button = self.button(i18n._('edit'), wx.ID_OK, event_id=int(events.WINDOW_EDIT)) self.progress_bar = wx.Gauge(self, range=100) self.buttons = [self.cancel_button, self.start_button, self.stop_button, self.close_button, self.restart_button, self.edit_button]
def __init__(self, build_spec): self.current_state = States.CONFIGURING self.build_spec = build_spec self.layout_type = self.build_spec.get('layout_type') self.auto_start = self.build_spec.get('auto_start') self.progress_regex = self.build_spec.get('progress_regex') self.progress_expr = self.build_spec.get('progress_expr') self.program_name = self.build_spec.get('program_name') self.default_size = self.build_spec.get('default_size') self.heading_title = _("settings_title") self.heading_subtitle = self.build_spec['program_description'] or '' self.use_monospace_font = self.build_spec.get('monospace_display') self.stop_button_disabled = self.build_spec['disable_stop_button'] self.argument_groups = self.wrap(self.build_spec.get('widgets', {})) self.active_group = iter(self.argument_groups).next() self.text_states = { States.CONFIGURING: { 'title': _("settings_title"), 'subtitle': self.build_spec['program_description'] or '' }, States.RUNNNING: { 'title': _("running_title"), 'subtitle': _('running_msg') }, States.SUCCESS: { 'title': _('finished_title'), 'subtitle': _('finished_msg') }, States.ERROR: { 'title': _('finished_title'), 'subtitle': _('finished_error') } }
def __init__(self, parent, buildSpec, **kwargs): wx.Panel.__init__(self, parent, **kwargs) self.buildSpec = buildSpec self.text = wx.StaticText(self, label=i18n._("status")) self.textbox = wx.TextCtrl( self, -1, "", style=wx.TE_MULTILINE | wx.TE_READONLY | wx.TE_RICH ) self.defaultFont = self.textbox.GetFont() self.textbox.SetFont(wx.Font( self.buildSpec['terminal_font_size'] or self.defaultFont.GetPointSize(), self.getFontStyle(), wx.NORMAL, self.buildSpec['terminal_font_weight'] or wx.NORMAL, False, self.getFontFace(), )) self.textbox.SetForegroundColour(self.buildSpec['terminal_font_color']) self.layoutComponent() self.Layout()
def _init_components(self): self.cancel_button = self.button(_('cancel'), wx.ID_CANCEL, event_id=events.WINDOW_CANCEL) self.stop_button = self.button(_('stop'), wx.ID_OK, event_id=events.WINDOW_STOP) self.start_button = self.button(_('start'), wx.ID_OK, event_id=int(events.WINDOW_START)) self.close_button = self.button(_("close"), wx.ID_OK, event_id=int(events.WINDOW_CLOSE)) self.restart_button = self.button(_('restart'), wx.ID_OK, event_id=int(events.WINDOW_RESTART)) self.edit_button = self.button(_('edit'), wx.ID_OK, event_id=int(events.WINDOW_EDIT)) self.progress_bar = wx.Gauge(self, range=100) self.time_remaining_text = wx.StaticText(self) self.buttons = [self.cancel_button, self.start_button, self.stop_button, self.close_button, self.restart_button, self.edit_button] if self.buildSpec['disable_stop_button']: self.stop_button.Enable(False)
def confirm_stop_dialog(self): result = self.show_dialog(_('sure_you_want_to_stop'), _('stop_task'), wx.YES_NO) return result == YES
def success_dialog(self): self.show_dialog(i18n._("execution_finished"), i18n._('success_message'), wx.ICON_INFORMATION)
def errorScreen(_: Callable[[str], str], state: GooeyState) -> GooeyState: return associnMany( finalScreen(_, state), ('image', state['images']['errorIcon']), ('title', _('finished_title')), ('subtitle', _('finished_error')))
def setOptions(self, options): with self.retainSelection(): self.widget.Clear() self.widget.SetItems([_('select_option')] + options)
def error_dialog(self, error_msg): self.show_dialog(i18n._('error_title'), i18n._('uh_oh').format(error_msg), wx.ICON_ERROR)
def getDialog(self): return wx.FileDialog(self, _('open_file'))
def getDialog(self): return wx.DirDialog(self, message=_('choose_folder'))
def __init__(self, parent): super(TimeDlg, self).__init__(parent, pickerClass=Classes.TimePickerCtrl, pickerGetter=lambda datepicker: datepicker.GetValue().FormatISOTime(), localizedPickerLabel=_('select_time'))
def show_missing_args_dialog(self): self.show_dialog(_('error_title'), _('error_required_fields'), wx.ICON_ERROR)
def interruptedScreen(_: Callable[[str], str], state: GooeyState): next_state = errorScreen(_, state) if state['force_stop_is_error'] else successScreen(_, state) return assoc(next_state, 'subtitle', _('finished_forced_quit'))
def __init__(self, *args, **kwargs): defaults = {'label': _('choose_time')} super(TimeChooser, self).__init__(*args, **merge(kwargs, defaults))
def __init__(self, *args, **kwargs): defaults = {'label': _('choose_colour'), 'style': wx.TE_RICH} super(ColourChooser, self).__init__(*args, **merge(kwargs, defaults))
def missingArgsDialog(): showDialog(_('error_title'), _('error_required_fields'), wx.ICON_ERROR)
def showSuccess(): showDialog(_('execution_finished'), _('success_message'), wx.ICON_INFORMATION)
def __init__(self, button_text=''): self.button_text = i18n._('browse') self.option_string = None self.parent = None self.text_box = None self.button = None
def confirmExit(): result = showDialog(_('sure_you_want_to_exit'), _('close_program'), wx.YES_NO | wx.ICON_INFORMATION) return result == DialogConstants.YES
def getWidget(self, parent, *args, **options): default = _('select_option') return wx.ListBox(parent=parent, choices=self._meta['choices'], size=(-1, 60), style=wx.LB_MULTIPLE)
def successScreen(_: Callable[[str], str], state: GooeyState) -> GooeyState: return associnMany( finalScreen(_, state), ('image', state['images']['successIcon']), ('title', _('finished_title')), ('subtitle', _('finished_msg')))
def validationFailure(): showDialog(_('error_title'), _('validation_failed'), wx.ICON_WARNING)
def showSuccess(self): self.showComplete() self.header.setImage('check_mark') self.header.setTitle(_('finished_title')) self.header.setSubtitle(_('finished_msg')) self.Layout()
def showFailure(): showDialog(_('execution_finished'), _('uh_oh'), wx.ICON_ERROR)
def showError(self): self.showComplete() self.header.setImage('error_symbol') self.header.setTitle(_('finished_title')) self.header.setSubtitle(_('finished_error'))
def confirmForceStop(): result = showDialog(_('stop_task'), _('sure_you_want_to_stop'), wx.YES_NO | wx.ICON_WARNING) return result == DialogConstants.YES
def __init__(self): self.button_text = i18n._('browse') self.parent = None self.widget = None self.button = None
def setOptions(self, options): prevSelection = self.widget.GetSelection() self.widget.Clear() for option in [_('select_option')] + options: self.widget.Append(option) self.widget.SetSelection(0)
def getDialog(self): options = self.Parent._options return wx.DirDialog(self, message=options.get('message', _('choose_folder')), defaultPath=options.get('default_path', os.getcwd()))
def confirm_exit_dialog(self): result = self.show_dialog(_('sure_you_want_to_exit'), _('close_program'), wx.YES_NO) return result == YES