From 90afe07406daf50d2b98ea490954a1c95592f520 Mon Sep 17 00:00:00 2001 From: Paul S Date: Tue, 29 Jun 2021 16:29:16 +0200 Subject: [PATCH] Results rounded to two digits --- changelog.md | 3 ++- src/main.py | 19 +++++++++++-------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/changelog.md b/changelog.md index fed3f67..73058ff 100644 --- a/changelog.md +++ b/changelog.md @@ -1,8 +1,9 @@ # Changelog GarageCalc1 -## [0.2] - 2021-06-27 +## [0.3] - 2021-06-29 ### Added - Warnt beim Beenden falls ungespeicherte Einträge vorhanden sind +- Alle Ergebnisse aufrunden auf 2 Nachkommastellen ## [0.2] - 2021-06-27 ### Added diff --git a/src/main.py b/src/main.py index baf068f..7ca07de 100644 --- a/src/main.py +++ b/src/main.py @@ -23,9 +23,10 @@ from PySide2.QtUiTools import QUiLoader from utils import show_about, resource_path # Local globals +APP_VERSION = "v0.3.1" + APP_NAME = "Garagenraum-Rechner" APP_DISPNAME = "GarageCalc" -APP_VERSION = "v0.3" APP_AUTHOR = "Paul Salajean" APP_DESCR = "Berechnet zur Verfügung stehenden Garagenraum" APP_COPYRIGHT = "(c) Paul Salajean 2021" @@ -667,7 +668,7 @@ class MyMainWindow(QMainWindow): is_error = True if not is_error: - garage_vol = garage_length * float(garage_width) * float(garage_height) + garage_vol = round(float(garage_length) * float(garage_width) * float(garage_height), 2) else: garage_vol = 0.0 self.statusBar.showMessage("Fehler in der Garagen-Dimension. :-(", 5000) @@ -716,7 +717,7 @@ class MyMainWindow(QMainWindow): height = 0 is_error = True - vol = length * width * height + vol = round(length * width * height, 2) stuff_vol = stuff_vol + vol @@ -731,14 +732,16 @@ class MyMainWindow(QMainWindow): # get garage vol garage_vol = self.get_garage_vol() + print("garage_vol", garage_vol) # get stuff vol stuff_vol = self.get_stuff_vol() + print("stuff_vol", stuff_vol) # display results - self.ui.efVol_Garage.setText(str(garage_vol)) - self.ui.efVol_Stuff.setText(str(stuff_vol)) - self.ui.efVol_Free.setText(str(garage_vol - stuff_vol)) + self.ui.efVol_Garage.setText(f"{garage_vol:2.2f}") + self.ui.efVol_Stuff.setText(f"{stuff_vol:2.2f}") + self.ui.efVol_Free.setText(f"{garage_vol - stuff_vol:2.2f}") if ( garage_vol - stuff_vol ) < 0: self.ui.efVol_Free.setStyleSheet("border: 1px solid red;") @@ -761,9 +764,9 @@ class MyMainWindow(QMainWindow): except ValueError: weight = 0.0 - weight_sum = weight_sum + weight + weight_sum = round(weight_sum + weight, 2) - self.ui.efWeight.setText(str(weight_sum)) + self.ui.efWeight.setText(f"{weight_sum:2.2f}") if __name__ == "__main__":