def _get_editors(self, item): name = item and item.name or '' args = item and utils.join_value(item.args) or '' alias = item.alias if item else '' self._suggester = LibrariesSuggester(self._controller, self._history_suggester) return [FileNameEditor(self, name, 'Name', self._controller, suggestion_source=self._suggester), ValueEditor(self, args, 'Args'), ValueEditor(self, alias, 'Alias')]
def _get_editors(self, item): path = item and item.name or '' args = item and utils.join_value(item.args) or '' return [ FileNameEditor(self, path, 'Path', self._controller, suggestion_source=self._history_suggester), ValueEditor(self, args, 'Args') ]
class _Dialog(Dialog): _title = property(lambda self: utils.name_from_class(self, drop='Dialog')) def __init__(self, controller, item=None, plugin=None): # TODO: Get rid of item, everything should be in controller Dialog.__init__(self, self._title) self.SetExtraStyle(wx.WS_EX_VALIDATE_RECURSIVELY) self._controller = controller self.plugin = plugin self._sizer = wx.BoxSizer(wx.VERTICAL) self._editors = self._get_editors(item) for editor in self._editors: self._sizer.Add(editor, editor.expand_factor, wx.EXPAND) self._add_comment_editor(item) self._create_help() self._create_line() self._create_buttons() self.SetSizer(self._sizer) self._sizer.Fit(self) self._editors[0].set_focus() def _add_comment_editor(self, item): comment = ListToStringFormatter(item.comment).value if item else '' self._comment_editor = ValueEditor(self, comment, 'Comment') self._sizer.Add(self._comment_editor) def _create_line(self): line = wx.StaticLine(self, size=(20,-1), style=wx.LI_HORIZONTAL) self._sizer.Add(line, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.RIGHT|wx.TOP, 5) def _create_help(self): self._sizer.Add(HelpLabel(self, label=get_help(self._title)), flag=wx.ALL, border=2) def _create_buttons(self): buttons = self.CreateStdDialogButtonSizer(wx.OK|wx.CANCEL) self._sizer.Add(buttons, 0, wx.ALIGN_CENTER|wx.ALL, 5) def get_value(self): return [ e.get_value() for e in self._editors ] def get_comment(self): return self._comment_editor.get_value() def setFocusToOK(self): self.FindWindowById(wx.ID_OK).SetFocus()
def _add_comment_editor(self, item): comment = ListToStringFormatter(item.comment).value if item else '' self._comment_editor = ValueEditor(self, comment, 'Comment') self._sizer.Add(self._comment_editor)
def _get_editors(self, item): editor = ValueEditor(self, item.value) if self._validator: editor.set_validator(self._validator()) return [editor]