math-expert icon indicating copy to clipboard operation
math-expert copied to clipboard

Better define methods in `main.py`

Open salastro opened this issue 3 years ago • 1 comments

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(" ", ""))
        """)

salastro avatar May 23 '22 20:05 salastro

https://stackoverflow.com/a/49631500

salastro avatar May 27 '22 13:05 salastro