Esempio n. 1
0
    def _insert_tab(self, index, label):
        # add tab/page
        tabs_p = self.properties["tabs"]
        tabs = tabs_p.get()  # the value will be modified in place
        tabs.insert(index, [
            label,
        ])
        tabs_p.set(tabs)
        self.children.insert(index, None)

        # adjust pos of the following pages
        for i, page in enumerate(self.children[index + 1:]):
            pos_p = page.properties["pos"]
            pos_p.set(index + 1 + i)

        # create panel and node, add to tree
        editor = EditPanel(self.next_pane_name(), 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()
        return editor
Esempio n. 2
0
    def insert_tab(self, index, label):
        # add tab/page this needs to be done before EditPanel calls self.virtual_sizer.add_item
        tabs_p = self.properties["tabs"]
        tabs = tabs_p.get()  # the value will be modified in place
        tabs.insert(index, [
            label,
        ])
        tabs_p.set(tabs)
        self.pages.insert(index, None)

        # adjust pos of the following pages
        for i, page in enumerate(self.pages[index + 1:]):
            pos_p = page.properties["pos"]
            pos_p.set(index + 2 + i)

        # create panel and node, add to tree
        pos = index + 1
        window = EditPanel(self.next_pane_name(), self, -1, self.virtual_sizer,
                           pos)
        window._dont_destroy = True
        window.node = node = Node(window)

        #common.app_tree.add(node, self.node, index)
        self.virtual_sizer.add_item(window, pos)
        common.app_tree.insert(node, self.node, index)

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

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

            self.widget.SetSelection(index)

        self.properties["tabs"].update_display()
Esempio n. 3
0
    def insert_tab(self, index, label):

        # add tab/page this needs to be done before EditPanel calls self.virtual_sizer.add_item
        tabs_p = self.properties["tabs"]
        tabs = tabs_p.get()
        tabs.insert(index, [
            label,
        ])
        tabs_p.set(tabs)
        self.pages.insert(index, None)
        # adjust pos of the following pages
        for i, page in enumerate(self.pages[index + 1:]):
            pos_p = page.properties["pos"]
            pos_p.set(index + 2 + i)

        pos = index + 1
        window = EditPanel(self.next_pane_name(suggestion=label), self, -1,
                           self.virtual_sizer, pos)
        window._dont_destroy = True
        node = Node(window)

        window.node = node
        common.app_tree.add(node, self.node)

        if self.widget:
            window.create()
            compat.SetToolTip(window.widget,
                              _("Notebook page pane:\nAdd a sizer here"))
            self.virtual_sizer.insert_tab(index)

            try:
                wx.CallAfter(window.sel_marker.update)
            except AttributeError:
                #self._logger.exception(_('Internal Error'))
                import os
                if 'WINGDB_ACTIVE' in os.environ: raise
        self.properties["tabs"].update_display()
Esempio n. 4
0
    def set_tabs(self, old_names,
                 indices):  # called from tabs proberty on Apply button
        """tabs: list of strings
        indices: the current indices of the tabs or None for a new tab; re-ordering is currently not supported"""
        keep_indices = [i for i in indices if i is not None]
        if keep_indices != sorted(keep_indices):
            raise ValueError("Re-ordering is not yet implemented")
        keep_indices = set(keep_indices)
        new_names = old_names[:]

        # set tab labels of existing pages, if modified
        for (name, ), index in zip(self.tabs, indices):
            if index is not None and old_names[index] != name:
                new_names[index] = [
                    name,
                ]
                if self.widget:
                    self.widget.SetPageText(index, name)

        # remove tabs
        for index in range(len(old_names) - 1, -1, -1):
            if not index in keep_indices:
                self._is_removing_pages = True
                self.virtual_sizer.remove_tab(
                    index)  # remove from sizer; does not delete window
                self.pages[index]._remove(
                )  # delete the page content without setting the focus
                common.app_tree.remove(
                    self.pages[index].node)  # remove from tree
                del self.pages[index]  # delete from page list
                del new_names[index]  # delete from list of names
                self._is_removing_pages = False

        # insert/add tabs
        added = None
        for i, (name, ) in enumerate(self.tabs):
            index = indices[i]
            if index is not None:
                # old tab to be kept, just ensure that pos is correct
                pos_p = self.pages[i].properties["pos"]
                if pos_p.value != i + 1: pos_p.set(i + 1)
                continue

            # actually add/insert
            new_names.insert(
                i, [
                    name,
                ]
            )  # this needs to be done before EditPanel calls self.virtual_sizer.add_item
            self.pages.insert(i, None)
            # create panel and node, add to tree
            pos = i + 1
            suggestion = "%s_%s" % (self.name, name)
            window = EditPanel(self.next_pane_name(suggestion), self, -1,
                               self.virtual_sizer, pos)
            window._dont_destroy = True
            node = window.node = Node(window)

            # adjust pos of the following pages
            for p, page in enumerate(self.pages[i + 1:]):
                pos_p = page.properties["pos"]
                pos_p.set(i + 2 + p)

            self.virtual_sizer.add_item(window, pos)
            common.app_tree.insert(node, self.node, i, select=False)

            if self.widget:
                # add to widget
                window.create()
                compat.SetToolTip(window.widget,
                                  _("Notebook page pane:\nAdd a sizer here"))
                self.virtual_sizer.insert_tab(i)

                try:
                    wx.CallAfter(window.sel_marker.update)
                except AttributeError:
                    if config.debugging: raise

                added = i  # remember last added index for selection

        # select the last added tab
        if added is not None and self.widget:
            self.widget.SetSelection(added)

        # update tree labels
        for node in self.node.children:
            node.refresh(refresh_label=True, refresh_image=False)
Esempio n. 5
0
    def set_tabs(self, old_names, indices):
        """tabs: list of strings
        indices: the current indices of the tabs or None for a new tab; re-ordering is currently not supported"""
        keep_indices = [i for i in indices if i is not None]
        if keep_indices != sorted(keep_indices):
            raise ValueError("Re-ordering is not yet implemented")
        keep_indices = set(keep_indices)
        new_names = old_names[:]

        # set tab labels of existing pages, if modified
        for (name, ), index in zip(self.tabs, indices):
            if index is not None and old_names[index] != name:
                new_names[index] = [
                    name,
                ]
                if self.widget:
                    self.widget.SetPageText(index, name)

        # remove tabs
        for index in range(len(old_names) - 1, -1, -1):
            if not index in keep_indices:
                self._is_removing_pages = True
                self.virtual_sizer.remove_tab(
                    index)  # remove from sizer; does not delete window
                self.pages[index].remove(False)  # delete the page content
                del self.pages[index]  # delete from page list
                del new_names[index]  # delete from list of names
                self._is_removing_pages = False

        # insert/add tabs
        added = None
        for i, (name, ) in enumerate(self.tabs):
            index = indices[i]
            if index is not None: continue  # old tab to be kept

            # actually add/insert
            new_names.insert(
                i, [
                    name,
                ]
            )  # this needs to be done before EditPanel calls self.virtual_sizer.add_item
            self.pages.insert(i, None)
            # create panel and node, add to tree
            pos = i + 1
            window = EditPanel(self.next_pane_name(name), self, -1,
                               self.virtual_sizer, pos)
            window._dont_destroy = True
            node = window.node = Node(window)

            # adjust pos of the following pages
            for p, page in enumerate(self.pages[i + 1:]):
                pos_p = page.properties["pos"]
                pos_p.set(i + 2 + p)

            self.virtual_sizer.add_item(window, pos)
            common.app_tree.insert(node, self.node, i)
            # add to widget
            if self.widget:
                window.create()
                compat.SetToolTip(window.widget,
                                  _("Notebook page pane:\nAdd a sizer here"))
                self.virtual_sizer.insert_tab(i)

                try:
                    wx.CallAfter(window.sel_marker.update)
                except AttributeError:
                    import os
                    if 'WINGDB_ACTIVE' in os.environ: raise

                added = i  # remember last added index for selection

        # select the last added tab
        if added is not None and self.widget:
            self.widget.SetSelection(added)
Esempio n. 6
0
    def set_tabs(self, old_labels,
                 indices):  # called from tabs proberty on Apply button
        """tabs: list of strings
        indices: the current indices of the tabs or None for a new tab; re-ordering is currently not supported"""
        keep_indices = [pos for pos in indices if pos is not None]
        if keep_indices != sorted(keep_indices):
            raise ValueError("Re-ordering is not yet implemented")
        keep_indices = set(keep_indices)
        new_labels = old_labels[:]

        # set tab labels of existing pages, if modified
        for (label, ), index in zip(self.tabs, indices):
            if index is not None and old_labels[index] != label:
                new_labels[index] = [
                    label,
                ]
                if self.widget:
                    self.widget.SetPageText(index, label)

        # remove tabs
        for index in range(len(old_labels) - 1, -1, -1):
            if not index in keep_indices:
                self._is_removing_pages = True
                self.children[index].recursive_remove()
                if self.widget:
                    self.widget.RemovePage(index)  # deletes the specified page
                del new_labels[index]  # delete from list of names
                self._is_removing_pages = False

        # insert/add tabs
        added = None
        for pos, (label, ) in enumerate(self.tabs):
            index = indices[pos]
            if index is not None:
                # old tab to be kept, just ensure that pos is correct
                pos_p = self.children[pos].properties["pos"]
                if pos_p.value != pos: pos_p.set(pos)
                continue

            # actually add/insert
            new_labels.insert(
                pos, [
                    label,
                ]
            )  # this needs to be done before EditPanel calls self.virtual_sizer.add_item
            self.children.insert(pos, None)
            # create panel and node, add to tree
            suggestion = "%s_%s" % (self.name, label)
            editor = EditPanel(self.next_pane_name(suggestion), self, pos)

            # adjust pos of the following pages
            for p, page in enumerate(self.children[pos + 1:]):
                pos_p = page.properties["pos"]
                pos_p.set(pos + 2 + p)

            if self.widget:
                # add to widget
                editor.create()
                self.vs_insert_tab(pos)

                try:
                    wx.CallAfter(editor.sel_marker.update)
                except AttributeError:
                    if config.debugging: raise

                added = pos  # remember last added index for selection

        # select the last added tab
        if added is not None and self.widget:
            self.widget.SetSelection(added)

        common.app_tree.build(self, recursive=False)