mailr13474 - in /branches/gui_testing/gui/user_functions: base.py deselect.py


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

Header


Content

Posted by edward on July 07, 2011 - 10:52:
Author: bugman
Date: Thu Jul  7 10:52:17 2011
New Revision: 13474

URL: http://svn.gna.org/viewcvs/relax?rev=13474&view=rev
Log:
Created the UF_base.get_title() method for setting wizard window titles.

The deselect.all() user function now uses this.


Modified:
    branches/gui_testing/gui/user_functions/base.py
    branches/gui_testing/gui/user_functions/deselect.py

Modified: branches/gui_testing/gui/user_functions/base.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/gui_testing/gui/user_functions/base.py?rev=13474&r1=13473&r2=13474&view=diff
==============================================================================
--- branches/gui_testing/gui/user_functions/base.py (original)
+++ branches/gui_testing/gui/user_functions/base.py Thu Jul  7 10:52:17 2011
@@ -27,6 +27,7 @@
 from prompt.base_class import _strip_lead
 
 # relax GUI imports.
+from gui.misc import str_to_gui
 from gui.wizard import Wiz_page
 
 
@@ -40,6 +41,40 @@
         self.gui = gui
         self.interpreter = interpreter
 
+
+    def get_title(self, base=None, fn=None):
+        """Get the title for the wizard window from the user function 
documentation.
+
+        @keyword base:  The name of the user function base class, if it 
exists.
+        @type base:     str
+        @keyword fn:    The name of the function of the base class, or the 
user function itself if there is no base class.
+        @type fn:       str
+        @return:        The title for the window.
+        @rtype:         GUI str
+        """
+
+        # Get the user function class (or function).
+        if base:
+            uf_class = getattr(self.interpreter, base)
+
+        # Get the user function.
+        if base:
+            uf = getattr(uf_class, fn)
+        else:
+            uf = getattr(self.interpreter, fn)
+
+        # The title (default to the short one).
+        if hasattr(uf, '_doc_title_short'):
+            title = uf._doc_title_short
+        else:
+            title = uf._doc_title
+
+        # Remove full stops, if present.
+        if title[-1] == '.':
+            title = title[:-1]
+
+        # Return the title as a GUI string.
+        return str_to_gui(title)
 
 
 class UF_page(Wiz_page):

Modified: branches/gui_testing/gui/user_functions/deselect.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/gui_testing/gui/user_functions/deselect.py?rev=13474&r1=13473&r2=13474&view=diff
==============================================================================
--- branches/gui_testing/gui/user_functions/deselect.py (original)
+++ branches/gui_testing/gui/user_functions/deselect.py Thu Jul  7 10:52:17 
2011
@@ -44,7 +44,7 @@
         """
 
         # Execute the wizard.
-        wizard = Wiz_window(size_x=600, size_y=300, title='Deselect all 
spins')
+        wizard = Wiz_window(size_x=600, size_y=300, 
title=self.get_title('deselect', 'all'))
         page = All_page(wizard, self.gui, self.interpreter)
         wizard.add_page(page, apply_button=False)
         wizard.run()




Related Messages


Powered by MHonArc, Updated Thu Jul 07 11:00:02 2011