Author: bugman Date: Wed May 16 17:31:19 2012 New Revision: 16316 URL: http://svn.gna.org/viewcvs/relax?rev=16316&view=rev Log: The user function GUI page arguments are now updated after execution of the user function. This allows ComboBox lists to be dynamically updated, and is useful for when the user clicks on 'Apply'. Modified: branches/uf_redesign/gui/uf_objects.py Modified: branches/uf_redesign/gui/uf_objects.py URL: http://svn.gna.org/viewcvs/relax/branches/uf_redesign/gui/uf_objects.py?rev=16316&r1=16315&r2=16316&view=diff ============================================================================== --- branches/uf_redesign/gui/uf_objects.py (original) +++ branches/uf_redesign/gui/uf_objects.py Wed May 16 17:31:19 2012 @@ -586,9 +586,102 @@ interpreter.queue(uf, *args, **kwds) + def on_completion(self): + """Update the argument GUI elements if needed.""" + + # Update the args. + self.update_args() + + def on_display(self): """Clear and update the data if needed.""" + # Update the args. + self.update_args() + + + def on_execute(self): + """Execute the user function.""" + + # Get the argument values. + kargs = {} + for i in range(len(self.uf_data.kargs)): + # The argument name. + name = self.uf_data.kargs[i]['name'] + + # Store the value. + kargs[name] = self.GetValue(name) + + # Handle the free file format args. + if 'free_file_format' in self.uf_args: + kargs.update(self.uf_args['free_file_format'].GetValue()) + + # Display the relax controller, if asked. + if self.uf_data.display: + # Get the App. + app = wx.GetApp() + + # First show the controller. + app.gui.show_controller(None) + + # Go to the last line. + app.gui.controller.log_panel.on_goto_end(None) + + # Wait a little while. + sleep(0.5) + + # Execute the user function. + self.execute(self.name, **kargs) + + # Bring the controller to the front. + if self.uf_data.display: + wx.CallAfter(app.gui.controller.Raise) + + + def process_doc(self, doc): + """Process the documentation list. + + @param doc: The documentation in the form of a list of the title and description. + @type doc: list of str + """ + + # The title. + yield doc[0], 'title' + + # Strip the leading whitespace, if needed. + doc[1] = strip_lead(doc[1]) + + # Split up the description. + docstring_lines = split(doc[1], "\n") + + # Initialise. + text = [""] + type = ['desc'] + in_table = False + + # Loop over the lines of the docstring. + for line in docstring_lines: + # Start of the table. + if not in_table and search('___', line): + in_table = True + text.append("") + type.append("table") + + # Add the line to the text. + text[-1] = "%s%s\n" % (text[-1], line) + + # End of the table. + if in_table and line == '': + in_table = False + text.append("") + type.append("desc") + + # Yield the bits. + for i in range(len(text)): + yield text[i], type[i] + + + def update_args(self): # Loop over the arguments. for i in range(len(self.uf_data.kargs)): # The argument name. @@ -626,87 +719,6 @@ self.ResetChoices(name, combo_choices=choices, combo_data=data) - def on_execute(self): - """Execute the user function.""" - - # Get the argument values. - kargs = {} - for i in range(len(self.uf_data.kargs)): - # The argument name. - name = self.uf_data.kargs[i]['name'] - - # Store the value. - kargs[name] = self.GetValue(name) - - # Handle the free file format args. - if 'free_file_format' in self.uf_args: - kargs.update(self.uf_args['free_file_format'].GetValue()) - - # Display the relax controller, if asked. - if self.uf_data.display: - # Get the App. - app = wx.GetApp() - - # First show the controller. - app.gui.show_controller(None) - - # Go to the last line. - app.gui.controller.log_panel.on_goto_end(None) - - # Wait a little while. - sleep(0.5) - - # Execute the user function. - self.execute(self.name, **kargs) - - # Bring the controller to the front. - if self.uf_data.display: - wx.CallAfter(app.gui.controller.Raise) - - - def process_doc(self, doc): - """Process the documentation list. - - @param doc: The documentation in the form of a list of the title and description. - @type doc: list of str - """ - - # The title. - yield doc[0], 'title' - - # Strip the leading whitespace, if needed. - doc[1] = strip_lead(doc[1]) - - # Split up the description. - docstring_lines = split(doc[1], "\n") - - # Initialise. - text = [""] - type = ['desc'] - in_table = False - - # Loop over the lines of the docstring. - for line in docstring_lines: - # Start of the table. - if not in_table and search('___', line): - in_table = True - text.append("") - type.append("table") - - # Add the line to the text. - text[-1] = "%s%s\n" % (text[-1], line) - - # End of the table. - if in_table and line == '': - in_table = False - text.append("") - type.append("desc") - - # Yield the bits. - for i in range(len(text)): - yield text[i], type[i] - - class Uf_storage(dict): """A singleton container for holding all the GUI user functions."""