Author: bugman
Date: Mon May 7 17:53:44 2012
New Revision: 16065
URL: http://svn.gna.org/viewcvs/relax?rev=16065&view=rev
Log:
The 'num_or_num_list' and 'num_or_num_tuple' argument types are now supported
in the GUI.
These are for the auto-generated GUI user functions. The 'num_or_num_tuple'
argument type is used
for the diffusion_tensor.init user function, for example.
Modified:
branches/uf_redesign/gui/uf_objects.py
branches/uf_redesign/gui/wizard.py
branches/uf_redesign/gui/wizard_elements.py
Modified: branches/uf_redesign/gui/uf_objects.py
URL:
http://svn.gna.org/viewcvs/relax/branches/uf_redesign/gui/uf_objects.py?rev=16065&r1=16064&r2=16065&view=diff
==============================================================================
--- branches/uf_redesign/gui/uf_objects.py (original)
+++ branches/uf_redesign/gui/uf_objects.py Mon May 7 17:53:44 2012
@@ -220,22 +220,27 @@
self.element_bool(key=arg['name'],
element_type=arg['wiz_element_type'], sizer=sizer, desc=desc,
tooltip=arg['desc'], default=arg['default'])
# Sequence types.
- elif arg['py_type'] in ['float_list', 'int_list', 'num_list',
'str_list', 'float_tuple', 'int_tuple', 'num_tuple', 'str_tuple']:
+ elif arg['py_type'] in ['float_list', 'int_list', 'num_list',
'str_list', 'float_tuple', 'int_tuple', 'num_tuple', 'str_tuple',
'num_or_num_list', 'num_or_num_tuple']:
# The sequence type.
- if arg['py_type'] in ['float_list', 'int_list', 'num_list',
'str_list']:
+ if arg['py_type'] in ['float_list', 'int_list', 'num_list',
'str_list', 'num_or_num_list']:
seq_type = 'list'
else:
seq_type = 'tuple'
# The value type.
- if arg['py_type'] in ['float_list', 'float_tuple', 'num_list',
'num_tuple']:
+ if arg['py_type'] in ['float_list', 'float_tuple', 'num_list',
'num_or_num_list', 'num_tuple', 'num_or_num_tuple']:
value_type = 'float'
elif arg['py_type'] in ['int_list', 'int_tuple']:
value_type = 'int'
else:
value_type = 'str'
- self.element_sequence(key=arg['name'],
element_type=arg['wiz_element_type'], seq_type=seq_type, value_type=value_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'],
read_only=arg['wiz_read_only'])
+ # Single values.
+ single_value = False
+ if arg['py_type'] in ['num_or_num_list', 'num_or_num_tuple']:
+ single_value = True
+
+ self.element_sequence(key=arg['name'],
element_type=arg['wiz_element_type'], seq_type=seq_type, value_type=value_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'],
single_value=single_value, read_only=arg['wiz_read_only'])
# String list of lists.
elif arg['py_type'] in ['float_list_of_lists',
'int_list_of_lists', 'num_list_of_lists', 'str_list_of_lists',
'float_tuple_of_tuples', 'int_tuple_of_tuples', 'num_tuple_of_tuples',
'str_tuple_of_tuples']:
Modified: branches/uf_redesign/gui/wizard.py
URL:
http://svn.gna.org/viewcvs/relax/branches/uf_redesign/gui/wizard.py?rev=16065&r1=16064&r2=16065&view=diff
==============================================================================
--- branches/uf_redesign/gui/wizard.py (original)
+++ branches/uf_redesign/gui/wizard.py Mon May 7 17:53:44 2012
@@ -679,7 +679,7 @@
self._elements[key] = element
- def element_sequence(self, key=None, sizer=None, element_type='default',
seq_type=None, value_type=None, desc=None, combo_choices=None, combo_data=None,
combo_default=None, combo_list_size=None, tooltip=None, divider=None,
padding=0, spacer=None, read_only=False):
+ def element_sequence(self, key=None, sizer=None, element_type='default',
seq_type=None, value_type=None, desc=None, combo_choices=None, combo_data=None,
combo_default=None, combo_list_size=None, tooltip=None, divider=None,
padding=0, spacer=None, single_value=False, read_only=False):
"""Set up the element and store it.
@keyword key: The dictionary key to store the element
with.
@@ -710,12 +710,14 @@
@type padding: int
@keyword spacer: The amount of spacing to add below the
field in pixels. If None, a stretchable spacer will be used.
@type spacer: None or int
+ @keyword single_value: A flag which if True will cause single
input values to be treated as single values rather than a list or tuple.
+ @type single_value: bool
@keyword read_only: A flag which if True means that the text
of the element cannot be edited.
@type read_only: bool
"""
# Create the element.
- element = Sequence(name=key, element_type=element_type,
seq_type=seq_type, value_type=value_type, parent=self, sizer=sizer, desc=desc,
combo_choices=combo_choices, combo_data=combo_data,
combo_default=combo_default, combo_list_size=combo_list_size, tooltip=tooltip,
divider=divider, padding=padding, spacer=spacer, read_only=read_only)
+ element = Sequence(name=key, element_type=element_type,
seq_type=seq_type, value_type=value_type, parent=self, sizer=sizer, desc=desc,
combo_choices=combo_choices, combo_data=combo_data,
combo_default=combo_default, combo_list_size=combo_list_size, tooltip=tooltip,
divider=divider, padding=padding, spacer=spacer, single_value=single_value,
read_only=read_only)
# Store it.
self._elements[key] = element
Modified: branches/uf_redesign/gui/wizard_elements.py
URL:
http://svn.gna.org/viewcvs/relax/branches/uf_redesign/gui/wizard_elements.py?rev=16065&r1=16064&r2=16065&view=diff
==============================================================================
--- branches/uf_redesign/gui/wizard_elements.py (original)
+++ branches/uf_redesign/gui/wizard_elements.py Mon May 7 17:53:44 2012
@@ -54,7 +54,7 @@
- tuple of strings
"""
- def __init__(self, name=None, parent=None, element_type='default',
seq_type=None, value_type=None, sizer=None, desc=None, combo_choices=None,
combo_data=None, combo_default=None, combo_list_size=None, tooltip=None,
divider=None, padding=0, spacer=None, read_only=False):
+ def __init__(self, name=None, parent=None, element_type='default',
seq_type=None, value_type=None, sizer=None, desc=None, combo_choices=None,
combo_data=None, combo_default=None, combo_list_size=None, tooltip=None,
divider=None, padding=0, spacer=None, single_value=False, read_only=False):
"""Set up the element.
@keyword name: The name of the element to use in titles,
etc.
@@ -87,6 +87,8 @@
@type padding: int
@keyword spacer: The amount of spacing to add below the
field in pixels. If None, a stretchable spacer will be used.
@type spacer: None or int
+ @keyword single_value: A flag which if True will cause single
input values to be treated as single values rather than a list or tuple.
+ @type single_value: bool
@keyword read_only: A flag which if True means that the text
of the element cannot be edited.
@type read_only: bool
"""
@@ -96,6 +98,7 @@
self.element_type = element_type
self.seq_type = seq_type
self.value_type = value_type
+ self.single_value = single_value
# The sequence types.
if seq_type == 'list':
@@ -205,11 +208,18 @@
# Convert, handling bad user behaviour.
try:
value = self.convert_from_gui(value)
- except:
+ except RelaxError:
if self.seq_type == 'list':
value = []
else:
value = ()
+
+ # Handle single values.
+ if self.single_value and len(value) == 1:
+ if self.seq_type == 'list' and not isinstance(value, list):
+ value = [value]
+ elif self.seq_type == 'tuple' and not isinstance(value, tuple):
+ value = (value,)
# Return the value.
return value
@@ -240,8 +250,12 @@
@type value: list of str
"""
+ # Handle single values.
+ if self.single_value and len(value) == 1:
+ value = value[0]
+
# Convert and set the value.
- self._field.SetValue(list_to_gui(value))
+ self._field.SetValue(self.convert_to_gui(value))
def open_dialog(self, event):
_______________________________________________
relax (http://www.nmr-relax.com)
This is the relax-commits mailing list
[email protected]
To unsubscribe from this list, get a password
reminder, or change your subscription options,
visit the list information page at
https://mail.gna.org/listinfo/relax-commits