Author: bugman Date: Fri Feb 21 11:40:22 2014 New Revision: 22234 URL: http://svn.gna.org/viewcvs/relax?rev=22234&view=rev Log: Modified the GUI window for inputting sequence data to include item numbers. An non-editable initial column with the number of each item has been added. This is to help the user when, for example, the items of one sequence element should match another (for example in the spectrum.read_intensities user function where multiple file names should match multiple spectrum IDs). Modified: trunk/gui/input_elements/sequence.py Modified: trunk/gui/input_elements/sequence.py URL: http://svn.gna.org/viewcvs/relax/trunk/gui/input_elements/sequence.py?rev=22234&r1=22233&r2=22234&view=diff ============================================================================== --- trunk/gui/input_elements/sequence.py (original) +++ trunk/gui/input_elements/sequence.py Fri Feb 21 11:40:22 2014 @@ -404,6 +404,25 @@ wx.lib.mixins.listctrl.TextEditMixin.__init__(self) wx.lib.mixins.listctrl.ListCtrlAutoWidthMixin.__init__(self) + # Catch edits. + self.Bind(wx.EVT_LIST_BEGIN_LABEL_EDIT, self.begin_label_edit) + + + def begin_label_edit(self, event): + """Catch edits to make the first column read only. + + @param event: The wx event. + @type event: wx event + """ + + # Prevent edits in the first column. + if event.m_col == 0: + event.Veto() + + # Otherwise the user is free to edit. + else: + event.Skip() + class Sequence_window(wx.Dialog): @@ -497,7 +516,12 @@ # Loop over the entries. for i in range(self.sequence.GetItemCount()): - values.append(self.convert_from_gui(self.sequence.GetItemText(i))) + # Get the text. + item = self.sequence.GetItem(i, col=1) + text = item.GetText() + + # Store the text. + values.append(self.convert_from_gui(text)) # Sequence conversion. if self.seq_type == 'tuple': @@ -531,11 +555,15 @@ for i in range(len(values)): # Fixed dimension sequences - set the values of the pre-created list. if self.dim: - self.sequence.SetStringItem(index=i, col=0, label=self.convert_to_gui(values[i])) + self.sequence.SetStringItem(index=i, col=1, label=self.convert_to_gui(values[i])) # Variable dimension sequences - append the item to the end of the blank list. else: - self.sequence.InsertStringItem(i, self.convert_to_gui(values[i])) + # First add the index+1. + self.sequence.InsertStringItem(i, int_to_gui(i+1)) + + # Then set the value. + self.sequence.SetStringItem(index=i, col=1, label=self.convert_to_gui(values[i])) def add_buttons(self, sizer): @@ -597,9 +625,13 @@ # Set the column title. title = "%s%s" % (self.name[0].upper(), self.name[1:]) + # Add the index column. + self.sequence.InsertColumn(0, "Position") + self.sequence.SetColumnWidth(0, 70) + # Add a single column, full width. - self.sequence.InsertColumn(0, title) - self.sequence.SetColumnWidth(0, wx.LIST_AUTOSIZE) + self.sequence.InsertColumn(1, title) + self.sequence.SetColumnWidth(1, wx.LIST_AUTOSIZE) # Add the table to the sizer. sizer.Add(self.sequence, 1, wx.ALL|wx.EXPAND, 0) @@ -621,7 +653,7 @@ next = self.sequence.GetItemCount() # Add a new empty row. - self.sequence.InsertStringItem(next, '') + self.sequence.InsertStringItem(next, int_to_gui(next+1)) def close(self, event):