Exemple #1
0
    def menu_root(self):
        """The right click root menu."""

        # Init the item list.
        items = []

        # The menu.
        menu = wx.Menu()

        # Add some menu items for the spin user functions.
        items.append(build_menu_item(menu, id=MENU_ROOT_MOLECULE_CREATE, text="&Add a molecule", icon=fetch_icon("oxygen.actions.list-add-relax-blue")))
        items.append(build_menu_item(menu, id=MENU_ROOT_LOAD_SPINS, text="&Load spins", icon=fetch_icon("relax.spin", "16x16")))

        # Add the items and activate them.
        for item in items:
            menu.AppendItem(item)
            if status.exec_lock.locked():
                item.Enable(False)

        # The menu actions.
        self.Bind(wx.EVT_MENU, self.action_root_molecule_create, id=MENU_ROOT_MOLECULE_CREATE)
        self.Bind(wx.EVT_MENU, self.gui.spin_viewer.load_spins_wizard, id=MENU_ROOT_LOAD_SPINS)

        # Show the menu.
        if status.show_gui:
            self.PopupMenu(menu)

        # Cleanup.
        menu.Destroy()
Exemple #2
0
    def menu_root(self):
        """The right click root menu."""

        # Init the item list.
        items = []

        # The menu.
        menu = wx.Menu()

        # Add some menu items for the spin user functions.
        items.append(build_menu_item(menu, id=MENU_ROOT_MOLECULE_CREATE, text="&Add a molecule", icon=fetch_icon("oxygen.actions.list-add-relax-blue")))
        items.append(build_menu_item(menu, id=MENU_ROOT_LOAD_SPINS, text="&Load spins", icon=fetch_icon("relax.spin", "16x16")))

        # Add the items and activate them.
        for item in items:
            menu.AppendItem(item)
            if status.exec_lock.locked():
                item.Enable(False)

        # The menu actions.
        self.Bind(wx.EVT_MENU, self.action_root_molecule_create, id=MENU_ROOT_MOLECULE_CREATE)
        self.Bind(wx.EVT_MENU, self.gui.spin_viewer.load_spins_wizard, id=MENU_ROOT_LOAD_SPINS)

        # Show the menu.
        if status.show_gui:
            self.PopupMenu(menu)

        # Cleanup.
        menu.Destroy()
Exemple #3
0
    def _create_menu(self, menu, entries):
        """Build the menu."""

        # Loop over the menu entries.
        for item in entries:
            # Build the menu entry.
            menu_item = build_menu_item(menu, id=item[0], text=item[1], icon=item[2])

            # A sub-menu.
            if len(item[4]):
                # The sub-menu.
                sub_menu = wx.Menu()

                # Loop over the sub-menus.
                for sub_item in item[4]:
                    # Build the menu entry.
                    sub_menu_item = build_menu_item(sub_menu, id=sub_item[0], text=sub_item[1], icon=sub_item[2])
                    sub_menu.AppendItem(sub_menu_item)

                    # The menu actions.
                    self.gui.Bind(wx.EVT_MENU, sub_item[3], id=sub_item[0])

                # Append the sub-menu.
                menu_item.SetSubMenu(sub_menu)

            # A normal menu item.
            else:
                # The menu actions.
                self.gui.Bind(wx.EVT_MENU, item[3], id=item[0])

            # Append the menu item.
            menu.AppendItem(menu_item)
Exemple #4
0
    def on_right_click(self, event):
        """Pop up menu for the right click.

        @param event:   The wx event.
        @type event:    wx event
        """

        # Obtain the position.
        pos = event.GetPosition()

        # Hack to allow the test suite to pass.
        wx.Yield()

        # Find the item clicked on.
        item, flags = self.element.HitTest(pos)

        # Get the ID string (handling wxPython 2.9 ListCtrl.HitTest() bugs).
        id = None
        if item != -1:
            id = self.element.GetItemText(item)

        # Get the menu.
        popup_menus = self.generate_popup_menu(id=id)

        # No popup menus defined.
        if popup_menus == []:
            return

        # Execution lock, so do nothing.
        if status.exec_lock.locked():
            return

        # Initialise the menu.
        menu = wx.Menu()

        # Loop over the menu items.
        for i in range(len(popup_menus)):
            # Alias.
            info = popup_menus[i]

            # Add the menu item.
            build_menu_item(menu, id=info['id'], text=info['text'], icon=info['icon'])

            # Bind clicks.
            self.element.Bind(wx.EVT_MENU, info['method'], id=info['id'])

        # Pop up the menu.
        if status.show_gui:
            self.element.PopupMenu(menu)

        # Cleanup.
        menu.Destroy()
    def menu(self, event):
        """The pop up menu.

        @param event:   The wx event.
        @type event:    wx event
        """

        # Get the row.
        row = event.GetRow()

        # Get the name of the data pipe.
        self.selected_pipe = gui_to_str(self.grid.GetCellValue(row, 0))

        # No data pipe.
        if not self.selected_pipe:
            return

        # The pipe type and bundle.
        pipe_type = get_type(self.selected_pipe)
        pipe_bundle = get_bundle(self.selected_pipe)

        # Initialise the menu.
        menu = wx.Menu()
        items = []

        # Menu entry:  add the data pipe to a bundle.
        if not pipe_bundle:
            items.append(build_menu_item(menu, parent=self, text="&Add the pipe to a bundle", icon=fetch_icon("relax.pipe_bundle"), fn=self.pipe_bundle))

        # Menu entry:  delete the data pipe.
        items.append(build_menu_item(menu, parent=self, text="&Delete the pipe", icon=fetch_icon('oxygen.actions.list-remove', "16x16"), fn=self.pipe_delete))
 
        # Menu entry:  switch to this data pipe.
        items.append(build_menu_item(menu, parent=self, text="&Switch to this pipe", icon=fetch_icon('oxygen.actions.system-switch-user', "16x16"), fn=self.pipe_switch))
 
        # Menu entry:  new auto-analysis tab.
        if pipe_bundle and self.gui.analysis.page_index_from_bundle(pipe_bundle) == None and pipe_type in ['noe', 'r1', 'r2', 'mf', 'relax_disp']:
            items.append(build_menu_item(menu, parent=self, text="&Associate with a new auto-analysis", icon=fetch_icon('oxygen.actions.document-new', "16x16"), fn=self.associate_auto))
 
        # Set up the entries.
        for item in items:
            menu.AppendItem(item)
            if status.exec_lock.locked():
                item.Enable(False)

        # Show the menu.
        if status.show_gui:
            self.PopupMenu(menu)

        # Kill the menu once done.
        menu.Destroy()
    def pop_up_menu(self, event):
        """Override the StyledTextCtrl pop up menu.

        @param event:   The wx event.
        @type event:    wx event
        """

        # Create the menu.
        menu = wx.Menu()

        # Add the entries.
        menu.AppendItem(build_menu_item(menu, id=self.menu_id_find, text="&Find", icon=fetch_icon('oxygen.actions.edit-find', "16x16")))
        menu.AppendSeparator()
        menu.AppendItem(build_menu_item(menu, id=self.menu_id_copy, text="&Copy", icon=fetch_icon('oxygen.actions.edit-copy', "16x16")))
        menu.AppendItem(build_menu_item(menu, id=self.menu_id_select_all, text="&Select all", icon=fetch_icon('oxygen.actions.edit-select-all', "16x16")))
        menu.AppendSeparator()
        menu.AppendItem(build_menu_item(menu, id=self.menu_id_zoom_in, text="Zoom &in", icon=fetch_icon('oxygen.actions.zoom-in', "16x16")))
        menu.AppendItem(build_menu_item(menu, id=self.menu_id_zoom_out, text="Zoom &out", icon=fetch_icon('oxygen.actions.zoom-out', "16x16")))
        menu.AppendItem(build_menu_item(menu, id=self.menu_id_zoom_orig, text="Original &zoom", icon=fetch_icon('oxygen.actions.zoom-original', "16x16")))
        menu.AppendSeparator()
        menu.AppendItem(build_menu_item(menu, id=self.menu_id_goto_start, text="&Go to start", icon=fetch_icon('oxygen.actions.go-top', "16x16")))
        menu.AppendItem(build_menu_item(menu, id=self.menu_id_goto_end, text="&Go to end", icon=fetch_icon('oxygen.actions.go-bottom', "16x16")))

        # Pop up the menu.
        if status.show_gui:
            self.PopupMenu(menu)
            menu.Destroy()
Exemple #7
0
    def menu_default(self):
        """The right click root menu."""

        # The menu.
        menu = wx.Menu()

        # The load spins entry.
        item = build_menu_item(menu,
                               id=MENU_ROOT_LOAD_SPINS,
                               text="Load spins",
                               icon=fetch_icon("relax.spin", "16x16"))
        if status.exec_lock.locked():
            item.Enable(False)

        # The menu actions.
        self.Bind(wx.EVT_MENU,
                  self.gui.spin_viewer.load_spins_wizard,
                  id=MENU_ROOT_LOAD_SPINS)

        # Show the menu.
        if status.show_gui:
            self.PopupMenu(menu)

        # Cleanup.
        menu.Destroy()
Exemple #8
0
    def menu_residue(self):
        """The right click molecule menu."""

        # Init the item list.
        items = []

        # The menu.
        menu = wx.Menu()

        # Add some menu items for the spin user functions.
        items.append(build_menu_item(menu, id=MENU_RESIDUE_RESIDUE_COPY, text="&Copy the residue", icon=fetch_icon("oxygen.actions.list-add")))
        items.append(build_menu_item(menu, id=MENU_RESIDUE_RESIDUE_DELETE, text="De&lete the residue", icon=fetch_icon("oxygen.actions.list-remove")))
        items.append(build_menu_item(menu, id=MENU_RESIDUE_RESIDUE_NAME, text="&Name the residue", icon=fetch_icon("oxygen.actions.edit-rename")))
        items.append(build_menu_item(menu, id=MENU_RESIDUE_RESIDUE_NUMBER, text="N&umber the residue", icon=fetch_icon("oxygen.actions.edit-rename")))
        items.append(build_menu_item(menu, id=MENU_RESIDUE_SPIN_ADD, text="&Add a spin", icon=fetch_icon("oxygen.actions.list-add-relax-blue")))
        items.append(build_menu_item(menu, id=MENU_RESIDUE_SPIN_CREATE_PSEUDO, text="Create a &pseudo-atom", icon=fetch_icon("oxygen.actions.list-add-relax-blue")))

        # Add the items and activate them.
        for item in items:
            menu.AppendItem(item)
            if status.exec_lock.locked():
                item.Enable(False)

        # Add a separator.
        menu.AppendSeparator()

        # Selection or deselection.
        if self.info['select']:
            item = build_menu_item(menu, id=MENU_RESIDUE_RESIDUE_DESELECT, text="&Deselect", icon=fetch_icon("relax.residue_grey"))
        else:
            item = build_menu_item(menu, id=MENU_RESIDUE_RESIDUE_SELECT, text="&Select", icon=fetch_icon("relax.residue"))
        menu.AppendItem(item)
        if status.exec_lock.locked():
            item.Enable(False)

        # The menu actions.
        self.Bind(wx.EVT_MENU, self.action_residue_residue_copy, id=MENU_RESIDUE_RESIDUE_COPY)
        self.Bind(wx.EVT_MENU, self.action_residue_residue_delete, id=MENU_RESIDUE_RESIDUE_DELETE)
        self.Bind(wx.EVT_MENU, self.action_residue_residue_name, id=MENU_RESIDUE_RESIDUE_NAME)
        self.Bind(wx.EVT_MENU, self.action_residue_residue_number, id=MENU_RESIDUE_RESIDUE_NUMBER)
        self.Bind(wx.EVT_MENU, self.action_residue_spin_add, id=MENU_RESIDUE_SPIN_ADD)
        self.Bind(wx.EVT_MENU, self.action_residue_spin_create_pseudo, id=MENU_RESIDUE_SPIN_CREATE_PSEUDO)
        if self.info['select']:
            self.Bind(wx.EVT_MENU, self.action_residue_residue_deselect, id=MENU_RESIDUE_RESIDUE_DESELECT)
        else:
            self.Bind(wx.EVT_MENU, self.action_residue_residue_select, id=MENU_RESIDUE_RESIDUE_SELECT)

        # Show the menu.
        if status.show_gui:
            self.PopupMenu(menu)

        # Cleanup.
        menu.Destroy()
Exemple #9
0
    def menu_residue(self):
        """The right click molecule menu."""

        # Init the item list.
        items = []

        # The menu.
        menu = wx.Menu()

        # Add some menu items for the spin user functions.
        items.append(build_menu_item(menu, id=MENU_RESIDUE_RESIDUE_COPY, text="&Copy the residue", icon=fetch_icon("oxygen.actions.list-add")))
        items.append(build_menu_item(menu, id=MENU_RESIDUE_RESIDUE_DELETE, text="De&lete the residue", icon=fetch_icon("oxygen.actions.list-remove")))
        items.append(build_menu_item(menu, id=MENU_RESIDUE_RESIDUE_NAME, text="&Name the residue", icon=fetch_icon("oxygen.actions.edit-rename")))
        items.append(build_menu_item(menu, id=MENU_RESIDUE_RESIDUE_NUMBER, text="N&umber the residue", icon=fetch_icon("oxygen.actions.edit-rename")))
        items.append(build_menu_item(menu, id=MENU_RESIDUE_SPIN_ADD, text="&Add a spin", icon=fetch_icon("oxygen.actions.list-add-relax-blue")))
        items.append(build_menu_item(menu, id=MENU_RESIDUE_SPIN_CREATE_PSEUDO, text="Create a &pseudo-atom", icon=fetch_icon("oxygen.actions.list-add-relax-blue")))

        # Add the items and activate them.
        for item in items:
            menu.AppendItem(item)
            if status.exec_lock.locked():
                item.Enable(False)

        # Add a separator.
        menu.AppendSeparator()

        # Selection or deselection.
        if self.info['select']:
            item = build_menu_item(menu, id=MENU_RESIDUE_RESIDUE_DESELECT, text="&Deselect", icon=fetch_icon("relax.residue_grey"))
        else:
            item = build_menu_item(menu, id=MENU_RESIDUE_RESIDUE_SELECT, text="&Select", icon=fetch_icon("relax.residue"))
        menu.AppendItem(item)
        if status.exec_lock.locked():
            item.Enable(False)

        # The menu actions.
        self.Bind(wx.EVT_MENU, self.action_residue_residue_copy, id=MENU_RESIDUE_RESIDUE_COPY)
        self.Bind(wx.EVT_MENU, self.action_residue_residue_delete, id=MENU_RESIDUE_RESIDUE_DELETE)
        self.Bind(wx.EVT_MENU, self.action_residue_residue_name, id=MENU_RESIDUE_RESIDUE_NAME)
        self.Bind(wx.EVT_MENU, self.action_residue_residue_number, id=MENU_RESIDUE_RESIDUE_NUMBER)
        self.Bind(wx.EVT_MENU, self.action_residue_spin_add, id=MENU_RESIDUE_SPIN_ADD)
        self.Bind(wx.EVT_MENU, self.action_residue_spin_create_pseudo, id=MENU_RESIDUE_SPIN_CREATE_PSEUDO)
        if self.info['select']:
            self.Bind(wx.EVT_MENU, self.action_residue_residue_deselect, id=MENU_RESIDUE_RESIDUE_DESELECT)
        else:
            self.Bind(wx.EVT_MENU, self.action_residue_residue_select, id=MENU_RESIDUE_RESIDUE_SELECT)

        # Show the menu.
        if status.show_gui:
            self.PopupMenu(menu)

        # Cleanup.
        menu.Destroy()
Exemple #10
0
    def _create_menu(self, menu, entries):
        """Build the menu."""

        # Loop over the menu entries.
        for item in entries:
            # Build the menu entry.
            menu_item = build_menu_item(menu,
                                        id=item[0],
                                        text=item[1],
                                        icon=item[2],
                                        append=False)

            # A sub-menu.
            if len(item[4]):
                # The sub-menu.
                sub_menu = wx.Menu()

                # Loop over the sub-menus.
                for sub_item in item[4]:
                    # Build the menu entry.
                    sub_menu_item = build_menu_item(sub_menu,
                                                    id=sub_item[0],
                                                    text=sub_item[1],
                                                    icon=sub_item[2])

                    # The menu actions.
                    self.gui.Bind(wx.EVT_MENU, sub_item[3], id=sub_item[0])

                # Append the sub-menu.
                menu_item.SetSubMenu(sub_menu)

            # A normal menu item.
            else:
                # The menu actions.
                self.gui.Bind(wx.EVT_MENU, item[3], id=item[0])

            # Append the menu item.
            if dep_check.wx_classic:
                menu.AppendItem(menu_item)
            else:
                menu.Append(menu_item)
Exemple #11
0
    def on_right_click(self, event):
        """Pop up menu for the right click.

        @param event:   The wx event.
        @type event:    wx event
        """

        # Obtain the position.
        pos = event.GetPosition()

        # Hack to allow the test suite to pass.
        wx.Yield()

        # Find the item clicked on.
        item, flags = self.element.HitTest(pos)

        # Get the ID string (handling wxPython 2.9 ListCtrl.HitTest() bugs).
        id = None
        if item != -1:
            id = self.element.GetItemText(item)

        # Get the menu.
        popup_menus = self.generate_popup_menu(id=id)

        # No popup menus defined.
        if popup_menus == []:
            return

        # Execution lock, so do nothing.
        if status.exec_lock.locked():
            return

        # Initialise the menu.
        menu = wx.Menu()

        # Loop over the menu items.
        for i in range(len(popup_menus)):
            # Alias.
            info = popup_menus[i]

            # Add the menu item.
            menu.AppendItem(build_menu_item(menu, id=info["id"], text=info["text"], icon=info["icon"]))

            # Bind clicks.
            self.element.Bind(wx.EVT_MENU, info["method"], id=info["id"])

        # Pop up the menu.
        if status.show_gui:
            self.element.PopupMenu(menu)

        # Cleanup.
        menu.Destroy()
Exemple #12
0
    def menu_spin(self):
        """The right click spin menu."""

        # Init the item list.
        items = []

        # The menu.
        menu = wx.Menu()

        # Add some menu items for the spin user functions.
        items.append(build_menu_item(menu, id=MENU_SPIN_SPIN_COPY, text="&Copy the spin", icon=fetch_icon("oxygen.actions.list-add")))
        items.append(build_menu_item(menu, id=MENU_SPIN_SPIN_DELETE, text="De&lete the spin", icon=fetch_icon("oxygen.actions.list-remove")))
        items.append(build_menu_item(menu, id=MENU_SPIN_SPIN_ELEMENT, text="Set the element &type of the spin", icon=fetch_icon("oxygen.actions.edit-rename")))
        items.append(build_menu_item(menu, id=MENU_SPIN_SPIN_NAME, text="&Name the spin", icon=fetch_icon("oxygen.actions.edit-rename")))
        items.append(build_menu_item(menu, id=MENU_SPIN_SPIN_NUMBER, text="N&umber the spin", icon=fetch_icon("oxygen.actions.edit-rename")))

        # Add the items and activate them.
        for item in items:
            menu.AppendItem(item)
            if status.exec_lock.locked():
                item.Enable(False)

        # Add a separator.
        menu.AppendSeparator()

        # Selection or deselection.
        if self.info['select']:
            item = build_menu_item(menu, id=MENU_SPIN_SPIN_DESELECT, text="&Deselect", icon=fetch_icon("relax.spin_grey"))
        else:
            item = build_menu_item(menu, id=MENU_SPIN_SPIN_SELECT, text="&Select", icon=fetch_icon("relax.spin"))
        menu.AppendItem(item)
        if status.exec_lock.locked():
            item.Enable(False)

        # The menu actions.
        self.Bind(wx.EVT_MENU, self.action_spin_spin_copy, id=MENU_SPIN_SPIN_COPY)
        self.Bind(wx.EVT_MENU, self.action_spin_spin_delete, id=MENU_SPIN_SPIN_DELETE)
        self.Bind(wx.EVT_MENU, self.action_spin_spin_element, id=MENU_SPIN_SPIN_ELEMENT)
        self.Bind(wx.EVT_MENU, self.action_spin_spin_name, id=MENU_SPIN_SPIN_NAME)
        self.Bind(wx.EVT_MENU, self.action_spin_spin_number, id=MENU_SPIN_SPIN_NUMBER)
        if self.info['select']:
            self.Bind(wx.EVT_MENU, self.action_spin_spin_deselect, id=MENU_SPIN_SPIN_DESELECT)
        else:
            self.Bind(wx.EVT_MENU, self.action_spin_spin_select, id=MENU_SPIN_SPIN_SELECT)

        # Show the menu.
        if status.show_gui:
            self.PopupMenu(menu)

        # Cleanup.
        menu.Destroy()
Exemple #13
0
    def menu_spin(self):
        """The right click spin menu."""

        # Init the item list.
        items = []

        # The menu.
        menu = wx.Menu()

        # Add some menu items for the spin user functions.
        items.append(build_menu_item(menu, id=MENU_SPIN_SPIN_COPY, text="&Copy the spin", icon=fetch_icon("oxygen.actions.list-add")))
        items.append(build_menu_item(menu, id=MENU_SPIN_SPIN_DELETE, text="De&lete the spin", icon=fetch_icon("oxygen.actions.list-remove")))
        items.append(build_menu_item(menu, id=MENU_SPIN_SPIN_ELEMENT, text="Set the element &type of the spin", icon=fetch_icon("oxygen.actions.edit-rename")))
        items.append(build_menu_item(menu, id=MENU_SPIN_SPIN_NAME, text="&Name the spin", icon=fetch_icon("oxygen.actions.edit-rename")))
        items.append(build_menu_item(menu, id=MENU_SPIN_SPIN_NUMBER, text="N&umber the spin", icon=fetch_icon("oxygen.actions.edit-rename")))

        # Add the items and activate them.
        for item in items:
            menu.AppendItem(item)
            if status.exec_lock.locked():
                item.Enable(False)

        # Add a separator.
        menu.AppendSeparator()

        # Selection or deselection.
        if self.info['select']:
            item = build_menu_item(menu, id=MENU_SPIN_SPIN_DESELECT, text="&Deselect", icon=fetch_icon("relax.spin_grey"))
        else:
            item = build_menu_item(menu, id=MENU_SPIN_SPIN_SELECT, text="&Select", icon=fetch_icon("relax.spin"))
        menu.AppendItem(item)
        if status.exec_lock.locked():
            item.Enable(False)

        # The menu actions.
        self.Bind(wx.EVT_MENU, self.action_spin_spin_copy, id=MENU_SPIN_SPIN_COPY)
        self.Bind(wx.EVT_MENU, self.action_spin_spin_delete, id=MENU_SPIN_SPIN_DELETE)
        self.Bind(wx.EVT_MENU, self.action_spin_spin_element, id=MENU_SPIN_SPIN_ELEMENT)
        self.Bind(wx.EVT_MENU, self.action_spin_spin_name, id=MENU_SPIN_SPIN_NAME)
        self.Bind(wx.EVT_MENU, self.action_spin_spin_number, id=MENU_SPIN_SPIN_NUMBER)
        if self.info['select']:
            self.Bind(wx.EVT_MENU, self.action_spin_spin_deselect, id=MENU_SPIN_SPIN_DESELECT)
        else:
            self.Bind(wx.EVT_MENU, self.action_spin_spin_select, id=MENU_SPIN_SPIN_SELECT)

        # Show the menu.
        if status.show_gui:
            self.PopupMenu(menu)

        # Cleanup.
        menu.Destroy()
Exemple #14
0
    def menu_molecule(self):
        """The right click molecule menu."""

        # Init the item list.
        items = []

        # The menu.
        menu = wx.Menu()

        # Add some menu items for the spin user functions.
        items.append(build_menu_item(menu, id=self.MENU_MOLECULE_MOLECULE_COPY, text="&Copy the molecule", icon=fetch_icon("oxygen.actions.list-add")))
        items.append(build_menu_item(menu, id=self.MENU_MOLECULE_MOLECULE_DELETE, text="De&lete the molecule", icon=fetch_icon("oxygen.actions.list-remove")))
        items.append(build_menu_item(menu, id=self.MENU_MOLECULE_MOLECULE_NAME, text="&Name the molecule", icon=fetch_icon("oxygen.actions.edit-rename")))
        items.append(build_menu_item(menu, id=self.MENU_MOLECULE_MOLECULE_TYPE, text="Set the molecule &type", icon=fetch_icon("oxygen.actions.edit-rename")))
        items.append(build_menu_item(menu, id=self.MENU_MOLECULE_RESIDUE_CREATE, text="Add a &residue", icon=fetch_icon("oxygen.actions.list-add-relax-blue")))

        # Add the items and activate them.
        for item in items:
            menu.AppendItem(item)
            if status.exec_lock.locked():
                item.Enable(False)

        # Add a separator.
        menu.AppendSeparator()

        # Selection or deselection.
        if self.info['select']:
            item = build_menu_item(menu, id=self.MENU_MOLECULE_MOLECULE_DESELECT, text="&Deselect", icon=fetch_icon("relax.molecule_grey"))
        else:
            item = build_menu_item(menu, id=self.MENU_MOLECULE_MOLECULE_SELECT, text="&Select", icon=fetch_icon("relax.molecule"))
        menu.AppendItem(item)
        if status.exec_lock.locked():
            item.Enable(False)

        # The menu actions.
        self.Bind(wx.EVT_MENU, self.action_molecule_molecule_copy, id=self.MENU_MOLECULE_MOLECULE_COPY)
        self.Bind(wx.EVT_MENU, self.action_molecule_molecule_delete, id=self.MENU_MOLECULE_MOLECULE_DELETE)
        self.Bind(wx.EVT_MENU, self.action_molecule_molecule_name, id=self.MENU_MOLECULE_MOLECULE_NAME)
        self.Bind(wx.EVT_MENU, self.action_molecule_molecule_type, id=self.MENU_MOLECULE_MOLECULE_TYPE)
        self.Bind(wx.EVT_MENU, self.action_molecule_residue_create, id=self.MENU_MOLECULE_RESIDUE_CREATE)
        if self.info['select']:
            self.Bind(wx.EVT_MENU, self.action_molecule_molecule_deselect, id=self.MENU_MOLECULE_MOLECULE_DESELECT)
        else:
            self.Bind(wx.EVT_MENU, self.action_molecule_molecule_select, id=self.MENU_MOLECULE_MOLECULE_SELECT)

        # Show the menu.
        if status.show_gui:
            self.PopupMenu(menu)
            menu.Destroy()
Exemple #15
0
    def menu_default(self):
        """The right click root menu."""

        # The menu.
        menu = wx.Menu()

        # The load spins entry.
        item = build_menu_item(menu, id=self.MENU_ROOT_LOAD_SPINS, text="Load spins", icon=fetch_icon("relax.spin", "16x16"))
        menu.AppendItem(item)
        if status.exec_lock.locked():
            item.Enable(False)

        # The menu actions.
        self.Bind(wx.EVT_MENU, self.gui.spin_viewer.load_spins_wizard, id=self.MENU_ROOT_LOAD_SPINS)

        # Show the menu.
        if status.show_gui:
            self.PopupMenu(menu)
            menu.Destroy()
Exemple #16
0
    def menu_molecule(self):
        """The right click molecule menu."""

        # Init the item list.
        items = []

        # The menu.
        menu = wx.Menu()

        # Add some menu items for the spin user functions.
        items.append(
            build_menu_item(menu,
                            id=MENU_MOLECULE_MOLECULE_COPY,
                            text="&Copy the molecule",
                            icon=fetch_icon("oxygen.actions.list-add")))
        items.append(
            build_menu_item(menu,
                            id=MENU_MOLECULE_MOLECULE_DELETE,
                            text="De&lete the molecule",
                            icon=fetch_icon("oxygen.actions.list-remove")))
        items.append(
            build_menu_item(menu,
                            id=MENU_MOLECULE_MOLECULE_NAME,
                            text="&Name the molecule",
                            icon=fetch_icon("oxygen.actions.edit-rename")))
        items.append(
            build_menu_item(menu,
                            id=MENU_MOLECULE_MOLECULE_TYPE,
                            text="Set the molecule &type",
                            icon=fetch_icon("oxygen.actions.edit-rename")))
        items.append(
            build_menu_item(
                menu,
                id=MENU_MOLECULE_RESIDUE_CREATE,
                text="Add a &residue",
                icon=fetch_icon("oxygen.actions.list-add-relax-blue")))

        # Add the items and activate them.
        for item in items:
            if status.exec_lock.locked():
                item.Enable(False)

        # Add a separator.
        menu.AppendSeparator()

        # Selection or deselection.
        if self.info['select']:
            item = build_menu_item(menu,
                                   id=MENU_MOLECULE_MOLECULE_DESELECT,
                                   text="&Deselect",
                                   icon=fetch_icon("relax.molecule_grey"))
        else:
            item = build_menu_item(menu,
                                   id=MENU_MOLECULE_MOLECULE_SELECT,
                                   text="&Select",
                                   icon=fetch_icon("relax.molecule"))
        if status.exec_lock.locked():
            item.Enable(False)

        # The menu actions.
        self.Bind(wx.EVT_MENU,
                  self.action_molecule_molecule_copy,
                  id=MENU_MOLECULE_MOLECULE_COPY)
        self.Bind(wx.EVT_MENU,
                  self.action_molecule_molecule_delete,
                  id=MENU_MOLECULE_MOLECULE_DELETE)
        self.Bind(wx.EVT_MENU,
                  self.action_molecule_molecule_name,
                  id=MENU_MOLECULE_MOLECULE_NAME)
        self.Bind(wx.EVT_MENU,
                  self.action_molecule_molecule_type,
                  id=MENU_MOLECULE_MOLECULE_TYPE)
        self.Bind(wx.EVT_MENU,
                  self.action_molecule_residue_create,
                  id=MENU_MOLECULE_RESIDUE_CREATE)
        if self.info['select']:
            self.Bind(wx.EVT_MENU,
                      self.action_molecule_molecule_deselect,
                      id=MENU_MOLECULE_MOLECULE_DESELECT)
        else:
            self.Bind(wx.EVT_MENU,
                      self.action_molecule_molecule_select,
                      id=MENU_MOLECULE_MOLECULE_SELECT)

        # Show the menu.
        if status.show_gui:
            self.PopupMenu(menu)

        # Cleanup.
        menu.Destroy()
Exemple #17
0
    def pop_up_menu(self, event):
        """Override the StyledTextCtrl pop up menu.

        @param event:   The wx event.
        @type event:    wx event
        """

        # Create the menu.
        menu = wx.Menu()

        # Add the entries.
        build_menu_item(menu,
                        id=MENU_ID_FIND,
                        text="&Find",
                        icon=fetch_icon('oxygen.actions.edit-find', "16x16"))
        menu.AppendSeparator()
        build_menu_item(menu,
                        id=MENU_ID_COPY,
                        text="&Copy",
                        icon=fetch_icon('oxygen.actions.edit-copy', "16x16"))
        build_menu_item(menu,
                        id=MENU_ID_SELECT_ALL,
                        text="&Select all",
                        icon=fetch_icon('oxygen.actions.edit-select-all',
                                        "16x16"))
        menu.AppendSeparator()
        build_menu_item(menu,
                        id=MENU_ID_ZOOM_IN,
                        text="Zoom &in",
                        icon=fetch_icon('oxygen.actions.zoom-in', "16x16"))
        build_menu_item(menu,
                        id=MENU_ID_ZOOM_OUT,
                        text="Zoom &out",
                        icon=fetch_icon('oxygen.actions.zoom-out', "16x16"))
        build_menu_item(menu,
                        id=MENU_ID_ZOOM_ORIG,
                        text="Original &zoom",
                        icon=fetch_icon('oxygen.actions.zoom-original',
                                        "16x16"))
        menu.AppendSeparator()
        build_menu_item(menu,
                        id=MENU_ID_GOTO_START,
                        text="&Go to start",
                        icon=fetch_icon('oxygen.actions.go-top', "16x16"))
        build_menu_item(menu,
                        id=MENU_ID_GOTO_END,
                        text="&Go to end",
                        icon=fetch_icon('oxygen.actions.go-bottom', "16x16"))

        # Pop up the menu.
        if status.show_gui:
            self.PopupMenu(menu)

        # Cleanup.
        menu.Destroy()
Exemple #18
0
    def __init__(self, gui):
        """Build the menu bar."""

        # Store the args.
        self.gui = gui

        # Create the menu bar GUI item.
        self.menubar = wx.MenuBar()

        # The 'File' menu entries.
        menu = wx.Menu()
        build_menu_item(menu,
                        id=MENU_FILE_NEW,
                        text="&New analysis\tCtrl+N",
                        icon=fetch_icon('oxygen.actions.document-new',
                                        "16x16"))
        build_menu_item(menu,
                        id=MENU_FILE_CLOSE,
                        text="&Close analysis",
                        icon=fetch_icon('oxygen.actions.document-close',
                                        "16x16"))
        build_menu_item(menu,
                        id=MENU_FILE_CLOSE_ALL,
                        text="&Close all analyses",
                        icon=fetch_icon('oxygen.actions.dialog-close',
                                        "16x16"))
        menu.AppendSeparator()
        build_menu_item(menu,
                        id=MENU_FILE_CWD,
                        text="&Change directory\tCtrl+W",
                        icon=fetch_icon('oxygen.places.folder-favorites',
                                        "16x16"))
        build_menu_item(menu,
                        id=MENU_FILE_OPEN,
                        text="&Open relax state\tCtrl+O",
                        icon=fetch_icon('oxygen.actions.document-open',
                                        "16x16"))
        build_menu_item(menu,
                        id=MENU_FILE_SAVE,
                        text="S&ave relax state\tCtrl+S",
                        icon=fetch_icon('oxygen.actions.document-save',
                                        "16x16"))
        build_menu_item(menu,
                        id=MENU_FILE_SAVE_AS,
                        text="Save as...\tCtrl+Shift+S",
                        icon=fetch_icon('oxygen.actions.document-save-as',
                                        "16x16"))
        menu.AppendSeparator()
        build_menu_item(menu,
                        id=MENU_FILE_EXPORT_BMRB,
                        text="Export for BMRB deposition",
                        icon=fetch_icon('relax.bmrb'))
        menu.AppendSeparator()
        build_menu_item(menu,
                        id=MENU_FILE_EXIT,
                        text="E&xit\tCtrl+Q",
                        icon=fetch_icon('oxygen.actions.system-shutdown',
                                        "16x16"))
        self.menubar.Append(menu, "&File")

        # The 'File' menu actions.
        self.gui.Bind(wx.EVT_MENU,
                      self.gui.analysis.menu_new,
                      id=MENU_FILE_NEW)
        self.gui.Bind(wx.EVT_MENU,
                      self.gui.analysis.menu_close,
                      id=MENU_FILE_CLOSE)
        self.gui.Bind(wx.EVT_MENU,
                      self.gui.analysis.menu_close_all,
                      id=MENU_FILE_CLOSE_ALL)
        self.gui.Bind(wx.EVT_MENU, self.gui.system_cwd, id=MENU_FILE_CWD)
        self.gui.Bind(wx.EVT_MENU, self.gui.state_load, id=MENU_FILE_OPEN)
        self.gui.Bind(wx.EVT_MENU,
                      self.gui.action_state_save,
                      id=MENU_FILE_SAVE)
        self.gui.Bind(wx.EVT_MENU,
                      self.gui.action_state_save_as,
                      id=MENU_FILE_SAVE_AS)
        self.gui.Bind(wx.EVT_MENU,
                      self.gui.action_export_bmrb,
                      id=MENU_FILE_EXPORT_BMRB)
        self.gui.Bind(wx.EVT_MENU, self.gui.exit_gui, id=MENU_FILE_EXIT)

        # The 'View' menu entries.
        menu = wx.Menu()
        build_menu_item(menu,
                        id=MENU_VIEW_CONTROLLER,
                        text="&Controller\tCtrl+Z",
                        icon=fetch_icon(
                            'oxygen.apps.preferences-system-performance',
                            "16x16"))
        build_menu_item(menu,
                        id=MENU_VIEW_SPIN_VIEW,
                        text="&Spin viewer\tCtrl+T",
                        icon=fetch_icon('relax.spin', "16x16"))
        build_menu_item(menu,
                        id=MENU_VIEW_RESULTS,
                        text="&Results viewer\tCtrl+R",
                        icon=fetch_icon('oxygen.actions.view-statistics',
                                        "16x16"))
        build_menu_item(menu,
                        id=MENU_VIEW_PIPE_EDIT,
                        text="&Data pipe editor\tCtrl+D",
                        icon=fetch_icon('relax.pipe', "16x16"))
        build_menu_item(menu,
                        id=MENU_VIEW_PROMPT,
                        text="relax &prompt\tCtrl+P",
                        icon=fetch_icon(
                            'oxygen.mimetypes.application-x-executable-script',
                            "16x16"))
        self.menubar.Append(menu, "&View")

        # The 'View' actions.
        self.gui.Bind(wx.EVT_MENU,
                      self.gui.show_controller,
                      id=MENU_VIEW_CONTROLLER)
        self.gui.Bind(wx.EVT_MENU, self.gui.show_prompt, id=MENU_VIEW_PROMPT)
        self.gui.Bind(wx.EVT_MENU, self.gui.show_tree, id=MENU_VIEW_SPIN_VIEW)
        self.gui.Bind(wx.EVT_MENU,
                      self.gui.show_results_viewer,
                      id=MENU_VIEW_RESULTS)
        self.gui.Bind(wx.EVT_MENU,
                      self.gui.show_pipe_editor,
                      id=MENU_VIEW_PIPE_EDIT)

        # The auto generated 'User functions' menu entries.
        self.menu_uf_ids = build_uf_menus(parent=self.gui,
                                          menubar=self.menubar)

        # The 'Tools' menu entries.
        menu = wx.Menu()
        build_menu_item(menu,
                        id=MENU_TOOLS_FORMAT,
                        text="&Free file format settings",
                        icon=fetch_icon('oxygen.actions.document-properties',
                                        "16x16"))
        build_menu_item(menu,
                        id=MENU_TOOLS_SYS_INFO,
                        text="System &information",
                        icon=fetch_icon('oxygen.actions.help-about', "16x16"))

        # The 'Tools->Test suite" sub-menu.
        test_suite_item = build_menu_item(
            menu,
            id=MENU_TOOLS_TEST_SUITE,
            text="&Test suite",
            icon=fetch_icon('oxygen.mimetypes.application-x-desktop', "16x16"),
            append=False)
        sub_menu = wx.Menu()
        test_suite_item.SetSubMenu(sub_menu)
        build_menu_item(sub_menu,
                        id=MENU_TOOLS_TEST_SUITE_ALL,
                        text="&Full test suite",
                        icon=fetch_icon(
                            'oxygen.mimetypes.application-x-desktop', "16x16"))
        sub_menu.AppendSeparator()
        build_menu_item(sub_menu,
                        id=MENU_TOOLS_TEST_SUITE_SYS,
                        text="&System tests",
                        icon=fetch_icon(
                            'oxygen.mimetypes.application-x-desktop', "16x16"))
        build_menu_item(sub_menu,
                        id=MENU_TOOLS_TEST_SUITE_UNIT,
                        text="&Unit tests",
                        icon=fetch_icon(
                            'oxygen.mimetypes.application-x-desktop', "16x16"))
        build_menu_item(sub_menu,
                        id=MENU_TOOLS_TEST_SUITE_GUI,
                        text="&GUI tests",
                        icon=fetch_icon(
                            'oxygen.mimetypes.application-x-desktop', "16x16"))
        build_menu_item(sub_menu,
                        id=MENU_TOOLS_TEST_SUITE_VERIFICATION,
                        text="&Verification tests",
                        icon=fetch_icon(
                            'oxygen.mimetypes.application-x-desktop', "16x16"))
        if dep_check.wx_classic:
            menu.AppendItem(test_suite_item)
        else:
            menu.Append(test_suite_item)
        self.menubar.Append(menu, "&Tools")

        # The 'Tools' menu actions.
        self.gui.Bind(wx.EVT_MENU,
                      self.gui.free_file_format_settings,
                      id=MENU_TOOLS_FORMAT)
        self.gui.Bind(wx.EVT_MENU, self._sys_info, id=MENU_TOOLS_SYS_INFO)
        self.gui.Bind(wx.EVT_MENU,
                      self.gui.run_test_suite,
                      id=MENU_TOOLS_TEST_SUITE_ALL)
        self.gui.Bind(wx.EVT_MENU,
                      self.gui.run_test_suite_sys,
                      id=MENU_TOOLS_TEST_SUITE_SYS)
        self.gui.Bind(wx.EVT_MENU,
                      self.gui.run_test_suite_unit,
                      id=MENU_TOOLS_TEST_SUITE_UNIT)
        self.gui.Bind(wx.EVT_MENU,
                      self.gui.run_test_suite_gui,
                      id=MENU_TOOLS_TEST_SUITE_GUI)
        self.gui.Bind(wx.EVT_MENU,
                      self.gui.run_test_suite_verification,
                      id=MENU_TOOLS_TEST_SUITE_VERIFICATION)

        # The 'Help' menu entries.
        menu = wx.Menu()
        build_menu_item(menu,
                        id=MENU_HELP_MANUAL,
                        text="relax user &manual\tF1",
                        icon=fetch_icon('oxygen.mimetypes.application-pdf',
                                        "16x16"))
        menu.AppendSeparator()
        build_menu_item(menu,
                        id=MENU_HELP_MAIL,
                        text="Mailing list &contact ([email protected])",
                        icon=fetch_icon('oxygen.actions.mail-mark-unread-new',
                                        "16x16"))
        build_menu_item(menu,
                        id=MENU_HELP_REFS,
                        text="&References",
                        icon=fetch_icon('oxygen.actions.flag-blue', "16x16"))
        menu.AppendSeparator()
        build_menu_item(menu,
                        id=MENU_HELP_GPL,
                        text="&Licence",
                        icon=fetch_icon('relax.gnu-head-mini', "16x16"))
        menu.AppendSeparator()
        build_menu_item(menu,
                        id=MENU_HELP_ABOUT,
                        text="About rela&x",
                        icon=fetch_icon("relax.relax"))
        self.menubar.Append(menu, "&Help")

        # The 'Help' menu actions.
        self.gui.Bind(wx.EVT_MENU, self.gui.relax_manual, id=MENU_HELP_MANUAL)
        self.gui.Bind(wx.EVT_MENU, self.gui.contact_relax, id=MENU_HELP_MAIL)
        self.gui.Bind(wx.EVT_MENU, self.gui.references, id=MENU_HELP_REFS)
        self.gui.Bind(wx.EVT_MENU, self._licence, id=MENU_HELP_GPL)
        self.gui.Bind(wx.EVT_MENU, self.gui.about_relax, id=MENU_HELP_ABOUT)

        # Add the menu bar GUI item to the main frame.
        if status.show_gui:
            self.gui.SetMenuBar(self.menubar)

        # Menu update.
        self.gui.Bind(wx.EVT_MENU_OPEN, self.update_menus)
Exemple #19
0
def build_uf_menus(parent=None, menubar=None):
    """Auto-generate the user function sub-menu.

    @keyword parent:    The parent window to bind the events to.
    @type parent:       wx instance
    @keyword menubar:   The menubar to attach the user function menus to.
    @type menubar:      wx.MenuBar instance
    @return:            The menu ID.
    @rtype:             int
    """

    # The user function menus.
    menu1 = wx.Menu()
    menu2 = wx.Menu()

    # The menu splitting.
    pattern = '^[a-m]'

    # Initialise some variables.
    class_list = []
    uf_store = Uf_storage()

    # Loop over the user functions.
    class_item = None
    menu = menu1
    menu_index = 0
    for name, data in uf_info.uf_loop():
        # Split up the name.
        if search('\.', name):
            class_name, uf_name = name.split('.')
        else:
            class_name = None

        # Generate a sub menu.
        if class_name:
            if class_name not in class_list:
                # Add the last sub menu.
                if class_item != None:
                    if dep_check.wx_classic:
                        menu.AppendItem(class_item)
                    else:
                        menu.Append(class_item)

                # Get the user function class data object.
                class_data = uf_info.get_class(class_name)

                # Create the menu entry.
                class_item = build_menu_item(menu, id=-1, text=class_data.menu_text, icon=fetch_icon(class_data.gui_icon, size='16x16'), append=False)

                # Initialise the sub menu.
                sub_menu = wx.Menu()
                class_item.SetSubMenu(sub_menu)

                # Add the class name to the list to block further sub menu creation.
                class_list.append(class_name)

            # Create the user function menu entry.
            build_menu_item(sub_menu, id=uf_store[name]._uf_id, text=data.menu_text, icon=fetch_icon(data.gui_icon, size='16x16'))

        # No sub menu.
        else:
            # Add the last sub menu.
            if class_item != None:
                if dep_check.wx_classic:
                    menu.AppendItem(class_item)
                else:
                    menu.Append(class_item)
                class_item = None

            # The menu item.
            build_menu_item(menu, id=uf_store[name]._uf_id, text=data.menu_text, icon=fetch_icon(data.gui_icon, size='16x16'), append=False)

        # New menu.
        if menu_index == 0 and not search(pattern, name):
            menu = menu2
            menu_index = 1

        # Bind the menu item to the parent.
        parent.Bind(wx.EVT_MENU, parent.uf_call, id=uf_store[name]._uf_id)

    # Add the very last sub menu.
    if class_item != None:
        if dep_check.wx_classic:
            menu.AppendItem(class_item)
        else:
            menu.Append(class_item)

    # Add the user function menu to the menu bar.
    title1 = "&User functions (a-m)"
    title2 = "&User functions (n-z)"
    menubar.Append(menu1, title1)
    menubar.Append(menu2, title2)

    # Return the menu IDs.
    return [menubar.FindMenu(title1), menubar.FindMenu(title2)]
Exemple #20
0
    def menu(self, event):
        """The pop up menu.

        @param event:   The wx event.
        @type event:    wx event
        """

        # Get the row.
        row = event.GetRow()

        # Get the name of the data pipe.
        self.selected_pipe = gui_to_str(self.grid.GetCellValue(row, 0))

        # No data pipe.
        if not self.selected_pipe:
            return

        # The pipe type and bundle.
        pipe_type = get_type(self.selected_pipe)
        pipe_bundle = get_bundle(self.selected_pipe)

        # Initialise the menu.
        popup_menus = []

        # Menu entry:  add the data pipe to a bundle.
        if not pipe_bundle:
            popup_menus.append({
                'id': MENU_BUNDLE,
                'text': "&Add the pipe to a bundle",
                'icon': fetch_icon("relax.pipe_bundle"),
                'method': self.pipe_bundle
            })

        # Menu entry:  delete the data pipe.
        popup_menus.append({
            'id': MENU_DELETE,
            'text': "&Delete the pipe",
            'icon': fetch_icon('oxygen.actions.list-remove', "16x16"),
            'method': self.pipe_delete
        })

        # Menu entry:  switch to this data pipe.
        popup_menus.append({
            'id': MENU_SWITCH,
            'text': "&Switch to this pipe",
            'icon': fetch_icon('oxygen.actions.system-switch-user', "16x16"),
            'method': self.pipe_switch
        })

        # Menu entry:  new auto-analysis tab.
        if pipe_bundle and self.gui.analysis.page_index_from_bundle(pipe_bundle) == None and pipe_type in ['noe', 'r1', 'r2', 'mf', 'relax_disp']:
            popup_menus.append({
                'id': MENU_NEW_AUTO_ANALYSIS,
                'text': "&Associate with a new auto-analysis",
                'icon': fetch_icon('oxygen.actions.document-new', "16x16"),
                'method': self.associate_auto
            })

        # Execution lock, so do nothing.
        if status.exec_lock.locked():
            return

        # Initialise the menu.
        menu = wx.Menu()

        # Loop over the menu items.
        for i in range(len(popup_menus)):
            # Alias.
            info = popup_menus[i]

            # Add the menu item.
            menu.AppendItem(build_menu_item(menu, id=info['id'], text=info['text'], icon=info['icon']))

            # Bind clicks.
            self.Bind(wx.EVT_MENU, info['method'], id=info['id'])

        # Pop up the menu.
        if status.show_gui:
            self.PopupMenu(menu)

        # Cleanup.
        menu.Destroy()
Exemple #21
0
def build_uf_menus(parent=None, menubar=None):
    """Auto-generate the user function sub-menu.

    @keyword parent:    The parent window to bind the events to.
    @type parent:       wx instance
    @keyword menubar:   The menubar to attach the user function menus to.
    @type menubar:      wx.MenuBar instance
    @return:            The menu ID.
    @rtype:             int
    """

    # The user function menus.
    menu1 = wx.Menu()
    menu2 = wx.Menu()

    # The menu splitting.
    pattern = '^[a-m]'

    # Initialise some variables.
    class_list = []
    uf_store = Uf_storage()

    # Loop over the user functions.
    class_item = None
    menu = menu1
    menu_index = 0
    for name, data in uf_info.uf_loop():
        # Split up the name.
        if search('\.', name):
            class_name, uf_name = name.split('.')
        else:
            class_name = None

        # Generate a sub menu.
        if class_name:
            if class_name not in class_list:
                # Add the last sub menu.
                if class_item != None:
                    menu.AppendItem(class_item)

                # Get the user function class data object.
                class_data = uf_info.get_class(class_name)

                # Create the menu entry.
                class_item = build_menu_item(menu, id=-1, text=class_data.menu_text, icon=fetch_icon(class_data.gui_icon, size='16x16'))

                # Initialise the sub menu.
                sub_menu = wx.Menu()
                class_item.SetSubMenu(sub_menu)

                # Add the class name to the list to block further sub menu creation.
                class_list.append(class_name)

            # Create the user function menu entry.
            sub_menu.AppendItem(build_menu_item(sub_menu, id=uf_store[name]._uf_id, text=data.menu_text, icon=fetch_icon(data.gui_icon, size='16x16')))

        # No sub menu.
        else:
            # Add the last sub menu.
            if class_item != None:
                menu.AppendItem(class_item)
                class_item = None

            # The menu item.
            menu.AppendItem(build_menu_item(menu, id=uf_store[name]._uf_id, text=data.menu_text, icon=fetch_icon(data.gui_icon, size='16x16')))

        # New menu.
        if menu_index == 0 and not search(pattern, name):
            menu = menu2
            menu_index = 1

        # Bind the menu item to the parent.
        parent.Bind(wx.EVT_MENU, parent.uf_call, id=uf_store[name]._uf_id)

    # Add the very last sub menu.
    if class_item != None:
        menu.AppendItem(class_item)

    # Add the user function menu to the menu bar.
    title1 = "&User functions (a-m)"
    title2 = "&User functions (n-z)"
    menubar.Append(menu1, title1)
    menubar.Append(menu2, title2)

    # Return the menu IDs.
    return [menubar.FindMenu(title1), menubar.FindMenu(title2)]
Exemple #22
0
    def __init__(self, gui):
        """Build the menu bar."""

        # Store the args.
        self.gui = gui

        # Create the menu bar GUI item.
        self.menubar = wx.MenuBar()

        # The 'File' menu entries.
        menu = wx.Menu()
        menu.AppendItem(build_menu_item(menu, id=MENU_FILE_NEW, text="&New analysis\tCtrl+N", icon=fetch_icon('oxygen.actions.document-new', "16x16")))
        menu.AppendItem(build_menu_item(menu, id=MENU_FILE_CLOSE, text="&Close analysis", icon=fetch_icon('oxygen.actions.document-close', "16x16")))
        menu.AppendItem(build_menu_item(menu, id=MENU_FILE_CLOSE_ALL, text="&Close all analyses", icon=fetch_icon('oxygen.actions.dialog-close', "16x16")))
        menu.AppendSeparator()
        menu.AppendItem(build_menu_item(menu, id=MENU_FILE_OPEN, text="&Open relax state\tCtrl+O", icon=fetch_icon('oxygen.actions.document-open', "16x16")))
        menu.AppendItem(build_menu_item(menu, id=MENU_FILE_SAVE, text="S&ave relax state\tCtrl+S", icon=fetch_icon('oxygen.actions.document-save', "16x16")))
        menu.AppendItem(build_menu_item(menu, id=MENU_FILE_SAVE_AS, text="Save as...\tCtrl+Shift+S", icon=fetch_icon('oxygen.actions.document-save-as', "16x16")))
        menu.AppendSeparator()
        menu.AppendItem(build_menu_item(menu, id=MENU_FILE_EXPORT_BMRB, text="Export for BMRB deposition", icon=fetch_icon('relax.bmrb')))
        menu.AppendSeparator()
        menu.AppendItem(build_menu_item(menu, id=MENU_FILE_EXIT, text="E&xit\tCtrl+Q", icon=fetch_icon('oxygen.actions.system-shutdown', "16x16")))
        self.menubar.Append(menu, "&File")

        # The 'File' menu actions.
        self.gui.Bind(wx.EVT_MENU, self.gui.analysis.menu_new, id=MENU_FILE_NEW)
        self.gui.Bind(wx.EVT_MENU, self.gui.analysis.menu_close, id=MENU_FILE_CLOSE)
        self.gui.Bind(wx.EVT_MENU, self.gui.analysis.menu_close_all, id=MENU_FILE_CLOSE_ALL)
        self.gui.Bind(wx.EVT_MENU, self.gui.state_load, id=MENU_FILE_OPEN)
        self.gui.Bind(wx.EVT_MENU, self.gui.action_state_save, id=MENU_FILE_SAVE)
        self.gui.Bind(wx.EVT_MENU, self.gui.action_state_save_as, id=MENU_FILE_SAVE_AS)
        self.gui.Bind(wx.EVT_MENU, self.gui.action_export_bmrb, id=MENU_FILE_EXPORT_BMRB)
        self.gui.Bind(wx.EVT_MENU, self.gui.exit_gui, id=MENU_FILE_EXIT)

        # The 'View' menu entries.
        menu = wx.Menu()
        menu.AppendItem(build_menu_item(menu, id=MENU_VIEW_CONTROLLER, text="&Controller\tCtrl+Z", icon=fetch_icon('oxygen.apps.preferences-system-performance', "16x16")))
        menu.AppendItem(build_menu_item(menu, id=MENU_VIEW_SPIN_VIEW, text="&Spin viewer\tCtrl+T", icon=fetch_icon('relax.spin', "16x16")))
        menu.AppendItem(build_menu_item(menu, id=MENU_VIEW_RESULTS, text="&Results viewer\tCtrl+R", icon=fetch_icon('oxygen.actions.view-statistics', "16x16")))
        menu.AppendItem(build_menu_item(menu, id=MENU_VIEW_PIPE_EDIT, text="&Data pipe editor\tCtrl+D", icon=fetch_icon('relax.pipe', "16x16")))
        menu.AppendItem(build_menu_item(menu, id=MENU_VIEW_PROMPT, text="relax &prompt\tCtrl+P", icon=fetch_icon('oxygen.mimetypes.application-x-executable-script', "16x16")))
        self.menubar.Append(menu, "&View")

        # The 'View' actions.
        self.gui.Bind(wx.EVT_MENU, self.gui.show_controller, id=MENU_VIEW_CONTROLLER)
        self.gui.Bind(wx.EVT_MENU, self.gui.show_prompt, id=MENU_VIEW_PROMPT)
        self.gui.Bind(wx.EVT_MENU, self.gui.show_tree, id=MENU_VIEW_SPIN_VIEW)
        self.gui.Bind(wx.EVT_MENU, self.gui.show_results_viewer, id=MENU_VIEW_RESULTS)
        self.gui.Bind(wx.EVT_MENU, self.gui.show_pipe_editor, id=MENU_VIEW_PIPE_EDIT)

        # The auto generated 'User functions' menu entries.
        self.menu_uf_ids = build_uf_menus(parent=self.gui, menubar=self.menubar)

        # The 'Tools' menu entries.
        menu = wx.Menu()
        menu.AppendItem(build_menu_item(menu, id=MENU_TOOLS_FORMAT, text="&Free file format settings", icon=fetch_icon('oxygen.actions.document-properties', "16x16")))
        menu.AppendItem(build_menu_item(menu, id=MENU_TOOLS_SYS_INFO, text="System &information", icon=fetch_icon('oxygen.actions.help-about', "16x16")))

        # The 'Tools->Test suite" sub-menu.
        test_suite_item = build_menu_item(menu, id=MENU_TOOLS_TEST_SUITE, text="&Test suite", icon=fetch_icon('oxygen.mimetypes.application-x-desktop', "16x16"))
        sub_menu = wx.Menu()
        test_suite_item.SetSubMenu(sub_menu)
        sub_menu.AppendItem(build_menu_item(sub_menu, id=MENU_TOOLS_TEST_SUITE_ALL, text="&Full test suite", icon=fetch_icon('oxygen.mimetypes.application-x-desktop', "16x16")))
        sub_menu.AppendSeparator()
        sub_menu.AppendItem(build_menu_item(sub_menu, id=MENU_TOOLS_TEST_SUITE_SYS, text="&System tests", icon=fetch_icon('oxygen.mimetypes.application-x-desktop', "16x16")))
        sub_menu.AppendItem(build_menu_item(sub_menu, id=MENU_TOOLS_TEST_SUITE_UNIT, text="&Unit tests", icon=fetch_icon('oxygen.mimetypes.application-x-desktop', "16x16")))
        sub_menu.AppendItem(build_menu_item(sub_menu, id=MENU_TOOLS_TEST_SUITE_GUI, text="&GUI tests", icon=fetch_icon('oxygen.mimetypes.application-x-desktop', "16x16")))
        sub_menu.AppendItem(build_menu_item(sub_menu, id=MENU_TOOLS_TEST_SUITE_VERIFICATION, text="&Verification tests", icon=fetch_icon('oxygen.mimetypes.application-x-desktop', "16x16")))
        menu.AppendItem(test_suite_item)
        self.menubar.Append(menu, "&Tools")

        # The 'Tools' menu actions.
        self.gui.Bind(wx.EVT_MENU, self.gui.free_file_format_settings, id=MENU_TOOLS_FORMAT)
        self.gui.Bind(wx.EVT_MENU, self._sys_info, id=MENU_TOOLS_SYS_INFO)
        self.gui.Bind(wx.EVT_MENU, self.gui.run_test_suite, id=MENU_TOOLS_TEST_SUITE_ALL)
        self.gui.Bind(wx.EVT_MENU, self.gui.run_test_suite_sys, id=MENU_TOOLS_TEST_SUITE_SYS)
        self.gui.Bind(wx.EVT_MENU, self.gui.run_test_suite_unit, id=MENU_TOOLS_TEST_SUITE_UNIT)
        self.gui.Bind(wx.EVT_MENU, self.gui.run_test_suite_gui, id=MENU_TOOLS_TEST_SUITE_GUI)
        self.gui.Bind(wx.EVT_MENU, self.gui.run_test_suite_verification, id=MENU_TOOLS_TEST_SUITE_VERIFICATION)

        # The 'Help' menu entries.
        menu = wx.Menu()
        menu.AppendItem(build_menu_item(menu, id=MENU_HELP_MANUAL, text="relax user &manual\tF1", icon=fetch_icon('oxygen.mimetypes.application-pdf', "16x16")))
        menu.AppendSeparator()
        menu.AppendItem(build_menu_item(menu, id=MENU_HELP_MAIL, text="Mailing list &contact ([email protected])", icon=fetch_icon('oxygen.actions.mail-mark-unread-new', "16x16")))
        menu.AppendItem(build_menu_item(menu, id=MENU_HELP_REFS, text="&References", icon=fetch_icon('oxygen.actions.flag-blue', "16x16")))
        menu.AppendSeparator()
        menu.AppendItem(build_menu_item(menu, id=MENU_HELP_GPL, text="&Licence", icon=fetch_icon('relax.gnu-head-mini', "16x16")))
        menu.AppendSeparator()
        menu.AppendItem(build_menu_item(menu, id=MENU_HELP_ABOUT, text="About rela&x", icon=fetch_icon("relax.relax")))
        self.menubar.Append(menu, "&Help")

        # The 'Help' menu actions.
        self.gui.Bind(wx.EVT_MENU, self.gui.relax_manual, id=MENU_HELP_MANUAL)
        self.gui.Bind(wx.EVT_MENU, self.gui.contact_relax, id=MENU_HELP_MAIL)
        self.gui.Bind(wx.EVT_MENU, self.gui.references, id=MENU_HELP_REFS)
        self.gui.Bind(wx.EVT_MENU, self._licence, id=MENU_HELP_GPL)
        self.gui.Bind(wx.EVT_MENU, self.gui.about_relax, id=MENU_HELP_ABOUT)

        # Add the menu bar GUI item to the main frame.
        if status.show_gui:
            self.gui.SetMenuBar(self.menubar)

        # Menu update.
        self.gui.Bind(wx.EVT_MENU_OPEN, self.update_menus)
Exemple #23
0
    def pop_up_menu(self, event):
        """Override the StyledTextCtrl pop up menu.

        @param event:   The wx event.
        @type event:    wx event
        """

        # Create the menu.
        menu = wx.Menu()

        # Add the entries.
        menu.AppendItem(
            build_menu_item(menu, id=MENU_ID_FIND, text="&Find", icon=fetch_icon("oxygen.actions.edit-find", "16x16"))
        )
        menu.AppendSeparator()
        menu.AppendItem(
            build_menu_item(menu, id=MENU_ID_COPY, text="&Copy", icon=fetch_icon("oxygen.actions.edit-copy", "16x16"))
        )
        menu.AppendItem(
            build_menu_item(
                menu,
                id=MENU_ID_SELECT_ALL,
                text="&Select all",
                icon=fetch_icon("oxygen.actions.edit-select-all", "16x16"),
            )
        )
        menu.AppendSeparator()
        menu.AppendItem(
            build_menu_item(
                menu, id=MENU_ID_ZOOM_IN, text="Zoom &in", icon=fetch_icon("oxygen.actions.zoom-in", "16x16")
            )
        )
        menu.AppendItem(
            build_menu_item(
                menu, id=MENU_ID_ZOOM_OUT, text="Zoom &out", icon=fetch_icon("oxygen.actions.zoom-out", "16x16")
            )
        )
        menu.AppendItem(
            build_menu_item(
                menu,
                id=MENU_ID_ZOOM_ORIG,
                text="Original &zoom",
                icon=fetch_icon("oxygen.actions.zoom-original", "16x16"),
            )
        )
        menu.AppendSeparator()
        menu.AppendItem(
            build_menu_item(
                menu, id=MENU_ID_GOTO_START, text="&Go to start", icon=fetch_icon("oxygen.actions.go-top", "16x16")
            )
        )
        menu.AppendItem(
            build_menu_item(
                menu, id=MENU_ID_GOTO_END, text="&Go to end", icon=fetch_icon("oxygen.actions.go-bottom", "16x16")
            )
        )

        # Pop up the menu.
        if status.show_gui:
            self.PopupMenu(menu)

        # Cleanup.
        menu.Destroy()