mailr11939 - in /branches/bieri_gui: gui_bieri/__init__.py gui_bieri/relax_gui.py gui_bieri/user_functions/script.py relax


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by edward on December 22, 2010 - 12:07:
Author: bugman
Date: Wed Dec 22 12:07:38 2010
New Revision: 11939

URL: http://svn.gna.org/viewcvs/relax?rev=11939&view=rev
Log:
Scripts given by the user on the command line will now be executed within the 
GUI.


Modified:
    branches/bieri_gui/gui_bieri/__init__.py
    branches/bieri_gui/gui_bieri/relax_gui.py
    branches/bieri_gui/gui_bieri/user_functions/script.py
    branches/bieri_gui/relax

Modified: branches/bieri_gui/gui_bieri/__init__.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/bieri_gui/gui_bieri/__init__.py?rev=11939&r1=11938&r2=11939&view=diff
==============================================================================
--- branches/bieri_gui/gui_bieri/__init__.py (original)
+++ branches/bieri_gui/gui_bieri/__init__.py Wed Dec 22 12:07:38 2010
@@ -62,14 +62,36 @@
 class App(wx.App):
     """The relax GUI wx application."""
 
-    def OnInit(self):
+    def __init__(self, script=None, redirect=False, filename=None, 
useBestVisual=False, clearSigInt=True):
+        """Initialise the wx.App.
+
+        @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.)
+        @type redirect:         bool
+        @keyword filename:      The name of a file to redirect output to, if 
redirect is True.
+        @type filename:         file object
+        @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.
+        @type useBestVisual:    bool
+        @keyword clearSigInt:   Should SIGINT be cleared? This allows the 
app to terminate upon a Ctrl-C in the console like other GUI apps will.
+        @type clearSigInt:      bool
+        @keyword script:        The path of a relax script to execute.
+        @type script:           str
+        """
+
+        # Store the script.
+        self.script = script
+
+        # Execute the base class method.
+        super(App, self).__init__(redirect=redirect, filename=filename, 
useBestVisual=useBestVisual, clearSigInt=clearSigInt)
+
+
+    def OnInit(self, script_file=None):
         """Build the application, showing a splash screen first."""
 
         # Show the splash screen.
         self.show_splash()
 
         # Build the GUI.
-        main = Main(parent=None, id=-1, title="")
+        main = Main(parent=None, id=-1, title="", script=self.script)
 
         # Make it the main application component.
         self.SetTopWindow(main)

Modified: branches/bieri_gui/gui_bieri/relax_gui.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/bieri_gui/gui_bieri/relax_gui.py?rev=11939&r1=11938&r2=11939&view=diff
==============================================================================
--- branches/bieri_gui/gui_bieri/relax_gui.py (original)
+++ branches/bieri_gui/gui_bieri/relax_gui.py Wed Dec 22 12:07:38 2010
@@ -76,14 +76,14 @@
     sequence_file_msg = "please insert sequence file"
     structure_file_pdb_msg = "please insert .pdb file"
 
-    def __init__(self, *args, **kwds):
+    def __init__(self, parent=None, id=-1, title="", script=None):
         """Initialise the main relax GUI frame."""
 
-        # Add the style keyword value.
-        kwds["style"] = wx.CLOSE_BOX | wx.MINIMIZE_BOX | wx.SYSTEM_MENU | 
wx.CAPTION | wx.CLIP_CHILDREN
+        # The window style.
+        style = wx.CLOSE_BOX | wx.MINIMIZE_BOX | wx.SYSTEM_MENU | wx.CAPTION 
| wx.CLIP_CHILDREN
 
         # Execute the base class __init__ method.
-        super(Main, self).__init__(*args, **kwds)
+        super(Main, self).__init__(parent=parent, id=id, title=title, 
style=style)
 
         # The analysis frame object storage.
         self.analysis_frames = []
@@ -148,6 +148,10 @@
         self.dialog_about_gui = About_gui(None, -1, "")
         self.dialog_about_relax = About_relax(None, -1, "")
 
+        # Run a script.
+        if script:
+            self.user_functions.script.script_exec(script)
+
 
     def __do_layout(self):
         # Build layout

Modified: branches/bieri_gui/gui_bieri/user_functions/script.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/bieri_gui/gui_bieri/user_functions/script.py?rev=11939&r1=11938&r2=11939&view=diff
==============================================================================
--- branches/bieri_gui/gui_bieri/user_functions/script.py (original)
+++ branches/bieri_gui/gui_bieri/user_functions/script.py Wed Dec 22 12:07:38 
2010
@@ -34,15 +34,18 @@
 class Script(UF_base):
     """The script user function GUI class."""
 
-    def run(self, event):
+    def run(self, event, file=None):
         """The script user function GUI element.
 
         @param event:   The wx event.
         @type event:    wx event
+        @param file:    The path of the script to execute, if already known. 
 If not given, a file selection dialog will appear.
+        @type file:     str
         """
 
         # User selection of the file.
-        file = openfile(msg='Select the relax script to execute', 
default='relax scripts (*.py)|*.py')
+        if not file:
+            file = openfile(msg='Select the relax script to execute', 
default='relax scripts (*.py)|*.py')
 
         # Check the file.
         if not file:

Modified: branches/bieri_gui/relax
URL: 
http://svn.gna.org/viewcvs/relax/branches/bieri_gui/relax?rev=11939&r1=11938&r2=11939&view=diff
==============================================================================
--- branches/bieri_gui/relax (original)
+++ branches/bieri_gui/relax Wed Dec 22 12:07:38 2010
@@ -135,7 +135,7 @@
                 sys.exit()
 
             # Start the relax GUI wx application.
-            app = gui_bieri.App()
+            app = gui_bieri.App(script=self.script_file)
             app.MainLoop()
 
         # Execute the relax test suite
@@ -315,16 +315,8 @@
             # Set the mode.
             mode = 'licence'
 
-        # Script mode.
-        elif self.script_file:
-            mode = 'script'
-
         # GUI.
         elif options.gui:
-            # Make sure no script is supplied.
-            if self.script_file:
-                parser.error("a script should not be supplied in test mode")
-
             # Exclusive models.
             if options.test_suite or options.system_tests or 
options.unit_tests:
                 parser.error("the relax GUI mode and testing modes are 
mutually exclusive")
@@ -338,6 +330,10 @@
             # Set the mode.
             mode = 'gui'
 
+        # Script mode.
+        elif self.script_file:
+            mode = 'script'
+
         # Prompt mode (default).
         else:
             mode = 'prompt'




Related Messages


Powered by MHonArc, Updated Wed Dec 22 12:20:02 2010