def setup_frame(self): """Set up the relax controller frame. @return: The sizer object. @rtype: wx.Sizer instance """ # Set the frame title. self.SetTitle("The relax controller") # 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 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 (hide so it can be reopened). self.Bind(wx.EVT_CLOSE, self.handler_close) # Set the default size of the controller. self.SetSize((self.size_x, self.size_y)) # Centre the frame. self.Centre() # Return the central sizer. return sizer
def __init__(self, parent): """Build the window. @param parent: The parent wx object. @type parent: wx object """ # Init the base class. super(References, self).__init__(parent, -1, "relax references", style=wx.DEFAULT_FRAME_STYLE) # Set up the window icon. self.SetIcons(Relax_icons()) # Set an initial window size. self.SetSize((800, 800)) # Add a sizer box. box = wx.BoxSizer(wx.VERTICAL) self.SetSizer(box) # The HTML window. self.html = RefWindow(self, -1, size=(500, -1)) box.Add(self.html, 1, wx.GROW) # Centre the window. self.Centre() # Show the front page. self.front_page()
def __init__(self, *args, **kwds): """Set up the relax prompt.""" # Store the parent object. self.gui = kwds.pop('parent') # Create GUI elements kwds["style"] = wx.DEFAULT_FRAME_STYLE wx.Frame.__init__(self, *args, **kwds) # Set up the window icon. self.SetIcons(Relax_icons()) # Some default values. self.size_x = 1000 self.size_y = 500 self.border = 0 # Set up the frame. sizer = self.setup_frame() # The shell. self.add_shell(sizer) # Register functions with the observer objects. status.observers.exec_lock.register('GUI prompt', self.enable, method_name='enable')
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()
def __init__(self, parent=None, id=-1, title='', html_text=None): """Build the dialog.""" # Execute the base class __init__() method. super(About_base, self).__init__(parent=parent, id=id, title=title, style=self.style) # Set up the window icon. self.SetIcons(Relax_icons()) # Create a scrolled window. self.window = wx.ScrolledWindow(self, -1) # Initialise the y-offset variable. self._offset_val = 0 # The starting cursor type. self.cursor_type = 'normal' # Initialise URL data structures. self.url_text = [] self.url_pos = [] # Determine the virtual size of the window. self.text_max_x = 0 self.virtual_size() # Set the window size. self.SetSize((self.virt_x, self.dim_y)) # Add y scrolling, if needed. self.window.SetScrollRate(0, self.SCROLL_RATE) # Create the buffered device context twice (to determine the real virtual size!). self.create_buffered_dc() self.create_buffered_dc() # Add HTML content. if html_text: self.add_html(html_text) # Draw everything. self.window.Bind(wx.EVT_PAINT, self.generate) # Let the dialog be closable with a left button click. self.window.Bind(wx.EVT_MOTION, self.cursor_style) # Let the dialog be closable with a left button click. self.window.Bind(wx.EVT_LEFT_DOWN, self.process_click) # Center Window if status.show_gui: self.Centre()
def __init__(self, parent=None): """Set up the window.""" # Execute the base __init__() method. wx.Dialog.__init__(self, parent, id=-1, title="Free file format", style=wx.DEFAULT_FRAME_STYLE) # The sizes. self._main_size = self.SIZE[0] - 2 * self.BORDER self._div_left = self._main_size / 2 # Set up the window icon. self.SetIcons(Relax_icons()) # The main sizer. self.main_sizer = self.build_frame() # The heading. text = wx.StaticText(self, -1, "Settings for the free file format") text.SetFont(wx.Font(12, wx.DEFAULT, wx.NORMAL, wx.BOLD, 0, "")) self.main_sizer.Add(text, 0, wx.ALIGN_CENTER_HORIZONTAL, 5) self.main_sizer.AddStretchSpacer() # The relax logo. bmp = wx.StaticBitmap(self, -1, bitmap_setup(IMAGE_PATH + 'relax.gif')) self.main_sizer.Add(bmp, 0, wx.ALIGN_CENTER_HORIZONTAL, 5) self.main_sizer.AddStretchSpacer() # The centre section. self.add_centre(self.main_sizer) # The bottom buttons. self.add_buttons(self.main_sizer) # Set the window size. self.SetSize(self.SIZE) self.SetMinSize(self.SIZE) # Centre the window. self.Center()
def __init__(self, *args, **kwds): """Set up the relax prompt.""" # Store the parent object. self.gui = kwds.pop('parent') # Create GUI elements kwds["style"] = wx.DEFAULT_FRAME_STYLE if not status.debug and status.wx_info["os"] != 'darwin': kwds["style"] = kwds["style"] | wx.MAXIMIZE wx.Frame.__init__(self, *args, **kwds) # Force the main window to start maximised (needed for MS Windows). if not status.debug and status.wx_info["os"] != 'darwin': self.Maximize() # Set up the window icon. self.SetIcons(Relax_icons()) # Some default values. self.size_x = 1000 self.size_y = 750 # Set up the window. sizer = self.setup_window() # Create a menu. self._create_menu() # Build the toolbar. self.toolbar() # The splitter window. splitter = Tree_splitter(self.gui, self, -1) sizer.Add(splitter, 1, wx.EXPAND | wx.ALL, 0) # Initialise observer name. self.name = 'spin viewer'
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)
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'
def __init__(self, missing=[], parent=None): """Set up the dialog. @keyword missing: The list of missing data types. @type missing: list of str @keyword parent: The parent wx element. @type parent: wx object """ # Initialise the base class. wx.Dialog.__init__(self, parent, title='Missing data', style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER | wx.STAY_ON_TOP) # Set up the window icon. self.SetIcons(Relax_icons()) # Set the initial size. self.SetSize((600, 400)) # Centre the window. self.Centre() # A sizer for the dialog. main_sizer = wx.BoxSizer(wx.HORIZONTAL) self.SetSizer(main_sizer) # Build the central sizer, with borders. sizer = gui.misc.add_border(main_sizer, border=10, packing=wx.HORIZONTAL) # Add the graphic. bitmap = wx.StaticBitmap( self, -1, bitmap_setup(fetch_icon('oxygen.status.user-busy', "48x48"))) sizer.Add(bitmap) # Spacing. sizer.AddSpacer(20) # A scrolled panel for the text. panel = wx.lib.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) # The message. msg = "The set up is incomplete.\n\n" if not len(missing): msg = msg + "Please check for missing data.\n" else: msg = msg + "Please check for the following missing information:\n" for data in missing: msg = msg + " %s\n" % data # Convert to a text element. text = wx.StaticText(panel, -1, msg, style=wx.TE_MULTILINE) panel_sizer.Add(text) # Show the GUI element. if status.show_gui: self.ShowModal() # Otherwise throw the error out to stderr. else: sys.stderr.write("Missing data: %s\n" % msg) sys.stderr.flush()
def __init__(self, msg, parent=None, title='', size=(350, 125), default=False): """A generic question box. @param msg: The text message to display. @type msg: str @keyword parent: The parent wx object. @type parent: wx.object instance @keyword title: The window title. @type title: str @keyword default: If True, the default button will be 'yes', otherwise it will be 'no'. @type default: bool @return: The answer. @rtype: bool """ # Initialise the base class. wx.Dialog.__init__(self, parent, title=title, size=size, style=wx.DEFAULT_DIALOG_STYLE | wx.STAY_ON_TOP) # Flag to indicate that a button was pressed. self.pressed = False # The default. if default: self.answer = wx.ID_YES else: self.answer = wx.ID_NO # Set up the window icon. self.SetIcons(Relax_icons()) # Centre the window. self.Centre() # A sizer for the dialog. main_sizer = wx.BoxSizer(wx.HORIZONTAL) self.SetSizer(main_sizer) # Build the central sizer, with borders. sizer = gui.misc.add_border(main_sizer, border=self.border, packing=wx.HORIZONTAL) # Add the graphic. bitmap = wx.StaticBitmap( self, -1, bitmap_setup( fetch_icon('oxygen.status.dialog-warning-relax-blue', "48x48"))) sizer.Add(bitmap) # Spacing. sizer.AddSpacer(self.spacer_main) # A vertical sizer for the right hand contents. sub_sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(sub_sizer, 1, wx.ALL | wx.EXPAND, 0) # Convert to a text element. text = wx.StaticText(self, -1, msg, style=wx.TE_MULTILINE) text.SetFont(font.normal) sub_sizer.Add(text, 1, wx.ALL | wx.EXPAND, 0) # A sizer for the buttons. button_sizer = wx.BoxSizer(wx.HORIZONTAL) sub_sizer.Add(button_sizer, 0, wx.ALIGN_RIGHT, 0) # The yes button. button_yes = wx.lib.buttons.ThemedGenBitmapTextButton( self, -1, None, " Yes") button_yes.SetBitmapLabel( wx.Bitmap(fetch_icon('oxygen.actions.dialog-ok', "22x22"), wx.BITMAP_TYPE_ANY)) button_yes.SetFont(font.normal) button_yes.SetMinSize((self.width_button, self.height_button)) button_sizer.Add(button_yes, 0, wx.ADJUST_MINSIZE | wx.ALIGN_CENTER_VERTICAL, 0) self.Bind(wx.EVT_BUTTON, self.yes, button_yes) # Button spacing. button_sizer.AddSpacer(self.spacer_button) # The no button. button_no = wx.lib.buttons.ThemedGenBitmapTextButton( self, -1, None, " No") button_no.SetBitmapLabel( wx.Bitmap(fetch_icon('oxygen.actions.dialog-cancel', "22x22"), wx.BITMAP_TYPE_ANY)) button_no.SetFont(font.normal) button_no.SetMinSize((self.width_button, self.height_button)) button_sizer.Add(button_no, 0, wx.ADJUST_MINSIZE | wx.ALIGN_CENTER_VERTICAL, 0) self.Bind(wx.EVT_BUTTON, self.no, button_no) # Set the focus to the default button. if self.answer == wx.ID_YES: button_yes.SetFocus() else: button_no.SetFocus() # Bind some events. self.Bind(wx.EVT_CLOSE, self.handler_close)