mailr13788 - /branches/gui_testing/gui/analyses/__init__.py


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

Header


Content

Posted by edward on July 20, 2011 - 21:26:
Author: bugman
Date: Wed Jul 20 21:26:29 2011
New Revision: 13788

URL: http://svn.gna.org/viewcvs/relax?rev=13788&view=rev
Log:
Created page_index_from_pipe() and page_name_from_pipe() to obtain page info 
for a given data pipe.


Modified:
    branches/gui_testing/gui/analyses/__init__.py

Modified: branches/gui_testing/gui/analyses/__init__.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/gui_testing/gui/analyses/__init__.py?rev=13788&r1=13787&r2=13788&view=diff
==============================================================================
--- branches/gui_testing/gui/analyses/__init__.py (original)
+++ branches/gui_testing/gui/analyses/__init__.py Wed Jul 20 21:26:29 2011
@@ -396,18 +396,16 @@
         event.Skip()
 
 
-    def pipe_switch(self, pipe=None):
-        """Switch the page to the given or current data pipe.
-
-        @keyword pipe:  The pipe associated with the page to switch to.  If 
not supplied, the current data pipe will be used.
-        @type pipe:     str or None
-        """
-
-        # The data pipe.
-        if pipe == None:
-            pipe = pipes.cdp_name()
-
-        # Find the page.
+    def page_index_from_pipe(self, pipe):
+        """Find the page holding the data pipe and return its page index.
+
+        @param pipe:    The data pipe to find the page of.
+        @type pipe:     str
+        @return:        The page index.
+        @rtype:         int or None
+        """
+
+        # Find the index.
         index = None
         for i in range(self._num_analyses):
             # Matching page.
@@ -415,16 +413,54 @@
                 index = i
                 break
 
+        # Return the index.
+        return index
+
+
+    def page_name_from_pipe(self, pipe):
+        """Find the page holding the data pipe and return its name.
+
+        @param pipe:    The data pipe to find the page of.
+        @type pipe:     str
+        @return:        The page name.
+        @rtype:         str or None
+        """
+
+        # Find the index.
+        index = self.page_index_from_pipe(pipe)
+
         # No matching page.
         if index == None:
             return
 
+        # Return the page name.
+        return ds.relax_gui.analyses[index].analysis_name
+
+
+    def pipe_switch(self, pipe=None):
+        """Switch the page to the given or current data pipe.
+
+        @keyword pipe:  The pipe associated with the page to switch to.  If 
not supplied, the current data pipe will be used.
+        @type pipe:     str or None
+        """
+
+        # The data pipe.
+        if pipe == None:
+            pipe = pipes.cdp_name()
+
+        # Find the page.
+        index = self.page_index_from_pipe(pipe)
+
+        # No matching page.
+        if index == None:
+            return
+
         # The page is already active, so do nothing.
-        if self._current == i:
+        if self._current == index:
             return
 
         # Switch to the page.
-        self.switch_page(i)
+        self.switch_page(index)
 
 
     def reset(self):




Related Messages


Powered by MHonArc, Updated Wed Jul 20 21:40:02 2011