"Fossies" - the Fresh Open Source Software Archive

Member "relax-5.0.0/gui/__init__.py" (2 Dec 2019, 5555 Bytes) of package /linux/privat/relax-5.0.0.src.tar.bz2:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Python source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. For more information about "__init__.py" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 4.1.3_vs_5.0.0.

    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     if not dep_check.wx_classic:
   37         import wx.adv
   38 
   39 # relax module imports.
   40 from graphics import IMAGE_PATH
   41 from gui.uf_objects import Uf_storage; uf_store = Uf_storage()
   42 from lib.errors import RelaxError
   43 import pipe_control
   44 from status import Status; status = Status()
   45 
   46 
   47 __all__ = ['about',
   48            'base_classes',
   49            'controller',
   50            'derived_wx_classes',
   51            'errors',
   52            'filedialog',
   53            'fonts',
   54            'icons',
   55            'interpreter',
   56            'menu',
   57            'message',
   58            'misc',
   59            'paths',
   60            'pipe_editor',
   61            'references',
   62            'relax_gui',
   63            'relax_prompt',
   64            'settings',
   65            'wizard']
   66 
   67 
   68 
   69 class App(wx.App):
   70     """The relax GUI wx application."""
   71 
   72     def __init__(self, script_file=None, redirect=False, filename=None, useBestVisual=False, clearSigInt=True):
   73         """Initialise the wx.App.
   74 
   75         @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.)
   76         @type redirect:         bool
   77         @keyword filename:      The name of a file to redirect output to, if redirect is True.
   78         @type filename:         file object
   79         @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.
   80         @type useBestVisual:    bool
   81         @keyword clearSigInt:   Should SIGINT be cleared? This allows the app to terminate upon a Ctrl-C in the console like other GUI apps will.
   82         @type clearSigInt:      bool
   83         @keyword script_file:   The path of a relax script to execute.
   84         @type script_file:      str
   85         """
   86 
   87         # First run the script before the GUI is built.
   88         if script_file:
   89             pipe_control.script.script(script_file)
   90 
   91         # Execute the base class method.
   92         super(App, self).__init__(redirect=redirect, filename=filename, useBestVisual=useBestVisual, clearSigInt=clearSigInt)
   93 
   94 
   95     def OnInit(self):
   96         """Build the application, showing a splash screen first."""
   97 
   98         # Import here to break a circular import which is killing Epydoc!
   99         from gui import relax_gui
  100 
  101         # Build the GUI.
  102         self.gui = relax_gui.Main(parent=None, id=-1, title="")
  103 
  104         # Make it the main application component.
  105         self.SetTopWindow(self.gui)
  106 
  107         # Only show the GUI if requested.
  108         if status.show_gui:
  109             # Wait a little while :)
  110             sleep(1)
  111 
  112             # Show it.
  113             self.gui.Show()
  114 
  115         # Show the splash screen.
  116         self.show_splash()
  117 
  118         # All is good!
  119         return True
  120 
  121 
  122     def show_splash(self):
  123         """Build and show the splash screen."""
  124 
  125         # The image.
  126         bmp = wx.Bitmap(IMAGE_PATH+'relaxGUI_splash.png', wx.BITMAP_TYPE_ANY)
  127 
  128         # The timeout (ms).
  129         timeout = 2500
  130 
  131         # The splash screen.
  132         if dep_check.wx_classic:
  133             screen = wx.SplashScreen(bmp, wx.SPLASH_CENTRE_ON_PARENT | wx.SPLASH_TIMEOUT, timeout, None, -1)
  134         else:
  135             screen = wx.adv.SplashScreen(bmp, wx.adv.SPLASH_CENTRE_ON_PARENT | wx.adv.SPLASH_TIMEOUT, timeout, None, -1)