def repr(self): """ Build the python script. """ # Compile output from the plugins output = dict() for plugin in self._plugins.itervalues(): for key, value in plugin.repr().iteritems(): if key in output: output[key] += value else: output[key] = value # Make import unique mooseutils.unique_list(output['imports'], output['imports']) # Apply the filters, if they exist if 'filters' in output: filters = [] for match in re.findall(r'^(\w+)\s*=', '\n'.join(output['filters']), flags=re.MULTILINE): filters.append(match) output['result'] += ['result.setOptions(filters=[{}])'.format(', '.join(filters))] # Build the script string = '' for key in ['imports', 'camera', 'reader', 'filters', 'result', 'window']: if key in output: string += '\n{}\n'.format('\n'.join(output.pop(key))) # Error if keys exist, this means data is missing from the script if output: raise mooseutils.MooseException('The output data was not completely written, the following keys remain: {}'.format(str(output.keys()))) return string
def repr(self): """ Build the python script. """ # Compile output from the plugins output = dict() for plugin in self._plugins.itervalues(): for key, value in plugin.repr().iteritems(): if key in output: output[key] += value else: output[key] = value # Add colorbar to window if 'colorbar' in output: output['window'][0] = 'window = chigger.RenderWindow(result, cbar)' # Make import unique mooseutils.unique_list(output['imports'], output['imports']) # Apply the filters, if they exist if 'filters' in output: filters = [] for match in re.findall(r'^(\w+)\s*=', '\n'.join(output['filters']), flags=re.MULTILINE): filters.append(match) output['result'] += [ 'result.setOptions(filters=[{}])'.format(', '.join(filters)) ] # Build the script string = '' for key in [ 'imports', 'camera', 'reader', 'filters', 'result', 'colorbar', 'window' ]: if key in output: string += '\n{}\n'.format('\n'.join(output.pop(key))) # Error if keys exist, this means data is missing from the script if output: raise mooseutils.MooseException( 'The output data was not completely written, the following keys remain: {}' .format(str(output.keys()))) return string
def repr(self): """ Writes a python script for reproducing the actions of this widget. """ # Setup output = [] imports = [] # Build script from plugins for plugin in self._plugins.itervalues(): out, imp = plugin.repr() output += out mooseutils.unique_list(imports, imp) return '\n'.join(imports + [''] + output)
def onVariablesChanged(self, x_vars, y_vars, y2_vars): """ Update the default variable names. """ # Create a single list of uniqne names x = [] y = [] y2 = [] for i in range(len(x_vars)): mooseutils.unique_list(x, x_vars[i]) mooseutils.unique_list(y, y_vars[i]) mooseutils.unique_list(y2, y2_vars[i]) # Update the default labels self.XAxisTab.setLabelDefault(x) self.YAxisTab.setLabelDefault(y) self.Y2AxisTab.setLabelDefault(y2) self.XAxisTab._callbackLabel() self.YAxisTab._callbackLabel() self.Y2AxisTab._callbackLabel() # Update the limits if self._axes != None: self.blockSignals(True) self.XAxisTab.setLimit(0) self.XAxisTab.setLimit(1) self.YAxisTab.setLimit(0) self.YAxisTab.setLimit(1) self.Y2AxisTab.setLimit(0) self.Y2AxisTab.setLimit(1) self.blockSignals(False)
def onVariablesChanged(self, x_vars, y_vars, y2_vars): """ Update the default variable names. """ # Create a single list of uniqne names x = []; y = []; y2 = [] for i in range(len(x_vars)): mooseutils.unique_list(x, x_vars[i]) mooseutils.unique_list(y, y_vars[i]) mooseutils.unique_list(y2, y2_vars[i]) # Update the default labels self.XAxisTab.setLabelDefault(x) self.YAxisTab.setLabelDefault(y) self.Y2AxisTab.setLabelDefault(y2) self.XAxisTab._callbackLabel() self.YAxisTab._callbackLabel() self.Y2AxisTab._callbackLabel() # Update the limits if self._axes != None: self.blockSignals(True) self.XAxisTab.setLimit(0) self.XAxisTab.setLimit(1) self.YAxisTab.setLimit(0) self.YAxisTab.setLimit(1) self.Y2AxisTab.setLimit(0) self.Y2AxisTab.setLimit(1) self.blockSignals(False)