Skip to content

Commit

Permalink
If the line is empty, a zero is added, an icon is added to the About …
Browse files Browse the repository at this point in the history
…window title
  • Loading branch information
limafresh committed Oct 29, 2024
1 parent 5398c79 commit 8ff4531
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "pyqulator"
version = "1.7.1"
version = "1.8.0"
dependencies = [
"PyQt6>=6.4.2",
"sympy>=1.13.3",
Expand Down
21 changes: 21 additions & 0 deletions src/pyqulator/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,34 +232,44 @@ def log(self):
self.current_line_result.setText(str(res).rstrip("0").rstrip("."))
except Exception as e:
QMessageBox.warning(self, "Error", str(e))
if self.current_line_result.text() == "":
self.current_line_result.setText("0")

def sin(self):
try:
res = sin(sympify(self.current_line_result.text()).evalf())
self.current_line_result.setText(str(res).rstrip("0").rstrip("."))
except Exception as e:
QMessageBox.warning(self, "Error", str(e))
if self.current_line_result.text() == "":
self.current_line_result.setText("0")

def cos(self):
try:
res = cos(sympify(self.current_line_result.text()).evalf())
self.current_line_result.setText(str(res).rstrip("0").rstrip("."))
except Exception as e:
QMessageBox.warning(self, "Error", str(e))
if self.current_line_result.text() == "":
self.current_line_result.setText("0")

def tan(self):
try:
res = tan(sympify(self.current_line_result.text()).evalf())
self.current_line_result.setText(str(res).rstrip("0").rstrip("."))
except Exception as e:
QMessageBox.warning(self, "Error", str(e))
if self.current_line_result.text() == "":
self.current_line_result.setText("0")

def exp(self):
try:
res = exp(sympify(self.current_line_result.text()).evalf())
self.current_line_result.setText(str(res).rstrip("0").rstrip("."))
except Exception as e:
QMessageBox.warning(self, "Error", str(e))
if self.current_line_result.text() == "":
self.current_line_result.setText("0")

def pi(self):
try:
Expand All @@ -270,6 +280,8 @@ def pi(self):
self.current_line_result.setText(str(res).rstrip("0").rstrip("."))
except Exception as e:
QMessageBox.warning(self, "Error", str(e))
if self.current_line_result.text() == "":
self.current_line_result.setText("0")

def e(self):
try:
Expand All @@ -280,27 +292,35 @@ def e(self):
self.current_line_result.setText(str(res).rstrip("0").rstrip("."))
except Exception as e:
QMessageBox.warning(self, "Error", str(e))
if self.current_line_result.text() == "":
self.current_line_result.setText("0")

def procent(self):
try:
res = (sympify(self.current_line_result.text()) / Rational(100)).evalf()
self.current_line_result.setText(str(res).rstrip("0").rstrip("."))
except Exception as e:
QMessageBox.warning(self, "Error", str(e))
if self.current_line_result.text() == "":
self.current_line_result.setText("0")

def radical(self):
try:
res = (sympify(self.current_line_result.text())).evalf()
self.current_line_result.setText(str(sqrt(res)).rstrip("0").rstrip("."))
except Exception as e:
QMessageBox.warning(self, "Error", str(e))
if self.current_line_result.text() == "":
self.current_line_result.setText("0")

def square(self):
try:
res = (sympify(self.current_line_result.text()) * sympify(self.current_line_result.text())).evalf()
self.current_line_result.setText(str(res).rstrip("0").rstrip("."))
except Exception as e:
QMessageBox.warning(self, "Error", str(e))
if self.current_line_result.text() == "":
self.current_line_result.setText("0")

# Journal functions
def clear_journal(self):
Expand Down Expand Up @@ -569,6 +589,7 @@ def show_about_program(self):
"""
self.about_msg.setText(msg_text)
icon = QIcon.fromTheme("accessories-calculator")
self.about_msg.setWindowIcon(icon)
self.about_msg.setIconPixmap(icon.pixmap(32, 32))
self.about_msg.exec()

Expand Down

0 comments on commit 8ff4531

Please sign in to comment.