Esempio n. 1
0
    def setup_frame(self):
        """Set up the relax controller frame.
        @return:    The sizer object.
        @rtype:     wx.Sizer instance
        """

        # Set the frame title.
        self.SetTitle("BMRB export window")

        # Set up the window icon.
        self.SetIcons(relax_icons)

        # Place all elements within a panel (to remove the dark grey in MS Windows).
        self.main_panel = wx.Panel(self, -1)

        # Use a grid sizer for packing the main elements.
        main_sizer = wx.BoxSizer(wx.VERTICAL)
        self.main_panel.SetSizer(main_sizer)

        # Build the central sizer, with borders.
        sizer = add_border(main_sizer, border=self.border, packing=wx.VERTICAL)

        # Close the window cleanly (unregistering observers).
        self.Bind(wx.EVT_CLOSE, self.handler_close)

        # Set the default size of the controller.
        self.SetSize(self.size)
        self.SetMinSize(self.size_min)

        # Centre the frame.
        self.Centre()

        # Return the central sizer.
        return sizer
Esempio n. 2
0
    def setup_frame(self):
        """Set up the relax controller frame.
        @return:    The sizer object.
        @rtype:     wx.Sizer instance
        """

        # Set the frame title.
        self.SetTitle("BMRB export window")

        # Set up the window icon.
        self.SetIcons(relax_icons)

        # Place all elements within a panel (to remove the dark grey in MS Windows).
        self.main_panel = wx.Panel(self, -1)

        # Use a grid sizer for packing the main elements.
        main_sizer = wx.BoxSizer(wx.VERTICAL)
        self.main_panel.SetSizer(main_sizer)

        # Build the central sizer, with borders.
        sizer = add_border(main_sizer, border=self.border, packing=wx.VERTICAL)

        # Close the window cleanly (unregistering observers).
        self.Bind(wx.EVT_CLOSE, self.handler_close)

        # Set the default size of the controller.
        self.SetSize(self.size)
        self.SetMinSize(self.size_min)

        # Centre the frame.
        self.Centre()

        # Return the central sizer.
        return sizer
Esempio n. 3
0
    def __init__(self):
        """Set up the window."""

        # Set up the dialog.
        wx.Dialog.__init__(self, None, id=-1, title="Protocol mode selection")

        # Initialise some values
        size_x = 600
        size_y = 600
        border = 10
        self.select = 'Fully automated'

        # Set the frame properties.
        self.SetSize((size_x, size_y))
        self.Centre()
        self.SetFont(font.normal)

        # The main box sizer.
        main_sizer = wx.BoxSizer(wx.VERTICAL)

        # Pack the sizer into the frame.
        self.SetSizer(main_sizer)

        # Build the central sizer, with borders.
        sizer = add_border(main_sizer, border=border, packing=wx.HORIZONTAL)

        # Build the automatic part.
        self.build_auto(sizer)

        # Line separator.
        sizer.Add(wx.StaticLine(self, -1, style=wx.LI_VERTICAL), 0, wx.EXPAND|wx.ALL, border)

        # Build the manual part.
        self.build_manual(sizer)
Esempio n. 4
0
    def __init__(self):
        """Set up the window."""

        # Set up the dialog.
        wx.Dialog.__init__(self, None, id=-1, title="Protocol mode selection")

        # Initialise some values
        size_x = 600
        size_y = 600
        border = 10
        self.select = 'Fully automated'

        # Set the frame properties.
        self.SetSize((size_x, size_y))
        self.Centre()
        self.SetFont(font.normal)

        # The main box sizer.
        main_sizer = wx.BoxSizer(wx.VERTICAL)

        # Pack the sizer into the frame.
        self.SetSizer(main_sizer)

        # Build the central sizer, with borders.
        sizer = add_border(main_sizer, border=border, packing=wx.HORIZONTAL)

        # Build the automatic part.
        self.build_auto(sizer)

        # Line separator.
        sizer.Add(wx.StaticLine(self, -1, style=wx.LI_VERTICAL), 0,
                  wx.EXPAND | wx.ALL, border)

        # Build the manual part.
        self.build_manual(sizer)
Esempio n. 5
0
    def __init__(self, gui=None, size_x=1000, size_y=600, border=10):
        """Set up the relax controller frame.
        
        @keyword gui:       The main GUI object.
        @type gui:          wx.Frame instance
        @keyword size_x:    The initial and minimum width of the window.
        @type size_x:       int
        @keyword size_y:    The initial and minimum height of the window.
        @type size_y:       int
        @keyword border:    The size of the internal border of the window.
        @type border:       int
        """

        # Store the args.
        self.gui = gui
        self.border = border

        # Create GUI elements
        wx.Frame.__init__(self, None, id=-1, title="Data pipe editor")

        # Set up the window icon.
        self.SetIcons(relax_icons)

        # Initialise some data.
        self.width_col_label = 40

        # Set the normal and minimum window sizes.
        self.SetMinSize((size_x, size_y))
        self.SetSize((size_x, size_y))

        # Place all elements within a panel (to remove the dark grey in MS Windows).
        self.main_panel = wx.Panel(self, -1)

        # Pack a sizer into the panel.
        main_sizer = wx.BoxSizer(wx.VERTICAL)
        self.main_panel.SetSizer(main_sizer)

        # Build the central sizer, with borders.
        sizer = add_border(main_sizer, border=border, packing=wx.VERTICAL)

        # Add the contents.
        sizer.AddSpacer(10)
        self.add_logo(sizer)
        sizer.AddSpacer(20)
        self.add_buttons(sizer)
        sizer.AddSpacer(10)
        self.add_table(sizer)

        # Bind some events.
        self.grid.Bind(wx.EVT_SIZE, self.resize)
        self.Bind(wx.EVT_CLOSE, self.handler_close)
        self.grid.Bind(wx.grid.EVT_GRID_CELL_RIGHT_CLICK, self.menu)

        # Initialise the observer name.
        self.name = 'pipe editor'

        # Update the grid.
        self.update_grid()
Esempio n. 6
0
    def __init__(self, gui=None, parent=None, subparent=None, data=None, label=None, width=688, height=300, box=None):
        """Build the peak list reading GUI element.

        @keyword gui:       The main GUI object.
        @type gui:          wx.Frame instance
        @keyword parent:    The parent GUI element that this is to be attached to (the panel object).
        @type parent:       wx object
        @keyword subparent: The subparent GUI element that this is to be attached to (the analysis object).
        @type subparent:    wx object
        @keyword data:      The data storage container.
        @type data:         class instance
        @keyword label:     The type of analysis.
        @type label:        str
        @keyword width:     The initial width of the GUI element.
        @type width:        int
        @keyword height:    The initial height of the GUI element.
        @type height:       int
        @keyword box:       The vertical box sizer to pack this GUI component into.
        @type box:          wx.BoxSizer instance
        """

        # Store the arguments.
        self.gui = gui
        self.parent = parent
        self.subparent = subparent
        self.data = data
        self.label = label

        # GUI variables.
        self.spacing = 5
        self.border = 5

        # The number of rows.
        self.num_rows = 50

        # A static box to hold all the widgets, and its sizer.
        stat_box = wx.StaticBox(self.parent, -1, "Peak lists")
        stat_box.SetFont(font.subtitle)
        sub_sizer = wx.StaticBoxSizer(stat_box, wx.VERTICAL)

        # Add the sizer to the static box and the static box to the main box.
        box.Add(sub_sizer, 1, wx.ALL|wx.EXPAND, 0)

        # Add a border.
        box_centre = add_border(sub_sizer, border=self.border)

        # Add the cycle delay time element.
        box_centre.AddSpacer(self.spacing)
        self.delay_time = self.subparent.add_text_sel_element(box_centre, self.parent, text="Single delay cycle time [s]")

        # Add the grid.
        box_centre.AddSpacer(self.spacing)
        self.add_grid(box_centre)
        box_centre.AddSpacer(self.spacing)

        # Bind some events.
        self.delay_time.Bind(wx.EVT_KEY_DOWN, self.change_delay_down)
        self.delay_time.Bind(wx.EVT_KEY_UP, self.change_delay_up)
Esempio n. 7
0
    def __init__(self, gui=None, parent=None, subparent=None, data=None, label=None, width=688, height=300, box=None):
        """Build the peak list reading GUI element.

        @keyword gui:       The main GUI object.
        @type gui:          wx.Frame instance
        @keyword parent:    The parent GUI element that this is to be attached to (the panel object).
        @type parent:       wx object
        @keyword subparent: The subparent GUI element that this is to be attached to (the analysis object).
        @type subparent:    wx object
        @keyword data:      The data storage container.
        @type data:         class instance
        @keyword label:     The type of analysis.
        @type label:        str
        @keyword width:     The initial width of the GUI element.
        @type width:        int
        @keyword height:    The initial height of the GUI element.
        @type height:       int
        @keyword box:       The vertical box sizer to pack this GUI component into.
        @type box:          wx.BoxSizer instance
        """

        # Store the arguments.
        self.gui = gui
        self.parent = parent
        self.subparent = subparent
        self.data = data
        self.label = label

        # GUI variables.
        self.spacing = 5
        self.border = 5

        # The number of rows.
        self.num_rows = 50

        # A static box to hold all the widgets, and its sizer.
        stat_box = wx.StaticBox(self.parent, -1, "Peak lists")
        stat_box.SetFont(font.subtitle)
        sub_sizer = wx.StaticBoxSizer(stat_box, wx.VERTICAL)

        # Add the sizer to the static box and the static box to the main box.
        box.Add(sub_sizer, 1, wx.ALL|wx.EXPAND, 0)

        # Add a border.
        box_centre = add_border(sub_sizer, border=self.border)

        # Add the cycle delay time element.
        box_centre.AddSpacer(self.spacing)
        self.delay_time = self.subparent.add_text_sel_element(box_centre, self.parent, text="Single delay cycle time [s]")

        # Add the grid.
        box_centre.AddSpacer(self.spacing)
        self.add_grid(box_centre)
        box_centre.AddSpacer(self.spacing)

        # Bind some events.
        self.delay_time.Bind(wx.EVT_KEY_DOWN, self.change_delay_down)
        self.delay_time.Bind(wx.EVT_KEY_UP, self.change_delay_up)
Esempio n. 8
0
    def __init__(self, gui=None, size_x=1000, size_y=600, border=10):
        """Set up the relax controller frame.
        
        @keyword gui:       The main GUI object.
        @type gui:          wx.Frame instance
        @keyword size_x:    The initial and minimum width of the window.
        @type size_x:       int
        @keyword size_y:    The initial and minimum height of the window.
        @type size_y:       int
        @keyword border:    The size of the internal border of the window.
        @type border:       int
        """

        # Store the args.
        self.gui = gui
        self.border = border

        # Create GUI elements
        wx.Frame.__init__(self, None, id=-1, title="Data pipe editor")

        # Set up the window icon.
        self.SetIcons(relax_icons)

        # Initialise some data.
        self.width_col_label = 40

        # Set the normal and minimum window sizes.
        self.SetMinSize((size_x, size_y))
        self.SetSize((size_x, size_y))

        # Place all elements within a panel (to remove the dark grey in MS Windows).
        self.main_panel = wx.Panel(self, -1)

        # Pack a sizer into the panel.
        main_sizer = wx.BoxSizer(wx.VERTICAL)
        self.main_panel.SetSizer(main_sizer)

        # Build the central sizer, with borders.
        sizer = add_border(main_sizer, border=border, packing=wx.VERTICAL)

        # Add the contents.
        sizer.AddSpacer(10)
        self.add_logo(sizer)
        sizer.AddSpacer(20)
        self.add_buttons(sizer)
        sizer.AddSpacer(10)
        self.add_table(sizer)

        # Bind some events.
        self.grid.Bind(wx.EVT_SIZE, self.resize)
        self.Bind(wx.EVT_CLOSE, self.handler_close)
        self.grid.Bind(wx.grid.EVT_GRID_CELL_RIGHT_CLICK, self.menu)

        # Initialise the observer name.
        self.name = 'pipe editor'

        # Update the grid.
        self.update_grid()
Esempio n. 9
0
    def __init__(self, parent):
        """Build the results frame.

        @param parent:  The parent wx object.
        @type parent:   wx object
        """

        # Initialise the base frame.
        wx.Frame.__init__(self, parent=parent, style=wx.DEFAULT_FRAME_STYLE)

        # Set up the window icon.
        self.SetIcons(relax_icons)

        # Set the window title, size, etc.
        self.SetTitle("Results viewer")
        self.SetSize(self.size)

       # Place all elements within a panel (to remove the dark grey in MS Windows).
        self.main_panel = wx.Panel(self, -1)

        # Pack a sizer into the panel.
        box_main = wx.BoxSizer(wx.HORIZONTAL)
        self.main_panel.SetSizer(box_main)

        # Build the central sizer, with borders.
        box_centre = add_border(box_main, border=self.border, packing=wx.VERTICAL)

        # Build the data pipe selector.
        self.build_pipe_sel(box_centre)

        # Spacer.
        box_centre.AddSpacer(self.border)

        # Add the list of results files.
        self.add_files(box_centre)

        # Spacer.
        box_centre.AddSpacer(self.border)

        # Add the open button.
        self.button_open = buttons.ThemedGenBitmapTextButton(self.main_panel, -1, None, " Open")
        self.button_open.SetBitmapLabel(wx.Bitmap(fetch_icon('oxygen.actions.document-open', "22x22"), wx.BITMAP_TYPE_ANY))
        self.button_open.SetFont(font.normal)
        self.button_open.SetMinSize((103, 33))
        self.Bind(wx.EVT_BUTTON, self.open_result_file, self.button_open)
        box_centre.Add(self.button_open, 0, wx.ALIGN_RIGHT|wx.ADJUST_MINSIZE, 5)

        # Relayout the main panel.
        self.main_panel.Layout()
        self.main_panel.Refresh()

        # Bind some events.
        self.Bind(wx.EVT_COMBOBOX, self.switch_pipes, self.pipe_name)
        self.Bind(wx.EVT_CLOSE, self.handler_close)

        # Initialise observer name.
        self.name = 'results viewer'
Esempio n. 10
0
    def __init__(self, parent):
        """Build the results frame.

        @param parent:  The parent wx object.
        @type parent:   wx object
        """

        # Initialise the base frame.
        wx.Frame.__init__(self, parent=parent, style=wx.DEFAULT_FRAME_STYLE)

        # Set up the window icon.
        self.SetIcons(relax_icons)

        # Set the window title, size, etc.
        self.SetTitle("Results viewer")
        self.SetSize(self.size)

       # Place all elements within a panel (to remove the dark grey in MS Windows).
        self.main_panel = wx.Panel(self, -1)

        # Pack a sizer into the panel.
        box_main = wx.BoxSizer(wx.HORIZONTAL)
        self.main_panel.SetSizer(box_main)

        # Build the central sizer, with borders.
        box_centre = add_border(box_main, border=self.border, packing=wx.VERTICAL)

        # Build the data pipe selector.
        self.build_pipe_sel(box_centre)

        # Spacer.
        box_centre.AddSpacer(self.border)

        # Add the list of results files.
        self.add_files(box_centre)

        # Spacer.
        box_centre.AddSpacer(self.border)

        # Add the open button.
        self.button_open = buttons.ThemedGenBitmapTextButton(self.main_panel, -1, None, " Open")
        self.button_open.SetBitmapLabel(wx.Bitmap(fetch_icon('oxygen.actions.document-open', "22x22"), wx.BITMAP_TYPE_ANY))
        self.button_open.SetFont(font.normal)
        self.button_open.SetMinSize((103, 33))
        self.Bind(wx.EVT_BUTTON, self.open_result_file, self.button_open)
        box_centre.Add(self.button_open, 0, wx.ALIGN_RIGHT|wx.ADJUST_MINSIZE, 5)

        # Relayout the main panel.
        self.main_panel.Layout()
        self.main_panel.Refresh()

        # Bind some events.
        self.Bind(wx.EVT_COMBOBOX, self.switch_pipes, self.pipe_name)
        self.Bind(wx.EVT_CLOSE, self.handler_close)

        # Initialise observer name.
        self.name = 'results viewer'
Esempio n. 11
0
    def __init__(self,
                 parent,
                 id=wx.ID_ANY,
                 pos=None,
                 size=None,
                 style=None,
                 name=None,
                 gui=None):
        """Initialise the scrolled window.

        @param parent:  The parent wx element.
        @type parent:   wx object
        @keyword id:    The unique ID number.
        @type id:       int
        @keyword pos:   The position.
        @type pos:      wx.Size object
        @keyword size:  The size.
        @type size:     wx.Size object
        @keyword style: The style.
        @type style:    int
        @keyword name:  The name for the panel.
        @type name:     unicode
        """

        # Execute the base class method.
        super(Base_analysis, self).__init__(parent,
                                            id=id,
                                            pos=pos,
                                            size=size,
                                            style=style,
                                            name=name)

        # Determine the size of the scrollers.
        self.width_vscroll = wx.SystemSettings.GetMetric(wx.SYS_VSCROLL_X)

        # Pack a sizer into the panel.
        box_main = wx.BoxSizer(wx.HORIZONTAL)
        self.SetSizer(box_main)

        # Build the central sizer, with borders.
        box_centre = add_border(box_main,
                                border=self.border,
                                packing=wx.HORIZONTAL)

        # Build and pack the main sizer box, then add it to the automatic model-free analysis frame.
        self.build_main_box(box_centre)

        # Set up the scrolled panel.
        self.SetAutoLayout(True)
        self.SetupScrolling(scroll_x=False, scroll_y=True)

        # Bind resize events.
        self.Bind(wx.EVT_SIZE, self.resize)
Esempio n. 12
0
    def __init__(self, parent=None, name='', spacing=10):
        """Set up the file list selection window.

        @keyword parent:    The parent GUI element.
        @type parent:       wx.Window instance or None
        @keyword name:      The name of the window.
        @type name:         str
        @keyword spacing:   The spacing between elements in pixels.
        @type spacing:      int
        """

        # Store the args.
        self.name = name
        self.spacing = spacing

        # The title of the dialog.
        title = "Multiple %s selection." % name

        # Set up the dialog.
        wx.Dialog.__init__(self, parent, id=-1, title=title)

        # Initialise some values
        self.width = self.SIZE[0] - 2*self.BORDER

        # Set the frame properties.
        self.SetSize(self.SIZE)
        self.Centre()
        self.SetFont(font.normal)

        # The main box sizer.
        main_sizer = wx.BoxSizer(wx.VERTICAL)

        # Pack the sizer into the frame.
        self.SetSizer(main_sizer)

        # Build the central sizer, with borders.
        sizer = add_border(main_sizer, border=self.BORDER, packing=wx.VERTICAL)

        # Add the file list element.
        self.add_file_list(sizer)

        # Some spacing.
        sizer.AddSpacer(self.BORDER)

        # Add the bottom buttons.
        self.add_buttons(sizer)

        # Initialise the list of file selection elements to a single element.
        self.elements = []
        self.add_element()
Esempio n. 13
0
    def __init__(self, parent=None, name='', spacing=10):
        """Set up the file list selection window.

        @keyword parent:    The parent GUI element.
        @type parent:       wx.Window instance or None
        @keyword name:      The name of the window.
        @type name:         str
        @keyword spacing:   The spacing between elements in pixels.
        @type spacing:      int
        """

        # Store the args.
        self.name = name
        self.spacing = spacing

        # The title of the dialog.
        title = "Multiple %s selection." % name

        # Set up the dialog.
        wx.Dialog.__init__(self, parent, id=-1, title=title)

        # Initialise some values
        self.width = self.SIZE[0] - 2 * self.BORDER

        # Set the frame properties.
        self.SetSize(self.SIZE)
        self.Centre()
        self.SetFont(font.normal)

        # The main box sizer.
        main_sizer = wx.BoxSizer(wx.VERTICAL)

        # Pack the sizer into the frame.
        self.SetSizer(main_sizer)

        # Build the central sizer, with borders.
        sizer = add_border(main_sizer, border=self.BORDER, packing=wx.VERTICAL)

        # Add the file list element.
        self.add_file_list(sizer)

        # Some spacing.
        sizer.AddSpacer(self.BORDER)

        # Add the bottom buttons.
        self.add_buttons(sizer)

        # Initialise the list of file selection elements to a single element.
        self.elements = []
        self.add_element()
Esempio n. 14
0
    def __init__(self, parent, id=wx.ID_ANY, pos=None, size=None, style=None, name=None, gui=None):
        """Initialise the scrolled window.

        @param parent:  The parent wx element.
        @type parent:   wx object
        @keyword id:    The unique ID number.
        @type id:       int
        @keyword pos:   The position.
        @type pos:      wx.Size object
        @keyword size:  The size.
        @type size:     wx.Size object
        @keyword style: The style.
        @type style:    int
        @keyword name:  The name for the panel.
        @type name:     unicode
        """

        # Execute the base class method.
        super(Base_analysis, self).__init__(parent, id=id, pos=pos, size=size, style=style, name=name)

        # Determine the size of the scrollers.
        self.width_vscroll = wx.SystemSettings_GetMetric(wx.SYS_VSCROLL_X)

        # Pack a sizer into the panel.
        box_main = wx.BoxSizer(wx.HORIZONTAL)
        self.SetSizer(box_main)

        # Build the central sizer, with borders.
        box_centre = add_border(box_main, border=self.border, packing=wx.HORIZONTAL)

        # Build and pack the main sizer box, then add it to the automatic model-free analysis frame.
        self.build_main_box(box_centre)

        # Set up the scrolled panel.
        self.SetAutoLayout(True)
        self.SetupScrolling(scroll_x=False, scroll_y=True)

        # Bind resize events.
        self.Bind(wx.EVT_SIZE, self.resize)
Esempio n. 15
0
    def __init__(self, parent=None, size_x=400, size_y=400, title='', border=10, style=wx.DEFAULT_DIALOG_STYLE):
        """Set up the window.

        @keyword parent:    The parent window.
        @type parent:       wx.Window instance
        @keyword size_x:    The width of the wizard.
        @type size_x:       int
        @keyword size_y:    The height of the wizard.
        @type size_y:       int
        @keyword title:     The title of the wizard dialog.
        @type title:        str
        @keyword border:    The size of the border inside the wizard.
        @type border:       int
        @keyword style:     The dialog style.
        @type style:        wx style
        """

        # Store the args.
        self._size_x = size_x
        self._size_y = size_y
        self._border = border

        # Execute the base class method.
        wx.Dialog.__init__(self, parent, id=-1, title=title, style=style)

        # Set up the window icon.
        self.SetIcons(relax_icons)

        # The sizer for the dialog.
        sizer = wx.BoxSizer(wx.VERTICAL)
        self.SetSizer(sizer)

        # Build the central sizer, with borders.
        self._main_sizer = add_border(sizer, border=border, packing=wx.VERTICAL)

        # Set the default size of the dialog.
        self.SetSize((size_x, size_y))

        # Centre the dialog.
        self.Centre()

        # Initialise the page storage.
        self._current_page = 0
        self._num_pages = 0
        self._pages = []
        self._page_sizers = []
        self._button_sizers = []
        self._button_apply_flag = []
        self._button_skip_flag = []
        self._buttons = []
        self._button_ids = []
        self._exec_on_next = []
        self._exec_count = []
        self._proceed_on_error = []
        self._uf_flush = []
        self._seq_fn_list = []
        self._seq_next = []
        self._seq_prev = []
        self._skip_flag = []

        # A max of 15 pages should be enough.
        for i in range(15):
            # Append some Nones.
            self._pages.append(None)

            # Initialise all box sizers for the wizard pages.
            self._page_sizers.append(wx.BoxSizer(wx.VERTICAL))

            # Initialise all box sizers for the buttons.
            self._button_sizers.append(wx.BoxSizer(wx.HORIZONTAL))

            # Set all button flags.
            self._button_apply_flag.append(True)
            self._button_skip_flag.append(False)

            # Initialise the button storage.
            self._buttons.append({'back': None,
                                  'apply': None,
                                  'next': None,
                                  'ok': None,
                                  'finish': None,
                                  'cancel': None})

            # Initialise a set of unique button IDs.
            self._button_ids.append({'back': wx.NewId(),
                                     'apply': wx.NewId(),
                                     'next': wx.NewId(),
                                     'ok': wx.NewId(),
                                     'finish': wx.NewId(),
                                     'cancel': wx.NewId()})

            # Execute on next by default.
            self._exec_on_next.append(True)

            # Execution count.
            self._exec_count.append(0)

            # Proceed to next page on errors by default.
            self._proceed_on_error.append(True)

            # No user function flushing of the GUI interpreter thread prior to proceeding.
            self._uf_flush.append(False)

            # Page sequence initialisation.
            self._seq_fn_list.append(self._next_fn)
            self._seq_next.append(None)
            self._seq_prev.append(None)

            # Page skipping.
            self._skip_flag.append(False)

        # Flag to suppress later button addition.
        self._buttons_built = False

        # Bind some events.
        self.Bind(wx.EVT_CLOSE, self._handler_close)
Esempio n. 16
0
    def __init__(self, models, params, desc, size=None, border=None):
        """Set up the model selector window.

        @param models:      The list of models.
        @type models:       list of str
        @param params:      The list of parameters corresponding to the models.
        @type params:       list of str
        @param desc:        The description for each model.
        @type desc:         list of str
        @keyword size:      The initial size of the window.
        @type size:         wx.Size instance
        @keyword border:    The border width, in pixels.
        @type border:       int
        """

        # Set up the dialog.
        wx.Dialog.__init__(self, None, id=-1, title="Model list selector", size=size, style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER)

        # Initialise some values
        desc_flag = False
        if len(desc):
            desc_flag = True

        # Set the frame properties.
        self.SetFont(font.normal)

        # The main sizer.
        main_sizer = wx.BoxSizer(wx.VERTICAL)

        # Pack the sizer into the frame.
        self.SetSizer(main_sizer)

        # Build the central sizer, with borders.
        sizer = add_border(main_sizer, border=border, packing=wx.VERTICAL)

        # A scrolled panel for the text.
        panel = scrolledpanel.ScrolledPanel(self, -1)
        panel.SetAutoLayout(1)
        panel.SetupScrolling()
        sizer.Add(panel, 1, wx.ALL|wx.EXPAND, 0)

        # A sizer for the panel.
        panel_sizer = wx.BoxSizer(wx.HORIZONTAL)
        panel.SetSizer(panel_sizer)

        # Add a list control.
        cols = 2
        if desc_flag:
            cols += 1
        self.grid_sizer = wx.FlexGridSizer(len(models)+2, cols, 3, 30)

        # The headers (and then a space).
        titles = ["Model", "Parameters"]
        if desc_flag:
            titles.append("Description")
        for title in titles:
            text = wx.StaticText(panel, -1, str_to_gui(title))
            text.SetFont(font.subtitle)
            self.grid_sizer.Add(text, 0, wx.ALIGN_CENTER_VERTICAL)
        for i in range(len(titles)):
            self.grid_sizer.Add(wx.StaticText(panel, -1, ""))

        # Add the models and parameters.
        self.model_selection = []
        for i in range(len(models)):
            # No model - i.e. a separator.
            if models[i] == None:
                for i in range(len(titles)):
                    self.grid_sizer.Add(wx.StaticText(panel, -1, ""))
                continue

            # Create a checkbox for the model.
            check_box = wx.CheckBox(panel, -1, str_to_gui(models[i]))
            self.model_selection.append(check_box)
            self.grid_sizer.Add(check_box, 0, wx.ALIGN_CENTER_VERTICAL)

            # Set all selections to True.
            self.model_selection[-1].SetValue(True)

            # Add the parameter text.
            text = wx.StaticText(panel, -1, str_to_gui(params[i]))
            text.SetFont(font.normal)
            self.grid_sizer.Add(text, 0, wx.ALIGN_CENTER_VERTICAL)

            # Add the description.
            if desc_flag:
                text = wx.StaticText(panel, -1, str_to_gui(desc[i]))
                text.SetFont(font.normal)
                self.grid_sizer.Add(text, 0, wx.ALIGN_CENTER_VERTICAL)

        # Add the table to the sizer.
        panel_sizer.Add(self.grid_sizer, 1, wx.ALL|wx.EXPAND, 0)

        # Set up the window.
        self.SetMinSize(wx.Size(600, 300))
        self.Centre()
Esempio n. 17
0
    def __init__(self, parent=None, name='', seq_type='list', value_type='str', dim=None, titles=None):
        """Set up the string list editor window.

        @keyword parent:        The parent GUI element.
        @type parent:           wx.Window instance or None
        @keyword name:          The name of the window.
        @type name:             str
        @keyword seq_type:      The type of Python sequence.  This should be one of 'list' or 'tuple'.
        @type seq_type:         str
        @keyword value_type:    The type of Python data expected in the sequence.  This should be one of 'float', 'int', or 'str'.
        @type value_type:       str
        @keyword dim:           The fixed dimension that the sequence must conform to.
        @type dim:              int or None
        @keyword titles:        The titles of each of the elements of the fixed dimension elements.
        @type titles:           list of str
        """

        # Store the args.
        self.name = name
        self.seq_type = seq_type
        self.value_type = value_type
        self.dim = dim
        self.titles = titles

        # The base types.
        if value_type in ['float', 'num']:
            self.convert_from_gui = gui_to_float
            self.convert_to_gui =   float_to_gui
        elif value_type == 'int':
            self.convert_from_gui = gui_to_int
            self.convert_to_gui =   int_to_gui
        elif value_type == 'str':
            self.convert_from_gui = gui_to_str
            self.convert_to_gui =   str_to_gui
        else:
            raise RelaxError("Unknown base data type '%s'." % value_type)

        # Variable length.
        if not hasattr(self, 'variable_length'):
            self.variable_length = False
            self.offset = 0
            if dim == None:
                self.variable_length = True
                self.offset = 1

        # The title of the dialog.
        title = "Edit the %s values." % name

        # Set up the dialog.
        wx.Dialog.__init__(self, parent, id=-1, title=title)

        # Initialise some values
        self.width = self.SIZE[0] - 2*self.BORDER

        # Set the frame properties.
        self.SetSize(self.SIZE)
        self.Centre()
        self.SetFont(font.normal)

        # The main box sizer.
        main_sizer = wx.BoxSizer(wx.VERTICAL)

        # Pack the sizer into the frame.
        self.SetSizer(main_sizer)

        # Build the central sizer, with borders.
        sizer = add_border(main_sizer, border=self.BORDER, packing=wx.VERTICAL)

        # Add the list control.
        self.add_list(sizer)

        # Some spacing.
        sizer.AddSpacer(self.BORDER)

        # Add the bottom buttons.
        self.add_buttons(sizer)

        # Initialise the list of elements to a single element.
        if not self.sequence.GetItemCount():
            self.add_element()
Esempio n. 18
0
    def __init__(self,
                 gui=None,
                 parent=None,
                 box=None,
                 id=None,
                 proportion=0,
                 button_placement='default'):
        """Build the base list GUI element.

        @keyword gui:               The main GUI object.
        @type gui:                  wx.Frame instance
        @keyword parent:            The parent GUI element that this is to be attached to.
        @type parent:               wx object
        @keyword box:               The box sizer to pack this GUI component into.
        @type box:                  wx.BoxSizer instance
        @keyword id:                A unique identification string.  This is used to register the update method with the GUI user function observer object.
        @type id:                   str
        @keyword proportion:        The window proportion parameter.
        @type proportion:           bool
        @keyword button_placement:  Override the button visibility and placement.  The value of 'default' will leave the buttons at the default setting.  The value of 'top' will place the buttons at the top, 'bottom' will place them at the bottom, and None will turn off the buttons.
        @type button_placement:     str or None
        """

        # Store the arguments.
        self.gui = gui
        self.parent = parent
        self.proportion = proportion

        # Variables to be overridden.
        self.title = ""
        self.spacing = 5
        self.border = 5
        self.observer_base_name = None
        self.columns = []
        self.button_placement = None
        self.button_size = (120, 40)
        self.button_spacing = 5
        self.button_info = []
        self.popup_menus = []

        # Override these base values.
        self.setup()

        # Button placement second override on initialisation.
        if button_placement != 'default':
            self.button_placement = button_placement

        # First create a panel (to allow for tooltips on the buttons).
        self.panel = wx.Panel(self.parent)
        box.Add(self.panel, self.proportion, wx.ALL | wx.EXPAND, 0)

        # Add a sizer to the panel.
        panel_sizer = wx.BoxSizer(wx.VERTICAL)
        self.panel.SetSizer(panel_sizer)

        # A static box to hold all the widgets, and its sizer.
        self.data_box = wx.StaticBox(self.panel, -1)
        self.set_box_label()
        self.data_box.SetFont(font.subtitle)
        sub_sizer = wx.StaticBoxSizer(self.data_box, wx.VERTICAL)

        # Add the sizer to the static box and the static box to the main box.
        panel_sizer.Add(sub_sizer, self.proportion, wx.ALL | wx.EXPAND, 0)

        # Add a border.
        box_centre = add_border(sub_sizer, border=self.border)

        # Add buttons to the top.
        if self.button_placement == 'top':
            self.add_buttons(box_centre)
            box_centre.AddSpacer(self.spacing)

        # Initialise the element.
        self.init_element(box_centre)

        # Build the element.
        self.build_element()

        # Add buttons to the bottom.
        if self.button_placement == 'bottom':
            box_centre.AddSpacer(self.spacing)
            self.add_buttons(box_centre)

        # Initialise observer name.
        if self.observer_base_name:
            self.name = '%s: %s' % (self.observer_base_name, id)
        else:
            self.name = id

        # Register the element for updating when a user function completes.
        self.observer_register()
Esempio n. 19
0
    def __init__(self, parent=None, size_x=400, size_y=400, title='', border=10, style=wx.DEFAULT_DIALOG_STYLE):
        """Set up the window.

        @keyword parent:    The parent window.
        @type parent:       wx.Window instance
        @keyword size_x:    The width of the wizard.
        @type size_x:       int
        @keyword size_y:    The height of the wizard.
        @type size_y:       int
        @keyword title:     The title of the wizard dialog.
        @type title:        str
        @keyword border:    The size of the border inside the wizard.
        @type border:       int
        @keyword style:     The dialog style.
        @type style:        wx style
        """

        # Store the args.
        self._size_x = size_x
        self._size_y = size_y
        self._border = border
        self.title = title

        # Execute the base class method.
        wx.Dialog.__init__(self, parent, id=-1, title=title, style=style)

        # Set up the window icon.
        self.SetIcons(relax_icons)

        # The sizer for the dialog.
        sizer = wx.BoxSizer(wx.VERTICAL)
        self.SetSizer(sizer)

        # Build the central sizer, with borders.
        self._main_sizer = add_border(sizer, border=border, packing=wx.VERTICAL)

        # Set the default size of the dialog.
        self.SetSize((size_x, size_y))

        # Centre the dialog.
        self.Centre()

        # Initialise the page storage.
        self._current_page = 0
        self._num_pages = 0
        self._pages = []
        self._page_sizers = []
        self._button_sizers = []
        self._top_sizers = []
        self._button_apply_flag = []
        self._button_skip_flag = []
        self._buttons = []
        self._button_ids = []
        self._exec_on_next = []
        self._exec_count = []
        self._proceed_on_error = []
        self._uf_flush = []
        self._seq_fn_list = []
        self._seq_next = []
        self._seq_prev = []
        self._skip_flag = []

        # Flag to suppress later button addition.
        self._buttons_built = False

        # Bind some events.
        self.Bind(wx.EVT_CLOSE, self._handler_close)

        # ESC to exit, via an accelerator table which creates menu events.
        self.acc_list = [(wx.ACCEL_NORMAL, wx.WXK_ESCAPE, ESC_ID)]
        self.acc_table = wx.AcceleratorTable(self.acc_list)
        self.SetAcceleratorTable(self.acc_table)
        self.Bind(wx.EVT_MENU, self._handler_escape, id=ESC_ID)
Esempio n. 20
0
    def __init__(self,
                 parent=None,
                 size_x=400,
                 size_y=400,
                 title='',
                 border=10,
                 style=wx.DEFAULT_DIALOG_STYLE):
        """Set up the window.

        @keyword parent:    The parent window.
        @type parent:       wx.Window instance
        @keyword size_x:    The width of the wizard.
        @type size_x:       int
        @keyword size_y:    The height of the wizard.
        @type size_y:       int
        @keyword title:     The title of the wizard dialog.
        @type title:        str
        @keyword border:    The size of the border inside the wizard.
        @type border:       int
        @keyword style:     The dialog style.
        @type style:        wx style
        """

        # Store the args.
        self._size_x = size_x
        self._size_y = size_y
        self._border = border
        self.title = title

        # Execute the base class method.
        wx.Dialog.__init__(self, parent, id=-1, title=title, style=style)

        # Set up the window icon.
        self.SetIcons(Relax_icons())

        # The sizer for the dialog.
        sizer = wx.BoxSizer(wx.VERTICAL)
        self.SetSizer(sizer)

        # Build the central sizer, with borders.
        self._main_sizer = add_border(sizer,
                                      border=border,
                                      packing=wx.VERTICAL)

        # Set the default size of the dialog.
        self.SetSize((size_x, size_y))

        # Centre the dialog.
        self.Centre()

        # Initialise the page storage.
        self._current_page = 0
        self._num_pages = 0
        self._pages = []
        self._page_sizers = []
        self._button_sizers = []
        self._top_sizers = []
        self._button_apply_flag = []
        self._button_skip_flag = []
        self._buttons = []
        self._button_ids = []
        self._exec_on_next = []
        self._exec_count = []
        self._proceed_on_error = []
        self._uf_flush = []
        self._seq_fn_list = []
        self._seq_next = []
        self._seq_prev = []
        self._skip_flag = []

        # Flag to suppress later button addition.
        self._buttons_built = False

        # Bind some events.
        self.Bind(wx.EVT_CLOSE, self._handler_close)

        # ESC to exit, via an accelerator table which creates menu events.
        self.acc_list = [(wx.ACCEL_NORMAL, wx.WXK_ESCAPE, ESC_ID)]
        self.acc_table = wx.AcceleratorTable(self.acc_list)
        self.SetAcceleratorTable(self.acc_table)
        self.Bind(wx.EVT_MENU, self._handler_escape, id=ESC_ID)
Esempio n. 21
0
    def __init__(self, models, params, desc, size=None, border=None):
        """Set up the model selector window.

        @param models:      The list of models.
        @type models:       list of str
        @param params:      The list of parameters corresponding to the models.
        @type params:       list of str
        @param desc:        The description for each model.
        @type desc:         list of str
        @keyword size:      The initial size of the window.
        @type size:         wx.Size instance
        @keyword border:    The border width, in pixels.
        @type border:       int
        """

        # Set up the dialog.
        wx.Dialog.__init__(self,
                           None,
                           id=-1,
                           title="Model list selector",
                           size=size,
                           style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER)

        # Initialise some values
        desc_flag = False
        if len(desc):
            desc_flag = True

        # Set the frame properties.
        self.SetFont(font.normal)

        # The main sizer.
        main_sizer = wx.BoxSizer(wx.VERTICAL)

        # Pack the sizer into the frame.
        self.SetSizer(main_sizer)

        # Build the central sizer, with borders.
        sizer = add_border(main_sizer, border=border, packing=wx.VERTICAL)

        # A scrolled panel for the text.
        panel = scrolledpanel.ScrolledPanel(self, -1)
        panel.SetAutoLayout(1)
        panel.SetupScrolling()
        sizer.Add(panel, 1, wx.ALL | wx.EXPAND, 0)

        # A sizer for the panel.
        panel_sizer = wx.BoxSizer(wx.HORIZONTAL)
        panel.SetSizer(panel_sizer)

        # Add a list control.
        cols = 2
        if desc_flag:
            cols += 1
        self.grid_sizer = wx.FlexGridSizer(len(models) + 2, cols, 3, 30)

        # The headers (and then a space).
        titles = ["Model", "Parameters"]
        if desc_flag:
            titles.append("Description")
        for title in titles:
            text = wx.StaticText(panel, -1, str_to_gui(title))
            text.SetFont(font.subtitle)
            self.grid_sizer.Add(text, 0, wx.ALIGN_CENTER_VERTICAL)
        for i in range(len(titles)):
            self.grid_sizer.Add(wx.StaticText(panel, -1, ""))

        # Add the models and parameters.
        self.model_selection = []
        for i in range(len(models)):
            # No model - i.e. a separator.
            if models[i] == None:
                for i in range(len(titles)):
                    self.grid_sizer.Add(wx.StaticText(panel, -1, ""))
                continue

            # Create a checkbox for the model.
            check_box = wx.CheckBox(panel, -1, str_to_gui(models[i]))
            self.model_selection.append(check_box)
            self.grid_sizer.Add(check_box, 0, wx.ALIGN_CENTER_VERTICAL)

            # Set all selections to True.
            self.model_selection[-1].SetValue(True)

            # Add the parameter text.
            text = wx.StaticText(panel, -1, str_to_gui(params[i]))
            text.SetFont(font.normal)
            self.grid_sizer.Add(text, 0, wx.ALIGN_CENTER_VERTICAL)

            # Add the description.
            if desc_flag:
                text = wx.StaticText(panel, -1, str_to_gui(desc[i]))
                text.SetFont(font.normal)
                self.grid_sizer.Add(text, 0, wx.ALIGN_CENTER_VERTICAL)

        # Add the table to the sizer.
        panel_sizer.Add(self.grid_sizer, 1, wx.ALL | wx.EXPAND, 0)

        # Set up the window.
        self.SetMinSize(wx.Size(600, 300))
        self.Centre()
Esempio n. 22
0
    def __init__(self, parent=None, name='', seq_type='list', value_type='str', dim=None, titles=None):
        """Set up the string list editor window.

        @keyword parent:        The parent GUI element.
        @type parent:           wx.Window instance or None
        @keyword name:          The name of the window.
        @type name:             str
        @keyword seq_type:      The type of Python sequence.  This should be one of 'list' or 'tuple'.
        @type seq_type:         str
        @keyword value_type:    The type of Python data expected in the sequence.  This should be one of 'float', 'int', or 'str'.
        @type value_type:       str
        @keyword dim:           The fixed dimension that the sequence must conform to.
        @type dim:              int or None
        @keyword titles:        The titles of each of the elements of the fixed dimension elements.
        @type titles:           list of str
        """

        # Store the args.
        self.name = name
        self.seq_type = seq_type
        self.value_type = value_type
        self.dim = dim
        self.titles = titles

        # The base types.
        if value_type in ['float', 'num']:
            self.convert_from_gui = gui_to_float
            self.convert_to_gui =   float_to_gui
        elif value_type == 'int':
            self.convert_from_gui = gui_to_int
            self.convert_to_gui =   int_to_gui
        elif value_type == 'str':
            self.convert_from_gui = gui_to_str
            self.convert_to_gui =   str_to_gui
        else:
            raise RelaxError("Unknown base data type '%s'." % value_type)

        # Variable length.
        if not hasattr(self, 'variable_length'):
            self.variable_length = False
            self.offset = 0
            if dim == None:
                self.variable_length = True
                self.offset = 1

        # The title of the dialog.
        title = "Edit the %s values." % name

        # Set up the dialog.
        wx.Dialog.__init__(self, parent, id=-1, title=title)

        # Initialise some values
        self.width = self.SIZE[0] - 2*self.BORDER

        # Set the frame properties.
        self.SetSize(self.SIZE)
        self.Centre()
        self.SetFont(font.normal)

        # The main box sizer.
        main_sizer = wx.BoxSizer(wx.VERTICAL)

        # Pack the sizer into the frame.
        self.SetSizer(main_sizer)

        # Build the central sizer, with borders.
        sizer = add_border(main_sizer, border=self.BORDER, packing=wx.VERTICAL)

        # Add the list control.
        self.add_list(sizer)

        # Some spacing.
        sizer.AddSpacer(self.BORDER)

        # Add the bottom buttons.
        self.add_buttons(sizer)

        # Initialise the list of elements to a single element.
        if not self.sequence.GetItemCount():
            self.add_element()
Esempio n. 23
0
    def __init__(self, gui=None, parent=None, box=None, id=None, proportion=0, button_placement="default"):
        """Build the base list GUI element.

        @keyword gui:               The main GUI object.
        @type gui:                  wx.Frame instance
        @keyword parent:            The parent GUI element that this is to be attached to.
        @type parent:               wx object
        @keyword box:               The box sizer to pack this GUI component into.
        @type box:                  wx.BoxSizer instance
        @keyword id:                A unique identification string.  This is used to register the update method with the GUI user function observer object.
        @type id:                   str
        @keyword proportion:        The window proportion parameter.
        @type proportion:           bool
        @keyword button_placement:  Override the button visibility and placement.  The value of 'default' will leave the buttons at the default setting.  The value of 'top' will place the buttons at the top, 'bottom' will place them at the bottom, and None will turn off the buttons.
        @type button_placement:     str or None
        """

        # Store the arguments.
        self.gui = gui
        self.parent = parent
        self.proportion = proportion

        # Variables to be overridden.
        self.title = ""
        self.spacing = 5
        self.border = 5
        self.observer_base_name = None
        self.columns = []
        self.button_placement = None
        self.button_size = (120, 40)
        self.button_spacing = 5
        self.button_info = []
        self.popup_menus = []

        # Override these base values.
        self.setup()

        # Button placement second override on initialisation.
        if button_placement != "default":
            self.button_placement = button_placement

        # First create a panel (to allow for tooltips on the buttons).
        self.panel = wx.Panel(self.parent)
        box.Add(self.panel, self.proportion, wx.ALL | wx.EXPAND, 0)

        # Add a sizer to the panel.
        panel_sizer = wx.BoxSizer(wx.VERTICAL)
        self.panel.SetSizer(panel_sizer)

        # A static box to hold all the widgets, and its sizer.
        self.data_box = wx.StaticBox(self.panel, -1)
        self.set_box_label()
        self.data_box.SetFont(font.subtitle)
        sub_sizer = wx.StaticBoxSizer(self.data_box, wx.VERTICAL)

        # Add the sizer to the static box and the static box to the main box.
        panel_sizer.Add(sub_sizer, self.proportion, wx.ALL | wx.EXPAND, 0)

        # Add a border.
        box_centre = add_border(sub_sizer, border=self.border)

        # Add buttons to the top.
        if self.button_placement == "top":
            self.add_buttons(box_centre)
            box_centre.AddSpacer(self.spacing)

        # Initialise the element.
        self.init_element(box_centre)

        # Build the element.
        self.build_element()

        # Add buttons to the bottom.
        if self.button_placement == "bottom":
            box_centre.AddSpacer(self.spacing)
            self.add_buttons(box_centre)

        # Initialise observer name.
        if self.observer_base_name:
            self.name = "%s: %s" % (self.observer_base_name, id)
        else:
            self.name = id

        # Register the element for updating when a user function completes.
        self.observer_register()