1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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
30 import dep_check
31
32
33 import sys
34 from time import sleep
35 if dep_check.wx_module:
36 import wx
37
38
39 from relax_errors import RelaxError
40 from relax_gui import Main
41 from status import Status; status = Status()
42
43
44 from paths import IMAGE_PATH
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
70 """The relax GUI wx application."""
71
72 - def __init__(self, script=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: The path of a relax script to execute.
84 @type script: str
85 """
86
87
88 self.script = script
89
90
91 super(App, self).__init__(redirect=redirect, filename=filename, useBestVisual=useBestVisual, clearSigInt=clearSigInt)
92
93
94 - def OnInit(self, script_file=None):
95 """Build the application, showing a splash screen first."""
96
97
98 self.show_splash()
99
100
101 self.gui = Main(parent=None, id=-1, title="", script=self.script)
102
103
104 self.SetTopWindow(self.gui)
105
106
107 if status.show_gui:
108
109 sleep(1)
110
111
112 self.gui.Show()
113
114
115 return True
116
117
119 """Build and show the splash screen."""
120
121
122 bmp = wx.Bitmap(IMAGE_PATH+'start_no_alpha.png', wx.BITMAP_TYPE_ANY)
123
124
125 timeout = 2500
126
127
128 screen = wx.SplashScreen(bmp, wx.SPLASH_CENTRE_ON_SCREEN | wx.SPLASH_TIMEOUT, timeout, None, -1)
129