mailr15968 - in /branches/uf_redesign: gui/uf_objects.py user_functions/objects.py user_functions/pipe.py


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

Header


Content

Posted by edward on May 04, 2012 - 16:40:
Author: bugman
Date: Fri May  4 16:40:48 2012
New Revision: 15968

URL: http://svn.gna.org/viewcvs/relax?rev=15968&view=rev
Log:
Advancements for the auto-generated GUI user functions.

String list GUI elements are now supported.  The wizard element are now 
updated on display, allowing
for example the current set of data pipes to be displayed in the ComboBoxes 
of the pipe user
functions.


Modified:
    branches/uf_redesign/gui/uf_objects.py
    branches/uf_redesign/user_functions/objects.py
    branches/uf_redesign/user_functions/pipe.py

Modified: branches/uf_redesign/gui/uf_objects.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/uf_redesign/gui/uf_objects.py?rev=15968&r1=15967&r2=15968&view=diff
==============================================================================
--- branches/uf_redesign/gui/uf_objects.py (original)
+++ branches/uf_redesign/gui/uf_objects.py Fri May  4 16:40:48 2012
@@ -214,7 +214,11 @@
 
             # String type.
             if arg['py_type'] == 'str':
-                self.element_string(key=arg['name'], 
element_type=arg['wiz_element_type'], sizer=sizer, desc=desc, 
combo_choices=arg['wiz_combo_choices'], combo_data=arg['wiz_combo_data'], 
combo_default=arg['wiz_combo_default'], tooltip=arg['desc'])
+                self.element_string(key=arg['name'], 
element_type=arg['wiz_element_type'], sizer=sizer, desc=desc, 
combo_choices=arg['wiz_combo_choices'], combo_data=arg['wiz_combo_data'], 
combo_default=arg['wiz_combo_default'], tooltip=arg['desc'], 
read_only=arg['wiz_read_only'])
+
+            # String list.
+            elif arg['py_type'] == 'str_list':
+                self.element_string_list(key=arg['name'], 
element_type=arg['wiz_element_type'], sizer=sizer, desc=desc, 
combo_choices=arg['wiz_combo_choices'], combo_data=arg['wiz_combo_data'], 
combo_default=arg['wiz_combo_default'], 
combo_list_size=arg['wiz_combo_list_size'], tooltip=arg['desc'])
 
 
     def add_desc(self, sizer, max_y=220):
@@ -249,7 +253,6 @@
                 text_list.append([element, type])
 
         # Additional documentation.
-        print self.uf_data
         if self.uf_data.additional != None:
             for i in range(len(self.uf_data.additional)):
                 for element, type in 
self.process_doc(self.uf_data.additional[i]):
@@ -347,6 +350,34 @@
             interpreter.queue(uf, *args, **kwds)
 
 
+    def on_display(self):
+        """Clear and update the data if needed."""
+
+        # Loop over the arguments.
+        for i in range(len(self.uf_data.kargs)):
+            # The argument name.
+            name = self.uf_data.kargs[i]['name']
+
+            # No iterator method for updating the list.
+            iterator = self.uf_data.kargs[i]['wiz_combo_iter']
+            if iterator == None:
+                continue
+
+            # Get the new choices and data.
+            choices = []
+            data = []
+            for vals in iterator():
+                if len(vals) == 2:
+                    choices.append(vals[0])
+                    data.append(vals[1])
+                else:
+                    choices.append(vals)
+                    data.append(vals)
+
+            # Reset.
+            self.ResetChoices(name, combo_choices=choices, combo_data=data)
+
+
     def on_execute(self):
         """Execute the user function."""
 

Modified: branches/uf_redesign/user_functions/objects.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/uf_redesign/user_functions/objects.py?rev=15968&r1=15967&r2=15968&view=diff
==============================================================================
--- branches/uf_redesign/user_functions/objects.py (original)
+++ branches/uf_redesign/user_functions/objects.py Fri May  4 16:40:48 2012
@@ -159,31 +159,37 @@
         self.__dict__[name] = value
 
 
-    def add_keyarg(self, name=None, default=None, py_type=None, 
desc_short=None, desc=None, wiz_desc=None, wiz_element_type='text', 
wiz_combo_choices=None, wiz_combo_data=None, wiz_combo_default=None, 
can_be_none=False):
+    def add_keyarg(self, name=None, default=None, py_type=None, 
desc_short=None, desc=None, wiz_desc=None, wiz_element_type='text', 
wiz_combo_choices=[], wiz_combo_data=None, wiz_combo_default=None, 
wiz_combo_iter=None, wiz_combo_list_size=None, wiz_read_only=False, 
can_be_none=False):
         """Wrapper method for adding keyword argument information to the 
container.
 
-        @keyword name:              The name of the argument.
-        @type name:                 str
-        @keyword default:           The default value of the argument.
-        @type default:              anything
-        @keyword py_type:           The Python object type that the argument 
must match (taking the can_be_none flag into account).
-        @type py_type:              str
-        @keyword desc_short:        The short human-readable description of 
the argument.  This is used, for example, in the RelaxError messages to refer 
to the argument.
-        @type desc_short:           str
-        @keyword desc:              The long human-readable description of 
the argument.
-        @type desc:                 str
-        @keyword wiz_desc:          The description used in the wizard GUI 
pages.
-        @type wiz_desc:             str
-        @keyword wiz_element_type:  The type of GUI element to create.  If 
set to 'text', a wx.TextCtrl element will be used.  If set to 'combo', a 
wx.ComboBox element will be used.
-        @type wiz_element_type:     str
-        @keyword wiz_combo_choices: The list of choices to present to the 
user.  This is only used if the element_type is set to 'combo'.
-        @type wiz_combo_choices:    list of str
-        @keyword wiz_combo_data:    The data returned by a call to 
GetValue().  This is only used if the element_type is set to 'combo'.  If 
supplied, it should be the same length at the combo_choices list.  If not 
supplied, the combo_choices list will be used for the returned data.
-        @type wiz_combo_data:       list
-        @keyword wiz_combo_default: The default value of the ComboBox.  This 
is only used if the element_type is set to 'combo'.
-        @type wiz_combo_default:    str or None
-        @keyword can_be_none:       A flag which specifies if the argument 
is allowed to have the None value.
-        @type can_be_none:          bool
+        @keyword name:                  The name of the argument.
+        @type name:                     str
+        @keyword default:               The default value of the argument.
+        @type default:                  anything
+        @keyword py_type:               The Python object type that the 
argument must match (taking the can_be_none flag into account).
+        @type py_type:                  str
+        @keyword desc_short:            The short human-readable description 
of the argument.  This is used, for example, in the RelaxError messages to 
refer to the argument.
+        @type desc_short:               str
+        @keyword desc:                  The long human-readable description 
of the argument.
+        @type desc:                     str
+        @keyword wiz_desc:              The description used in the wizard 
GUI pages.
+        @type wiz_desc:                 str
+        @keyword wiz_element_type:      The type of GUI element to create.  
If set to 'text', a wx.TextCtrl element will be used.  If set to 'combo', a 
wx.ComboBox element will be used.
+        @type wiz_element_type:         str
+        @keyword wiz_combo_choices:     The list of choices to present to 
the user.  This is only used if the element_type is set to 'combo'.
+        @type wiz_combo_choices:        list of str
+        @keyword wiz_combo_data:        The data returned by a call to 
GetValue().  This is only used if the element_type is set to 'combo'.  If 
supplied, it should be the same length at the combo_choices list.  If not 
supplied, the combo_choices list will be used for the returned data.
+        @type wiz_combo_data:           list
+        @keyword wiz_combo_default:     The default value of the ComboBox.  
This is only used if the element_type is set to 'combo'.
+        @type wiz_combo_default:        str or None
+        @keyword wiz_combo_iter:        An iterator method for regenerating 
the ComboBox choices.
+        @type wiz_combo_iter:           iterator or None
+        @keyword wiz_combo_list_size:   An iterator method for regenerating 
the ComboBox choices.
+        @type wiz_combo_list_size:      iterator or None
+        @keyword wiz_read_only:         A flag which if True means that the 
text of the GUI wizard page element cannot be edited.
+        @type wiz_read_only:            bool
+        @keyword can_be_none:           A flag which specifies if the 
argument is allowed to have the None value.
+        @type can_be_none:              bool
         """
 
         # Check that the args have been properly supplied.
@@ -213,4 +219,7 @@
         arg['wiz_combo_choices'] = wiz_combo_choices
         arg['wiz_combo_data'] = wiz_combo_data
         arg['wiz_combo_default'] = wiz_combo_default
+        arg['wiz_combo_iter'] = wiz_combo_iter
+        arg['wiz_combo_list_size'] = wiz_combo_list_size
+        arg['wiz_read_only'] = wiz_read_only
         arg['can_be_none'] = can_be_none

Modified: branches/uf_redesign/user_functions/pipe.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/uf_redesign/user_functions/pipe.py?rev=15968&r1=15967&r2=15968&view=diff
==============================================================================
--- branches/uf_redesign/user_functions/pipe.py (original)
+++ branches/uf_redesign/user_functions/pipe.py Fri May  4 16:40:48 2012
@@ -48,6 +48,8 @@
         desc_short = "pipe from",
         desc = "The name of the source data pipe to copy the data from.",
         wiz_desc = "Source pipe",
+        wiz_element_type = 'combo',
+        wiz_combo_iter = pipes.pipe_names,
         can_be_none = True
 )
 uf.add_keyarg(
@@ -99,7 +101,8 @@
         wiz_desc = "The type of data pipe",
         wiz_element_type = 'combo',
         wiz_combo_choices = pipes.PIPE_DESC_LIST,
-        wiz_combo_data = pipes.VALID_TYPES
+        wiz_combo_data = pipes.VALID_TYPES,
+        wiz_read_only = True
 )
 uf.backend = pipes.create
 uf.desc = """
@@ -150,6 +153,8 @@
         desc_short = "data pipe name",
         desc = "The name of the data pipe to delete.",
         wiz_desc = "The pipe",
+        wiz_element_type = 'combo',
+        wiz_combo_iter = pipes.pipe_names,
         can_be_none = True
 )
 uf.backend = pipes.delete
@@ -193,7 +198,10 @@
         py_type = "str_list",
         desc_short = "data pipes",
         desc = "An array containing the names of all data pipes to 
hybridise.",
-        wiz_desc = "The pipes to hybridise"
+        wiz_desc = "The pipes to hybridise",
+        wiz_element_type = 'combo_list',
+        wiz_combo_iter = pipes.pipe_names,
+        wiz_combo_list_size = 2
 )
 uf.backend = hybrid_obj._hybridise
 uf.desc = """
@@ -224,7 +232,9 @@
         py_type = "str",
         desc_short = "data pipe name",
         desc = "The name of the data pipe.",
-        wiz_desc = "The pipe"
+        wiz_desc = "The pipe",
+        wiz_element_type = 'combo',
+        wiz_combo_iter = pipes.pipe_names
 )
 uf.backend = pipes.switch
 uf.desc = """
@@ -240,4 +250,4 @@
 uf.gui_icon = "oxygen.actions.system-switch-user"
 uf.wizard_size = (650, 450)
 uf.wizard_apply_button = False
-uf.wizard_image = WIZARD_IMAGE_PATH + 'pipe.png'
+uf.wizard_image = WIZARD_IMAGE_PATH + 'pipe_switch.png'




Related Messages


Powered by MHonArc, Updated Fri May 04 17:00:02 2012