Beispiel #1
0
    def insert_tab(self, index, label, add_panel=True, add_sizer=False):
        # add tab/page; called from GUI
        self.properties["tabs"].insert(index, [
            label,
        ])

        # create panel and node, add to tree
        self.insert_item(None, index)  # placeholder
        if add_panel:
            if not isinstance(add_panel, compat.unicode):
                add_panel = self.next_pane_name()
            editor = panel.EditPanel(add_panel, self, index)
            if add_sizer:
                sizer = edit_sizers._builder(editor, 0)
        else:
            # just add a slot
            editor = edit_base.Slot(self, index)

        if self.widget:
            # add to widget
            editor.create()
            compat.SetToolTip(editor.widget,
                              _("Notebook page pane:\nAdd a sizer here"))
            self.vs_insert_tab(index)

            try:
                wx.CallAfter(editor.sel_marker.update)
            except AttributeError:
                #self._logger.exception(_('Internal Error'))
                if config.debugging: raise

            self.widget.SetSelection(index)

        self.properties["tabs"].update_display()
        misc.rebuild_tree(self)
Beispiel #2
0
def builder(parent, index, klass=None, base=None, name=None):
    "factory function for EditDialog objects"
    import window_dialog, edit_base, panel
    if klass is None or base is None:
        klass = 'wxDialog' if common.root.language.lower(
        ) == 'xrc' else 'MyDialog'

        dialog = window_dialog.DialogOrPanelDialog(klass)
        res = dialog.show()
        add_sizer = dialog.get_options()[0]
        button_names, button_types = dialog.get_selected_buttons()
        dialog.Destroy()
        if res is None: return
        klass, base = res
        name = 'dialog' if base == "wxDialog" else "panel"
        name = dialog.get_next_name(name)
        interactive = True
    else:
        interactive = False

    if base == "wxDialog":
        editor = EditDialog(name, parent, None, klass, name,
                            "wxDEFAULT_DIALOG_STYLE")
    else:
        editor = panel.EditTopLevelPanel(name, parent, None, klass)

    if interactive and add_sizer:
        # add a default panel and vertical sizer to the frame; optionally add buttons if it's a Dialog
        import edit_sizers, widgets.button.button
        slots = 2 if base == "wxDialog" and button_names else 1
        szr = edit_sizers._builder(editor, 0, slots=slots)
        if base == "wxDialog":
            button_szr = edit_sizers._builder(szr,
                                              1,
                                              "StdDialogButtonSizer",
                                              slots=len(button_names))
            button_szr.properties["border"].set(4)
            button_szr.properties["flag"].set("wxALL|wxALIGN_RIGHT")
            i = 0
            for button_name, button_type in zip(button_names, button_types):
                name = "button_%s" % button_name
                label = "OK" if button_name == "OK" else button_name.capitalize(
                )
                button = widgets.button.button.EditButton(
                    name, button_szr, i, label)
                button.properties["stockitem"].set(button_name, activate=True)
                if button_type == "A":
                    editor.properties["affirmative"].set(name, activate=True)
                    button.properties["default"].set(True)
                if button_type == "C":
                    editor.properties["escape"].set(name, activate=True)
                i += 1
    else:
        # just add a slot
        edit_base.Slot(editor, 0)

    editor.create()
    if base == "wxDialog":
        editor.widget.Show()
    else:
        editor.widget.GetParent().Show(
        )  # the panel is created as child of a Frame
    editor.design.update_label()
    if wx.Platform == '__WXMSW__':
        w = editor.widget.GetTopLevelParent()
        w.CenterOnScreen()
        w.Raise()

    return editor