math-expert
math-expert copied to clipboard
Better define methods in `main.py`
Currently, exec is used, which is very unpythonic and inefficient. There should be a way to get all the functions in the func.py and link them accordingly.
operations = ["inte", "diff", "lim", "fact", "sol",
"simp", "eval", "plot", "generate_pdf", "generate_latex"]
for func in operations:
exec(f"""
\n@pyqtSlot()
\ndef on_{func}_bt_clicked(self):
\n self.mathdoc.{func}(self.expression.toPlainText().\
replace(" ", ""))
""")
https://stackoverflow.com/a/49631500