mailr14587 - in /1.3/gui: misc.py results_viewer.py


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

Header


Content

Posted by edward on September 05, 2011 - 18:03:
Author: bugman
Date: Mon Sep  5 18:03:43 2011
New Revision: 14587

URL: http://svn.gna.org/viewcvs/relax?rev=14587&view=rev
Log:
Text files in the results viewer window are now opened with a text editor on 
Mac OS X and MS Windows.

On a Mac, the text file of NOE values was being opened up in 'Saturn', as the 
file ending '*.out' is
associated with that program.


Modified:
    1.3/gui/misc.py
    1.3/gui/results_viewer.py

Modified: 1.3/gui/misc.py
URL: 
http://svn.gna.org/viewcvs/relax/1.3/gui/misc.py?rev=14587&r1=14586&r2=14587&view=diff
==============================================================================
--- 1.3/gui/misc.py (original)
+++ 1.3/gui/misc.py Mon Sep  5 18:03:43 2011
@@ -322,20 +322,34 @@
     return unicode(list)
 
 
-def open_file(file):
+def open_file(file, force_text=False):
     """Open the file in the platform's native editor/viewer.
 
-    @param file:    The path of the file to open.
-    @type file:     str
+    @param file:            The path of the file to open.
+    @type file:             str
+    @keyword force_text:    A flag which if True will cause a text editor to 
be launched.
+    @type force_text:       bool
     """
 
     # Windows.
     if platform.uname()[0] in ['Windows', 'Microsoft']:
-        os.startfile(file)
+        # Text file.
+        if force_text:
+            os.system('notepad %s' % os.path.normpath(file))
+
+        # All other files.
+        else:
+            os.startfile(os.path.normpath(file))
 
     # Mac OS X.
     elif platform.uname()[0] == 'Darwin':
-        os.system('open %s' % file)
+        # Text file.
+        if force_text:
+            os.system('open -t %s' % file)
+
+        # All other files.
+        else:
+            os.system('open %s' % file)
 
     # POSIX Systems with xdg-open.
     else:

Modified: 1.3/gui/results_viewer.py
URL: 
http://svn.gna.org/viewcvs/relax/1.3/gui/results_viewer.py?rev=14587&r1=14586&r2=14587&view=diff
==============================================================================
--- 1.3/gui/results_viewer.py (original)
+++ 1.3/gui/results_viewer.py Mon Sep  5 18:03:43 2011
@@ -263,6 +263,10 @@
                 # The data.
                 model_result = [ds.relax_gui.table_residue, 
ds.relax_gui.table_model, ds.relax_gui.table_s2, ds.relax_gui.table_rex, 
ds.relax_gui.table_te]
 
+            # Text files.
+            elif type == 'text':
+                open_file(file, force_text=True)
+
             # Open all other files in which ever editor the platform decides 
on.
             else:
                 open_file(file)




Related Messages


Powered by MHonArc, Updated Mon Sep 05 18:20:02 2011