def edit_tools(self, event=None): if hasattr(self, "edit_btn") and self.edit_btn: parent = self.edit_btn.GetTopLevelParent() elif self.owner.widget: parent = self.owner.widget.GetTopLevelParent() else: parent = None dialog = ToolsDialog(parent, self.owner, items=self.value) with misc.disable_stay_on_top(common.adding_window or parent): res = dialog.ShowModal() if res == wx.ID_OK: self.on_value_edited(dialog.get_items()) dialog.Destroy()
def builder(parent, sizer, pos, number=[1]): "Factory function for EditSplitterWindow objects" dialog = wcodegen.WidgetStyleSelectionDialog(dlg_title, box_title, choices, ["Create panels"], [True]) with misc.disable_stay_on_top(common.adding_window or parent): res = dialog.ShowModal() orientation = dialog.get_selection().split(" ")[0] create_panels = dialog.get_options()[0] dialog.Destroy() if res != wx.ID_OK: return label = '%s_%d' % (tmpl_label, number[0]) while common.app_tree.has_name(label): number[0] += 1 label = '%s_%d' % (tmpl_label, number[0]) with parent.frozen(): widget = editor_class(label, parent, -1, None, None, orientation, sizer, pos) widget.properties["style"].set_to_default() if create_panels: widget._window_1 = pane1 = EditPanel(label + '_pane_1', widget, wx.NewId(), widget.virtual_sizer, 1) widget._window_2 = pane2 = EditPanel(label + '_pane_2', widget, wx.NewId(), widget.virtual_sizer, 2) node = Node(widget) widget.node = node widget.virtual_sizer.node = node widget.properties["proportion"].set(1) widget.properties["flag"].set("wxEXPAND") common.app_tree.insert(node, sizer.node, pos - 1) if create_panels: node2 = Node(widget._window_1) node3 = Node(widget._window_2) else: node2 = SlotNode(widget._window_1) node3 = SlotNode(widget._window_2) widget._window_1.node = node2 common.app_tree.add(node2, widget.node) widget._window_2.node = node3 common.app_tree.add(node3, widget.node) if parent.widget: widget.create()
def builder(parent, pos): "factory function for EditSpacer objects" dialog = _Dialog() with misc.disable_stay_on_top(common.adding_window or parent): res = dialog.ShowModal() width = dialog.width.GetValue() height = dialog.height.GetValue() dialog.Destroy() if res != wx.ID_OK: return with parent.frozen(): editor = EditSpacer('spacer', parent, width, height, pos) if parent.widget: editor.create() return editor
def builder(parent, pos): "Factory function for editor objects from GUI" dialog = wcodegen.WidgetStyleSelectionDialog( _('wxGauge'), _('Orientation'), 'wxGA_HORIZONTAL|wxGA_VERTICAL') with misc.disable_stay_on_top(common.adding_window or parent): res = dialog.ShowModal() style = dialog.get_selection() dialog.Destroy() if res != wx.ID_OK: return name = parent.toplevel_parent.get_next_contained_name('gauge_%d') with parent.frozen(): editor = EditGauge(name, parent, style, pos) editor.properties["flag"].set("wxEXPAND") if parent.widget: editor.create() return editor
def builder(parent, pos): "Factory function for editor objects from GUI" dialog = wcodegen.WidgetStyleSelectionDialog(dlg_title, box_title, choices) with misc.disable_stay_on_top(common.adding_window or parent): res = dialog.ShowModal() style = dialog.get_selection() dialog.Destroy() if res != wx.ID_OK: return name = common.root.get_next_name('gauge_%d', parent) with parent.frozen(): editor = editor_class(name, parent, style, pos) editor.properties["flag"].set("wxEXPAND") if parent.widget: editor.create() return editor
def builder(parent, index): "factory function for EditRadioButton objects" import dialogs, misc name = parent.toplevel_parent.get_next_contained_name('radio_btn_%d') dlg = dialogs.WidgetStyleSelectionDialog("RadioButton", None, None, ["?Label"]) with misc.disable_stay_on_top(common.adding_window or parent): res = dlg.ShowModal() label, = dlg.get_options() dlg.Destroy() if res != wx.ID_OK: return with parent.frozen(): editor = EditRadioButton(name, parent, index, label) editor.properties["style"].set_to_default() editor.check_defaults() if parent.widget: editor.create() return editor
def builder(parent, index): "factory function for CustomWidget objects" dialog = Dialog() with misc.disable_stay_on_top(common.adding_window or parent): res = dialog.ShowModal() klass = dialog.classname.GetValue().strip() dialog.Destroy() if res != wx.ID_OK: return name = parent.toplevel_parent.get_next_contained_name('window_%d') with parent.frozen(): editor = CustomWidget(name, parent, index, klass) editor.properties["arguments"].set( [['$parent'], ['$id']] ) # ,['$width'],['$height']] editor.properties["proportion"].set(1) editor.properties["flag"].set("wxEXPAND") if parent.widget: editor.create() return editor
def builder(parent, pos): "factory function for EditToolBar objects" dialog = Dialog() with misc.disable_stay_on_top(common.adding_window or parent): res = dialog.ShowModal() klass = dialog.klass dialog.Destroy() if res != wx.ID_OK: global _NUMBER if _NUMBER > 0: _NUMBER -= 1 return name = parent.toplevel_parent.get_next_contained_name('statusbar_%d') with parent.frozen(): editor = EditStatusBar(name, klass, parent) if parent.widget: editor.create() return editor
def builder(parent, index): "factory function for editor objects from GUI" import dialogs, misc dialog = dialogs.WidgetStyleSelectionDialog( _('wxSlider'), _('Orientation'), 'wxSL_HORIZONTAL|wxSL_VERTICAL') with misc.disable_stay_on_top(common.adding_window or parent): res = dialog.ShowModal() style = dialog.get_selection() dialog.Destroy() if res != wx.ID_OK: return name = parent.toplevel_parent.get_next_contained_name('slider_%d') with parent.frozen(): editor = EditSlider(name, parent, index, style) editor.properties["flag"].set("wxEXPAND") if parent.widget: editor.create() return editor
def builder(parent, sizer, pos): "factory function for EditSpacer objects" dialog = _Dialog(parent) with misc.disable_stay_on_top(common.adding_window or parent): res = dialog.ShowModal() width = dialog.width.GetValue() height = dialog.height.GetValue() dialog.Destroy() if res != wx.ID_OK: return name = 'spacer' with parent.frozen(): spacer = EditSpacer(name, parent, wx.NewId(), width, height, sizer, pos) node = Node(spacer) spacer.node = node if parent.widget: spacer.create() common.app_tree.insert(node, sizer.node, pos - 1)
def builder(parent, pos): "factory function for EditToolBar objects" dialog = Dialog() with misc.disable_stay_on_top(common.adding_window or parent): res = dialog.ShowModal() klass = dialog.klass dialog.Destroy() if res != wx.ID_OK: if number[0] > 0: number[0] -= 1 return name = common.root.get_next_name('statusbar_%d', parent) with parent.frozen(): editor = EditStatusBar(name, klass, parent) if parent.widget: editor.create() return editor
def builder(parent, pos): "factory function for editor objects from GUI" dialog = wcodegen.WidgetStyleSelectionDialog( _('wxStaticLine'), _('Orientation'), 'wxLI_HORIZONTAL|wxLI_VERTICAL') with misc.disable_stay_on_top(common.adding_window or parent): res = dialog.ShowModal() style = dialog.get_selection() dialog.Destroy() if res != wx.ID_OK: return name = common.root.get_next_name('static_line_%d', parent) with parent.frozen(): editor = EditStaticLine(name, parent, style, pos) if parent.IS_SIZER and "orient" in parent.properties and parent.orient: if ((parent.orient & wx.VERTICAL and style == "wxLI_HORIZONTAL") or (parent.orient & wx.HORIZONTAL and style == "wxLI_VERTICAL")): editor.properties["flag"].add("wxEXPAND") if parent.widget: editor.create() return editor
def builder(parent, index, url=None, label=None): "factory function for EditHyperlinkCtrl objects" name = parent.toplevel_parent.get_next_contained_name('hyperlink_%d') if url is None and label is None: import dialogs, misc dlg = dialogs.WidgetStyleSelectionDialog(_("Hyperlink"), None, None, ["?URL", "?Label"]) with misc.disable_stay_on_top(common.adding_window or parent): res = dlg.ShowModal() url, label = dlg.get_options() dlg.Destroy() if res != wx.ID_OK: return with parent.frozen(): editor = EditHyperlinkCtrl(name, parent, index, label or "") editor.properties["style"].set_to_default() editor.properties["attribute"].set(True) # allow to modificate it later on... editor.properties["url"].set(url or "") editor.check_defaults() if parent.widget: editor.create() return editor
def builder(parent, sizer, pos, number=[1]): "factory function for editor objects from GUI" dialog = wcodegen.WidgetStyleSelectionDialog(dlg_title, box_title, choices) with misc.disable_stay_on_top(common.adding_window or parent): res = dialog.ShowModal() style = dialog.get_selection() dialog.Destroy() if res != wx.ID_OK: return label = '%s_%d' % (tmpl_label, number[0]) while common.app_tree.has_name(label): number[0] += 1 label = '%s_%d' % (tmpl_label, number[0]) with parent.frozen(): widget = editor_class(label, parent, wx.ID_ANY, style, sizer, pos) node = Node(widget) widget.node = node widget.properties["flag"].set("wxEXPAND") if parent.widget: widget.create() common.app_tree.insert(node, sizer.node, pos - 1)
def builder(parent, pos): "Factory function for editor objects from GUI" choices = 'wxNB_TOP|wxNB_BOTTOM|wxNB_LEFT|wxNB_RIGHT' dialog = wcodegen.WidgetStyleSelectionDialog(_('wxNotebook'), _('Orientation'), choices) with misc.disable_stay_on_top(common.adding_window or parent): res = dialog.ShowModal() style = dialog.get_selection() dialog.Destroy() if res != wx.ID_OK: return name = parent.toplevel_parent.get_next_contained_name('notebook_%d') with parent.frozen(): editor = EditNotebook(name, parent, style, pos) editor.properties["proportion"].set(1) editor.properties["flag"].set("wxEXPAND") if parent.widget: editor.create() editor._insert_tab( 0, editor.next_pane_name() ) # next_pane_name will be used as label and as pane name, if possible return editor
def builder(parent, sizer, pos, number=[1]): "Factory function for editor objects from GUI" dialog = wcodegen.WidgetStyleSelectionDialog(dlg_title, box_title, choices) with misc.disable_stay_on_top(common.adding_window or parent): res = dialog.ShowModal() style = dialog.get_selection() dialog.Destroy() if res != wx.ID_OK: return with parent.frozen(): widget = editor_class(None, parent, wx.ID_ANY, style, sizer, pos) node = Node(widget) widget.node = node widget.virtual_sizer.node = node widget.properties["proportion"].set(1) widget.properties["flag"].set("wxEXPAND") if parent.widget: widget.create() common.app_tree.insert(node, sizer.node, pos - 1) widget.insert_tab( 0, widget.next_pane_name() ) # next_pane_name will be used as label and as pane name, if possible
def builder(parent, sizer, pos): "factory function for EditToolBar objects" dialog = Dialog() with misc.disable_stay_on_top(common.adding_window or parent): res = dialog.ShowModal() klass = dialog.klass dialog.Destroy() if res != wx.ID_OK: if number[0] > 0: number[0] -= 1 return name = 'statusbar_%d' % (number[0] or 1) while common.app_tree.has_name(name): number[0] += 1 name = 'statusbar_%d' % number[0] with parent.frozen(): widget = EditStatusBar(name, klass, parent) widget.node = Node(widget) common.app_tree.add(widget.node) if parent.widget: widget.create()