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

Source Code for Package gui

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 2009-2011 Edward d'Auvergne                                   # 
  4  #                                                                             # 
  5  # This file is part of the program relax.                                     # 
  6  #                                                                             # 
  7  # relax 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 2 of the License, or           # 
 10  # (at your option) any later version.                                         # 
 11  #                                                                             # 
 12  # relax 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 relax; if not, write to the Free Software                        # 
 19  # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA   # 
 20  #                                                                             # 
 21  ############################################################################### 
 22   
 23  # Package docstring. 
 24  """Package for the Bieri GUI interface for relax. 
 25   
 26  This GUI was announced in the post at http://www.nmr-relax.com/mail.gna.org/public/relax-devel/2009-11/msg00005.html. 
 27  """ 
 28   
 29  # Deps. 
 30  import dep_check 
 31   
 32  # Python module imports. 
 33  import sys 
 34  from time import sleep 
 35  if dep_check.wx_module: 
 36      import wx 
 37   
 38  # relax module imports. 
 39  from generic_fns.script import script 
 40  from graphics import IMAGE_PATH 
 41  from relax_errors import RelaxError 
 42  from relax_gui import Main 
 43  from status import Status; status = Status() 
 44   
 45  # relax GUI module imports. 
 46  from gui.uf_objects import Uf_storage; uf_store = Uf_storage() 
 47   
 48   
 49  __all__ = ['about', 
 50             'base_classes', 
 51             'controller', 
 52             'derived_wx_classes', 
 53             'errors', 
 54             'filedialog', 
 55             'fonts', 
 56             'icons', 
 57             'interpreter', 
 58             'menu', 
 59             'message', 
 60             'misc', 
 61             'paths', 
 62             'pipe_editor', 
 63             'references', 
 64             'relax_gui', 
 65             'relax_prompt', 
 66             'settings', 
 67             'wizard'] 
 68   
 69   
 70   
71 -class App(wx.App):
72 """The relax GUI wx application.""" 73
74 - def __init__(self, script_file=None, redirect=False, filename=None, useBestVisual=False, clearSigInt=True):
75 """Initialise the wx.App. 76 77 @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.) 78 @type redirect: bool 79 @keyword filename: The name of a file to redirect output to, if redirect is True. 80 @type filename: file object 81 @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. 82 @type useBestVisual: bool 83 @keyword clearSigInt: Should SIGINT be cleared? This allows the app to terminate upon a Ctrl-C in the console like other GUI apps will. 84 @type clearSigInt: bool 85 @keyword script_file: The path of a relax script to execute. 86 @type script_file: str 87 """ 88 89 # First run the script before the GUI is built. 90 if script_file: 91 script(script_file) 92 93 # Execute the base class method. 94 super(App, self).__init__(redirect=redirect, filename=filename, useBestVisual=useBestVisual, clearSigInt=clearSigInt)
95 96
97 - def OnInit(self):
98 """Build the application, showing a splash screen first.""" 99 100 # Show the splash screen. 101 self.show_splash() 102 103 # Build the GUI. 104 self.gui = Main(parent=None, id=-1, title="") 105 106 # Make it the main application component. 107 self.SetTopWindow(self.gui) 108 109 # Only show the GUI if requested. 110 if status.show_gui: 111 # Wait a little while :) 112 sleep(1) 113 114 # Show it. 115 self.gui.Show() 116 117 # All is good! 118 return True
119 120
121 - def show_splash(self):
122 """Build and show the splash screen.""" 123 124 # The image. 125 bmp = wx.Bitmap(IMAGE_PATH+'relaxGUI_splash.png', wx.BITMAP_TYPE_ANY) 126 127 # The timeout (ms). 128 timeout = 2500 129 130 # The splash screen. 131 screen = wx.SplashScreen(bmp, wx.SPLASH_CENTRE_ON_SCREEN | wx.SPLASH_TIMEOUT, timeout, None, -1)
132