def xml_builder(attrs, parent, sizer, sizeritem, pos=None): "Factory to build editor objects from a XML file" from xml_parse import XmlParsingError try: name = attrs['name'] except KeyError: raise XmlParsingError(_("'name' attribute missing")) if sizer is None or sizeritem is None: raise XmlParsingError(_("sizer or sizeritem object cannot be None")) widget = editor_class(name, parent, wx.NewId(), None, None, editor_style, sizer, pos) #sizer.set_item(widget.pos, proportion=sizeritem.proportion, span=sizeritem.span, flag=sizeritem.flag, border=sizeritem.border) node = Node(widget) widget.node = node widget.virtual_sizer.node = node if pos is None: common.app_tree.add(node, sizer.node) else: common.app_tree.insert(node, sizer.node, pos - 1) node2 = SlotNode(widget._window_1) widget._window_1.node = node2 common.app_tree.add(node2, widget.node) node3 = SlotNode(widget._window_2) widget._window_2.node = node3 common.app_tree.add(node3, widget.node) return widget
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 free_slot(self, pos, force_layout=True): "Replaces the element at pos with an empty slot" if self.window.orientation == "wxSPLIT_VERTICAL": labels = ("SLOT Left", "SLOT Right") else: labels = ("SLOT Top", "SLOT Bottom") if pos == 1: if self.window.widget and self.window._window_1 and self.window._window_1.widget: self.window.widget.Unsplit(self.window._window_1.widget) old_node = self.window._window_1.node slot = SizerSlot(self.window, self, pos, labels[0]) # XXX no node, no tree visualization? self.window._window_1 = slot w = self.window._window_1 else: if self.window.widget and self.window._window_2 and self.window._window_2.widget: self.window.widget.Unsplit(self.window._window_1.widget) old_node = self.window._window_2.node slot = SizerSlot(self.window, self, pos, labels[1]) # XXX no node, no tree visualization? self.window._window_2 = slot w = self.window._window_2 w.node = node = SlotNode(w) common.app_tree.change_node(old_node, w, node) self.window.split() return slot
def on_load(self): # create slot nodes for empty slots for p, page in enumerate(self.pages): if page is not None: continue self.pages[p] = slot = SizerSlot(self, self.virtual_sizer, p + 1) node = slot.node = SlotNode(slot) common.app_tree.insert(node, self.node, p)
def free_slot(self, pos, force_layout=True): "Replaces the element at pos with an empty slot" if self.window._is_removing_pages or not self.window.widget: return slot = SizerSlot(self.window, self, pos) # XXX node handling? #self._logger.debug('free: %s, %s, %s', slot, slot.pos, pos) slot.create() label = self.window.tabs[pos - 1][0] self.window.widget.RemovePage(pos - 1) w = self.window.pages[pos - 1] old_node = w.node self.window.pages[pos - 1] = slot slot.node = node = SlotNode(slot) common.app_tree.change_node(old_node, slot, node) self.window.widget.InsertPage(pos - 1, slot.widget, label) self.window.widget.SetSelection(pos - 1) return slot