mailr23559 - in /trunk: gui/ gui/input_elements/ user_functions/


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

Header


Content

Posted by edward on May 28, 2014 - 19:01:
Author: bugman
Date: Wed May 28 19:01:14 2014
New Revision: 23559

URL: http://svn.gna.org/viewcvs/relax?rev=23559&view=rev
Log:
Titles are now handled and set in the Sequence GUI element.

The titles will replace the numbering of 1 onwards in the first column of the 
GUI element.


Modified:
    trunk/gui/input_elements/sequence.py
    trunk/gui/input_elements/sequence_2D.py
    trunk/gui/uf_objects.py
    trunk/user_functions/objects.py

Modified: trunk/gui/input_elements/sequence.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/gui/input_elements/sequence.py?rev=23559&r1=23558&r2=23559&view=diff
==============================================================================
--- trunk/gui/input_elements/sequence.py        (original)
+++ trunk/gui/input_elements/sequence.py        Wed May 28 19:01:14 2014
@@ -48,7 +48,7 @@
         - tuple of strings
     """
 
-    def __init__(self, name=None, default=None, parent=None, 
element_type='default', seq_type=None, value_type=None, dim=None, min=0, 
max=1000, sizer=None, desc=None, combo_choices=None, combo_data=None, 
combo_list_min=None, tooltip=None, divider=None, padding=0, spacer=None, 
height_element=27, single_value=False, read_only=False, can_be_none=False):
+    def __init__(self, name=None, default=None, parent=None, 
element_type='default', seq_type=None, value_type=None, dim=None, min=0, 
max=1000, sizer=None, titles=None, desc=None, combo_choices=None, 
combo_data=None, combo_list_min=None, tooltip=None, divider=None, padding=0, 
spacer=None, height_element=27, single_value=False, read_only=False, 
can_be_none=False):
         """Set up the element.
 
         @keyword name:              The name of the element to use in 
titles, etc.
@@ -71,6 +71,8 @@
         @type max:                  int
         @keyword sizer:             The sizer to put the input field widget 
into.
         @type sizer:                wx.Sizer instance
+        @keyword titles:            The titles of each of the elements of 
the fixed dimension elements.
+        @type titles:               list of str
         @keyword desc:              The text description.
         @type desc:                 str
         @keyword combo_choices:     The list of choices to present to the 
user.  This is only used if the element_type is set to 'combo'.
@@ -107,6 +109,7 @@
         self.dim = dim
         self.min = min
         self.max = max
+        self.titles = titles
         self.single_value = single_value
         self.can_be_none = can_be_none
 
@@ -385,7 +388,7 @@
         """Show the selection window."""
 
         # Initialise the model selection window.
-        self.sel_win = Sequence_window(parent=self.parent, name=self.name, 
seq_type=self.seq_type, value_type=self.value_type, dim=self.dim)
+        self.sel_win = Sequence_window(parent=self.parent, name=self.name, 
seq_type=self.seq_type, value_type=self.value_type, titles=self.titles, 
dim=self.dim)
 
         # Set the model selector window selections.
         self.sel_win.SetValue(self.GetValue())
@@ -445,7 +448,7 @@
     # Sizes.
     SIZE_BUTTON = (150, 33)
 
-    def __init__(self, parent=None, name='', seq_type='list', 
value_type='str', dim=None):
+    def __init__(self, parent=None, name='', seq_type='list', 
value_type='str', dim=None, titles=None):
         """Set up the string list editor window.
 
         @keyword parent:        The parent GUI element.
@@ -458,6 +461,8 @@
         @type value_type:       str
         @keyword dim:           The fixed dimension that the sequence must 
conform to.
         @type dim:              int or None
+        @keyword titles:        The titles of each of the elements of the 
fixed dimension elements.
+        @type titles:           list of str
         """
 
         # Store the args.
@@ -465,6 +470,7 @@
         self.seq_type = seq_type
         self.value_type = value_type
         self.dim = dim
+        self.titles = titles
 
         # The base types.
         if value_type in ['float', 'num']:
@@ -690,8 +696,12 @@
         title = "%s%s" % (self.name[0].upper(), self.name[1:])
 
         # Add the index column.
-        self.sequence.InsertColumn(0, "Position")
-        self.sequence.SetColumnWidth(0, 70)
+        if self.titles:
+            self.sequence.InsertColumn(0, "")
+            self.sequence.SetColumnWidth(0, wx.LIST_AUTOSIZE)
+        else:
+            self.sequence.InsertColumn(0, "Number")
+            self.sequence.SetColumnWidth(0, 70)
 
         # Add a single column, full width.
         self.sequence.InsertColumn(1, title)
@@ -703,7 +713,16 @@
         # The fixed dimension sequence - add all the rows needed.
         if not self.variable_length:
             for i in range(self.dim):
+                # Add a new row.
                 self.add_element()
+
+                # Add a title to the first column.
+                if self.titles:
+                    self.sequence.SetStringItem(i, 0, 
str_to_gui(self.titles[i]))
+
+                # Otherwise add numbers starting from 1.
+                else:
+                    self.sequence.SetStringItem(i, 0, int_to_gui(i+1))
 
 
     def close(self, event):

Modified: trunk/gui/input_elements/sequence_2D.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/gui/input_elements/sequence_2D.py?rev=23559&r1=23558&r2=23559&view=diff
==============================================================================
--- trunk/gui/input_elements/sequence_2D.py     (original)
+++ trunk/gui/input_elements/sequence_2D.py     Wed May 28 19:01:14 2014
@@ -99,7 +99,7 @@
         self.titles = titles
 
         # Initialise the base class.
-        Sequence.__init__(self, name=name, default=default, parent=parent, 
sizer=sizer, element_type=element_type, seq_type=seq_type, 
value_type=value_type, dim=dim, min=min, max=max, desc=desc, 
combo_choices=combo_choices, combo_data=combo_data, 
combo_list_min=combo_list_min, tooltip=tooltip, divider=divider, 
padding=padding, spacer=spacer, height_element=height_element, 
read_only=read_only, can_be_none=can_be_none)
+        Sequence.__init__(self, name=name, default=default, parent=parent, 
sizer=sizer, element_type=element_type, seq_type=seq_type, 
value_type=value_type, dim=dim, min=min, max=max, titles=titles, desc=desc, 
combo_choices=combo_choices, combo_data=combo_data, 
combo_list_min=combo_list_min, tooltip=tooltip, divider=divider, 
padding=padding, spacer=spacer, height_element=height_element, 
read_only=read_only, can_be_none=can_be_none)
 
 
     def open_dialog(self, event):
@@ -170,7 +170,7 @@
             self.offset = 1
 
         # Initialise the base class.
-        Sequence_window.__init__(self, name=name, seq_type=seq_type, 
value_type=value_type, dim=dim)
+        Sequence_window.__init__(self, name=name, seq_type=seq_type, 
value_type=value_type, dim=dim, titles=self.titles)
 
 
     def GetValue(self):

Modified: trunk/gui/uf_objects.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/gui/uf_objects.py?rev=23559&r1=23558&r2=23559&view=diff
==============================================================================
--- trunk/gui/uf_objects.py     (original)
+++ trunk/gui/uf_objects.py     Wed May 28 19:01:14 2014
@@ -592,7 +592,7 @@
                 if isinstance(arg['dim'], int):
                     dim = arg['dim']
 
-                self.uf_args[arg['name']] = Sequence(name=arg['name'], 
parent=self, default=arg['default'], element_type=arg['wiz_element_type'], 
seq_type=seq_type, value_type=value_type, dim=dim, min=arg['min'], 
max=arg['max'], sizer=sizer, desc=desc, 
combo_choices=arg['wiz_combo_choices'], combo_data=arg['wiz_combo_data'], 
combo_list_min=arg['wiz_combo_list_min'], tooltip=arg['desc'], 
single_value=single_value, divider=self._div_left, 
height_element=self.height_element, read_only=arg['wiz_read_only'], 
can_be_none=arg['can_be_none'])
+                self.uf_args[arg['name']] = Sequence(name=arg['name'], 
parent=self, default=arg['default'], element_type=arg['wiz_element_type'], 
seq_type=seq_type, value_type=value_type, dim=dim, min=arg['min'], 
max=arg['max'], titles=arg['list_titles'], sizer=sizer, desc=desc, 
combo_choices=arg['wiz_combo_choices'], combo_data=arg['wiz_combo_data'], 
combo_list_min=arg['wiz_combo_list_min'], tooltip=arg['desc'], 
single_value=single_value, divider=self._div_left, 
height_element=self.height_element, read_only=arg['wiz_read_only'], 
can_be_none=arg['can_be_none'])
 
             # 2D sequence types.
             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', 'float_matrix', 'int_matrix', 
'list_val_or_list_of_list_val']:

Modified: trunk/user_functions/objects.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/user_functions/objects.py?rev=23559&r1=23558&r2=23559&view=diff
==============================================================================
--- trunk/user_functions/objects.py     (original)
+++ trunk/user_functions/objects.py     Wed May 28 19:01:14 2014
@@ -415,7 +415,7 @@
         @type desc_short:               str
         @keyword desc:                  The long human-readable description 
of the argument.
         @type desc:                     str
-        @keyword list_titles:           The titles of each of the elements 
of the fixed width second dimension.  This only applies to list of lists.
+        @keyword list_titles:           The titles of each of the elements 
of the fixed length lists.  This only applies to lists or list of lists.
         @type list_titles:              list of str
         @keyword wiz_element_type:      The type of GUI element to create.  
If left to 'default', then the currently set default element will be used.  
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




Related Messages


Powered by MHonArc, Updated Wed May 28 19:20:03 2014