Using ChatGPT I have tried to create a calculator like the one I am looking for.
With
Python and
PyQt6, to make it cross-platform.
With
mathjs, so that it has all its functions.
With
QuickJS, to have a lightweight Javascript interpreter, so you can have mathjs updated without any problem.
There is mathjs for Python,
mathjspy, however, it is not updated often
This is the source code of the program so far:
QuickMathPad
import sys
from PyQt6.QtWidgets import QApplication, QWidget, QTextEdit, QHBoxLayout
from PyQt6.QtCore import Qt
from quickjs import Context
class MyApp(QWidget):
def __init__(self):
super().__init__()
self.setWindowTitle("QuickMathPad")
self.setMinimumSize(512, 320)
self.resize(512, 320)
self.layout = QHBoxLayout()
self.setLayout(self.layout)
self.text_edit_left = QTextEdit()
self.layout.addWidget(self.text_edit_left)
self.text_edit_right = QTextEdit()
self.layout.addWidget(self.text_edit_right)
self.text_edit_left.textChanged.connect(self.evaluate_expression)
self.context = Context()
self.context.eval(open("math.js").read())
def evaluate_expression(self):
lines = self.text_edit_left.toPlainText().split('\n')
results = []
for line in lines:
try:
result = self.context.eval(line)
results.append(str(result))
except Exception as e:
results.append(str(e))
self.text_edit_right.setText('\n'.join(results))
app = QApplication(sys.argv)
window = MyApp()
window.show()
sys.exit(app.exec())
Things I would like to correct:Allow comments using #
Fix bugs like using percentage '%', blank lines showing as "None".
In general, make it have the same functionality as Numara.
If someone knows Python and wants to fix these problems it would be great.
Or create your own version in some fast, portable and lightweight language?
Such as Lua, AutoHotKey, etc, Rust?