Package gui
[hide private]
[frames] | no frames]

Source Code for Package gui

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 2009-2012 Edward d'Auvergne                                   # 
  4  #                                                                             # 
  5  # This file is part of the program relax (http://www.nmr-relax.com).          # 
  6  #                                                                             # 
  7  # This program is free software: you can redistribute it and/or modify        # 
  8  # it under the terms of the GNU General Public License as published by        # 
  9  # the Free Software Foundation, either version 3 of the License, or           # 
 10  # (at your option) any later version.                                         # 
 11  #                                                                             # 
 12  # This program is distributed in the hope that it will be useful,             # 
 13  # but WITHOUT ANY WARRANTY; without even the implied warranty of              # 
 14  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               # 
 15  # GNU General Public License for more details.                                # 
 16  #                                                                             # 
 17  # You should have received a copy of the GNU General Public License           # 
 18  # along with this program.  If not, see <http://www.gnu.org/licenses/>.       # 
 19  #                                                                             # 
 20  ############################################################################### 
 21   
 22  # Package docstring. 
 23  """Package for the Bieri GUI interface for relax. 
 24   
 25  This GUI was announced in the post at U{https://web.archive.org/web/https://mail.gna.org/public/relax-devel/2009-11/msg00005.html}. 
 26  """ 
 27   
 28  # Deps. 
 29  import dep_check 
 30   
 31  # Python module imports. 
 32  import sys 
 33  from time import sleep 
 34  if dep_check.wx_module: 
 35      import wx 
 36   
 37  # relax module imports. 
 38  from graphics import IMAGE_PATH 
 39  from gui.uf_objects import Uf_storage; uf_store = Uf_storage() 
 40  from lib.errors import RelaxError 
 41  import pipe_control 
 42  from status import Status; status = Status() 
 43   
 44   
 45  __all__ = ['about', 
 46             'base_classes', 
 47             'controller', 
 48             'derived_wx_classes', 
 49             'errors', 
 50             'filedialog', 
 51             'fonts', 
 52             'icons', 
 53             'interpreter', 
 54             'menu', 
 55             'message', 
 56             'misc', 
 57             'paths', 
 58             'pipe_editor', 
 59             'references', 
 60             'relax_gui', 
 61             'relax_prompt', 
 62             'settings', 
 63             'wizard'] 
 64   
 65   
 66   
67 -class App(wx.App):
68 """The relax GUI wx application.""" 69
70 - def __init__(self, script_file=None, redirect=False, filename=None, useBestVisual=False, clearSigInt=True):
71 """Initialise the wx.App. 72 73 @keyword redirect: Should sys.stdout and sys.stderr be redirected? Defaults to True on Windows and Mac, False otherwise. If filename is None then output will be redirected to a window that pops up as needed. (You can control what kind of window is created for the output by resetting the class variable outputWindowClass to a class of your choosing.) 74 @type redirect: bool 75 @keyword filename: The name of a file to redirect output to, if redirect is True. 76 @type filename: file object 77 @keyword useBestVisual: Should the app try to use the best available visual provided by the system (only relevant on systems that have more than one visual.) This parameter must be used instead of calling SetUseBestVisual later on because it must be set before the underlying GUI toolkit is initialized. 78 @type useBestVisual: bool 79 @keyword clearSigInt: Should SIGINT be cleared? This allows the app to terminate upon a Ctrl-C in the console like other GUI apps will. 80 @type clearSigInt: bool 81 @keyword script_file: The path of a relax script to execute. 82 @type script_file: str 83 """ 84 85 # First run the script before the GUI is built. 86 if script_file: 87 pipe_control.script.script(script_file) 88 89 # Execute the base class method. 90 super(App, self).__init__(redirect=redirect, filename=filename, useBestVisual=useBestVisual, clearSigInt=clearSigInt)
91 92
93 - def OnInit(self):
94 """Build the application, showing a splash screen first.""" 95 96 # Import here to break a circular import which is killing Epydoc! 97 from gui import relax_gui 98 99 # Build the GUI. 100 self.gui = relax_gui.Main(parent=None, id=-1, title="") 101 102 # Make it the main application component. 103 self.SetTopWindow(self.gui) 104 105 # Only show the GUI if requested. 106 if status.show_gui: 107 # Wait a little while :) 108 sleep(1) 109 110 # Show it. 111 self.gui.Show() 112 113 # Show the splash screen. 114 self.show_splash() 115 116 # All is good! 117 return True
118 119
120 - def show_splash(self):
121 """Build and show the splash screen.""" 122 123 # The image. 124 bmp = wx.Bitmap(IMAGE_PATH+'relaxGUI_splash.png', wx.BITMAP_TYPE_ANY) 125 126 # The timeout (ms). 127 timeout = 2500 128 129 # The splash screen. 130 screen = wx.SplashScreen(bmp, wx.SPLASH_CENTRE_ON_PARENT | wx.SPLASH_TIMEOUT, timeout, None, -1)
131