mailr14621 - in /1.3/gui/user_functions: __init__.py 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 September 09, 2011 - 16:10:
Author: bugman
Date: Fri Sep  9 16:10:17 2011
New Revision: 14621

URL: http://svn.gna.org/viewcvs/relax?rev=14621&view=rev
Log:
Redesigned how the user function wizards are created.

The create_wizard() UF_base class method has been added to perform most of 
the work and to simplify
the specific user function code.  The __init__() method has also been 
reintroduced, but this time it
takes the 'parent' arg, which is the parent wx.Window, via the User_functions 
package class.


Modified:
    1.3/gui/user_functions/__init__.py
    1.3/gui/user_functions/base.py
    1.3/gui/user_functions/deselect.py

Modified: 1.3/gui/user_functions/__init__.py
URL: 
http://svn.gna.org/viewcvs/relax/1.3/gui/user_functions/__init__.py?rev=14621&r1=14620&r2=14621&view=diff
==============================================================================
--- 1.3/gui/user_functions/__init__.py (original)
+++ 1.3/gui/user_functions/__init__.py Fri Sep  9 16:10:17 2011
@@ -77,26 +77,30 @@
     This uses the observer design pattern to allow for GUI updates upon 
completion of a user function.
     """
 
-    def __init__(self):
-        """Set up the container."""
+    def __init__(self, parent=None):
+        """Set up the container.
+
+        @keyword parent:    The parent window.
+        @type parent:       wx.Window instance
+        """
 
         # The user functions.
-        self.deselect = Deselect()
-        self.gpl = Gpl()
-        self.grace = Grace()
-        self.molecule = Molecule()
-        self.molmol = Molmol()
-        self.noe = Noe()
-        self.pipe = Pipe()
-        self.pymol = Pymol()
-        self.residue = Residue()
-        self.results = Results()
-        self.relax_data = Relax_data()
-        self.relax_fit = Relax_fit()
-        self.script = Script()
-        self.select = Select()
-        self.sequence = Sequence()
-        self.spectrum = Spectrum()
-        self.spin = Spin()
-        self.structure = Structure()
-        self.value = Value()
+        self.deselect = Deselect(parent)
+        self.gpl = Gpl(parent)
+        self.grace = Grace(parent)
+        self.molecule = Molecule(parent)
+        self.molmol = Molmol(parent)
+        self.noe = Noe(parent)
+        self.pipe = Pipe(parent)
+        self.pymol = Pymol(parent)
+        self.residue = Residue(parent)
+        self.results = Results(parent)
+        self.relax_data = Relax_data(parent)
+        self.relax_fit = Relax_fit(parent)
+        self.script = Script(parent)
+        self.select = Select(parent)
+        self.sequence = Sequence(parent)
+        self.spectrum = Spectrum(parent)
+        self.spin = Spin(parent)
+        self.structure = Structure(parent)
+        self.value = Value(parent)

Modified: 1.3/gui/user_functions/base.py
URL: 
http://svn.gna.org/viewcvs/relax/1.3/gui/user_functions/base.py?rev=14621&r1=14620&r2=14621&view=diff
==============================================================================
--- 1.3/gui/user_functions/base.py (original)
+++ 1.3/gui/user_functions/base.py Fri Sep  9 16:10:17 2011
@@ -37,11 +37,59 @@
 # relax GUI imports.
 from gui.fonts import font
 from gui.misc import str_to_gui
-from gui.wizard import Wiz_page
+from gui.wizard import Wiz_page, Wiz_window
 
 
 class UF_base:
     """User function GUI element base class."""
+
+    def __init__(self, parent):
+        """Set up the window.
+
+        @param parent:      The parent window.
+        @type parent:       wx.Window instance
+        """
+
+        # Store the arg.
+        self.parent = parent
+
+
+    def create_wizard(self, size_x=600, size_y=400, name=None, uf_page=None, 
apply_button=True):
+        """Create and return the wizard window.
+
+        @keyword size_x:        The width of the wizard.
+        @type size_x:           int
+        @keyword size_y:        The height of the wizard.
+        @type size_y:           int
+        @keyword name:          The name of the user function, such as 
'deselect.all'.
+        @type name:             str
+        @keyword uf_page:       The user function page class.
+        @type uf_page:          class
+        @keyword apply_button:  A flag which if true will show the apply 
button for that page.  This will be passed to the wizard's add_page() method.
+        @type apply_button:     bool
+        @return:                The wizard dialog.
+        @rtype:                 gui.wizard.Wiz_window instance
+        """
+
+        # Split the name.
+        comps = split(name, '.')
+        if len(comps) == 2:
+            base = comps[0]
+            fn = comps[1]
+        else:
+            base = None
+            fn = comps[0]
+
+        # Create the wizard dialog.
+        wizard = Wiz_window(parent=self.parent, size_x=size_x, 
size_y=size_y, title=self.get_title(base=base, fn=fn))
+
+        # Creat the page and add it to the wizard.
+        page = uf_page(wizard)
+        wizard.add_page(page, apply_button=apply_button)
+
+        # Return the wizard.
+        return wizard
+
 
     def get_title(self, base=None, fn=None):
         """Get the title for the wizard window from the user function 
documentation.

Modified: 1.3/gui/user_functions/deselect.py
URL: 
http://svn.gna.org/viewcvs/relax/1.3/gui/user_functions/deselect.py?rev=14621&r1=14620&r2=14621&view=diff
==============================================================================
--- 1.3/gui/user_functions/deselect.py (original)
+++ 1.3/gui/user_functions/deselect.py Fri Sep  9 16:10:17 2011
@@ -33,7 +33,6 @@
 from base import UF_base, UF_page
 from gui.interpreter import Interpreter; interpreter = Interpreter()
 from gui.misc import gui_to_bool, gui_to_int, gui_to_str, str_to_gui
-from gui.wizard import Wiz_window
 
 
 # The container class.
@@ -48,9 +47,7 @@
         """
 
         # Execute the wizard.
-        wizard = Wiz_window(size_x=600, size_y=300, 
title=self.get_title('deselect', 'all'))
-        page = All_page(wizard)
-        wizard.add_page(page, apply_button=False)
+        wizard = self.create_wizard(size_x=600, size_y=300, 
name='deselect.all', uf_page=All_page, apply_button=False)
         wizard.run()
 
 
@@ -62,9 +59,7 @@
         """
 
         # Execute the wizard.
-        wizard = Wiz_window(size_x=900, size_y=700, 
title=self.get_title('deselect', 'read'))
-        page = Read_page(wizard)
-        wizard.add_page(page)
+        wizard = self.create_wizard(size_x=900, size_y=700, 
name='deselect.read', uf_page=Read_page)
         wizard.run()
 
 
@@ -76,9 +71,7 @@
         """
 
         # Execute the wizard.
-        wizard = Wiz_window(size_x=700, size_y=400, 
title=self.get_title('deselect', 'reverse'))
-        page = Reverse_page(wizard)
-        wizard.add_page(page, apply_button=False)
+        wizard = self.create_wizard(size_x=700, size_y=400, 
name='deselect.reverse', uf_page=Reverse_page, apply_button=False)
         wizard.run()
 
 
@@ -90,9 +83,7 @@
         """
 
         # Execute the wizard.
-        wizard = Wiz_window(size_x=700, size_y=500, 
title=self.get_title('deselect', 'spin'))
-        page = Spin_page(wizard)
-        wizard.add_page(page)
+        wizard = self.create_wizard(size_x=700, size_y=500, 
name='deselect.spin', uf_page=Spin_page)
         wizard.run()
 
 




Related Messages


Powered by MHonArc, Updated Fri Sep 09 16:40:01 2011