def payload(save_group=df._current_group): import numpy as np input_variables = {} for variable in self.controls.keys(): if variable == 'save_returned' or variable == 'start' or variable == 'function name': continue variable_control = self.controls[variable] if type(variable_control) == type(QtWidgets.QLineEdit( )) and variable_control.isReadOnly() == True: fullargs = inspect.getargspec(self.function) args = fullargs.args try: args.remove('self') except ValueError: pass args = np.array(args) defaults = np.array(fullargs.defaults) default_value = defaults[args == variable] input_variables[variable] = default_value[0] print variable, default_value elif (type(variable_control) == QtWidgets.QSpinBox or type(variable_control) == QtWidgets.QDoubleSpinBox): input_variables[variable] = variable_control.value() elif type(variable_control) == QtWidgets.QLineEdit: try: exec 'temp_var = ' + variable_control.text() in locals( ) input_variables[variable] = temp_var except Exception as e: print e print 'Qlineedit input error for ', variable elif type(variable_control) == QtWidgets.QCheckBox: input_variables[variable] = variable_control.isChecked() try: function_returns = self.function(**input_variables) except TypeError: print input_variables print 'function: ', task print 'Did not recieve the correct inputs!' print 'did you make an error in your lineedit inputs?' if self.controls['save_returned'].isChecked() == True: save_group.create_dataset(task, data=function_returns, attrs=input_variables)
def add_lineedit(self, name): """Add a single-line text box control.""" le = QtWidgets.QLineEdit() self.controls[name] = le le.setObjectName(name + "_lineedit") self.layout().addRow(name.title(), le)