def on_varWLatexGuessButton_clicked(self): text = str(self.varWScaledText.text()) self.varWLatexText = str2lx.string2Latex(text) self.plotLatex(self.varWLatexText, self.varWLatexImage) self.varWLatexEditButton.setDisabled(False)
def accept(self): """ Save the function's data into a pickle file """ # Set the variables ### extract filename fz = str(self.functionDefinitionText.text()) self.fvars["Yname"], self.fvars["Xname"], independent, self.fvars["Yvalue"] = extractVariables(fz, self) self.fvars["XLatex"] = str2lx.string2Latex(self.fvars["Xname"]) # Check if the name of the function passed to the class (functionName) # is the same given in the function definition # and set it to the latter if different if self.functionName != self.fvars["Yname"]: nameSet = QString("The new function name will be set to : " + self.fvars["Yname"]) QMessageBox.warning(self, nameSet, nameSet) self.pklName = os.path.join(self.dirFiles, self.fvars["Yname"] + ".pkl") # Set the parameters self.fvars["independent"] = str(independent).replace(" ", "") self.fvars["parameterNames"] = str(self.parFittingText.text()).replace(" ", "") # Set the X scaling variables if present _varXscaledText = str(self.varXScaledText.text()).strip() if "=" in _varXscaledText: a, b = _varXscaledText.split("=") self.fvars["XscaledName"], self.fvars["XscaledValue"] = a.strip(), b.strip() try: self.fvars["XscaledLatex"] = self.varXLatexText except: Xerror = QString( "Error: please guess or enter a valid LaTeX string for variable ", self.fvars["XscaledName"] ) QMessageBox.critical(self, "Error in LaTeX", Xerror) self.varXLatexGuessButton.setFocus(True) return else: self.fvars["XscaledName"] = "" self.fvars["XscaledValue"] = "" self.fvars["XscaledLatex"] = "" # Other scaling variables _varWscaledText = str(self.varWScaledText.text()).strip() if "=" in _varWscaledText: a, b = _varWscaledText.split("=") self.fvars["WscaledName"], self.fvars["WscaledValue"] = a.strip(), b.strip() try: self.fvars["WscaledLatex"] = self.varWLatexText except: Werror = QString( "Error: please guess or enter a valid LaTeX string for variable ", self.fvars["WscaledName"] ) QMessageBox.critical(self, "Error in LaTeX", Werror) self.varWLatexGuessButton.setFocus(True) return else: self.fvars["WscaledName"] = "" self.fvars["WscaledValue"] = "" self.fvars["WscaledLatex"] = "" # Y variables self.fvars["Ydefinition"] = str(self.functionDefinitionText.text()) self.fvars["YDescription"] = str(self.functionDescriptionText.text()) self.fvars["YLatex"] = self.functionLatexText _varYscaledText = str(self.varYScaledText.text()).strip() if "=" in _varYscaledText: a, b = _varYscaledText.split("=") self.fvars["YscaledName"], self.fvars["YscaledValue"] = a.strip(), b.strip() try: self.fvars["YscaledLatex"] = self.varYLatexText except: Yerror = QString( "Error: please guess or enter a valid LaTeX string for variable ", self.fvars["YscaledName"] ) QMessageBox.critical(self, "Error in LaTeX", Yerror) self.varYLatexGuessButton.setFocus(True) return else: self.fvars["YscaledName"] = "" self.fvars["YscaledValue"] = "" self.fvars["YscaledLatex"] = "" self.fvars["Ycorrections"] = str(self.correctionFunctionText.text()) self.fvars["Ysign"] = str(self.correctionComboBox.currentText()) self.fvars["parameterNames_corrections"] = self.correctionParamsText.text() # Other variables # self.fvars['independent'] set above # Save on disk F = open(self.pklName, "wb") pickle.dump(self.fvars, F) F.close() # for key in self.fvars: # print key, self.fvars[key] QDialog.accept(self)
def on_functionLatexGuessButton_clicked(self): text = str(self.functionDefinitionText.text()) self.functionLatexText = str2lx.string2Latex(text) self.plotLatex(self.functionLatexText, self.functionLatexImage) self.functionLatexEditButton.setDisabled(False)