From 29e3234b1e02c66ad8875b6d94f49eaf009978dd Mon Sep 17 00:00:00 2001 From: Philipp Date: Thu, 30 May 2019 16:12:51 +0200 Subject: [PATCH] t --- calculation.py | 1 + day.py | 18 +++++++----------- ui.py | 25 ++++++++++++++++--------- 3 files changed, 24 insertions(+), 20 deletions(-) diff --git a/calculation.py b/calculation.py index 7f61a1f..1fb4b38 100644 --- a/calculation.py +++ b/calculation.py @@ -1,4 +1,5 @@ + def hoursSpent(day_start, day_end, break_start, break_end): duration_whole = day_end - day_start print("duration_whole", duration_whole) diff --git a/day.py b/day.py index e28b3b0..3aa9545 100644 --- a/day.py +++ b/day.py @@ -47,15 +47,11 @@ class Day: self.date: str = datetime.now().date() - self.begin: datetime = datetime.__init__ - - self.end: datetime = datetime.__init__ - - self.begin_break: datetime = datetime.__init__ - - self.end_break: datetime = datetime.__init__ - - self.duration: datetime = datetime.__init__ + self.begin = 0 + self.end = 0 + self.begin_break = 0 + self.end_break = 0 + self.duration = 0 self.isDayStarted: bool = False self.isBreakDone: bool = False @@ -63,7 +59,7 @@ class Day: def beginDay(self): '''Saves the time where a new day was started.''' - self.begin = datetime.now() + self.begin_break = datetime.now() self.isDayStarted = True def make_break(self): @@ -74,7 +70,7 @@ class Day: raise AssertionError( "You are already in break or have done your break already") - self.beingin_break = datetime.now() + self.begin = datetime.now() self.isInBreak = True def stop_break(self): diff --git a/ui.py b/ui.py index f41d72e..aaac0ab 100644 --- a/ui.py +++ b/ui.py @@ -19,32 +19,39 @@ class Application(tk.Frame): self.quit.pack(side="bottom") self.begin_day = tk.Button( - self, text="begin day", command=self.bd) + self, text="begin day", command=self.day_begin) self.begin_day.pack(side="left") - self.end_day = tk.Button(self, text="end day", command=self.ed) + self.end_day = tk.Button(self, text="end day", command=self.day_end) self.end_day.pack(side="right") - self.begin_pause = tk.Button(self, text="begin pause", command=self.mb) + self.begin_pause = tk.Button( + self, text="begin pause", command=self.make_brake) self.begin_pause.pack(side="left") - self.end_pause = tk.Button(self, text="end pause", command=self.go) + self.end_pause = tk.Button( + self, text="end pause", command=self.stop_break) self.end_pause.pack(side="right") - def bd(self): + def day_begin(self): self.day.beginDay() self.hi_there["text"] = "Started day" - def ed(self): + def day_end(self): + if not self.day.is_day_started(): + '''change field to: du musst erst day starten''' + return + self.day.endDay() self.hi_there["text"] = "Good Bye" + self.day = Day() - def mb(self): + def make_brake(self): self.day.make_break() self.hi_there["text"] = "Have a nice lunch" - def go(self): - self.day.go_on() + def stop_break(self): + self.day.stop_break() self.hi_there["text"] = "Welcome back"