|
@@ -0,0 +1,80 @@
|
|
|
+import PySimpleGUI
|
|
|
+from time_recoder.time_recoder_gui.time_recorder_gui_config import PAUSE_BUTTON_TEXT, START_BUTTON_TEXT, STOP_BUTTON_TEXT, \
|
|
|
+ STOP_BUTTON_INTRODUCTION_TEXT, PAUSE_BUTTON_INTRODUCTION_TEXT, WINDOW_SIZE
|
|
|
+from time_recoder import save_recorded_time_in_table
|
|
|
+
|
|
|
+
|
|
|
+def create_layout():
|
|
|
+ return [
|
|
|
+ [PySimpleGUI.Text(PAUSE_BUTTON_INTRODUCTION_TEXT)],
|
|
|
+ [PySimpleGUI.Text(STOP_BUTTON_INTRODUCTION_TEXT)],
|
|
|
+ [PySimpleGUI.Button(START_BUTTON_TEXT),
|
|
|
+ PySimpleGUI.Button(PAUSE_BUTTON_TEXT),
|
|
|
+ PySimpleGUI.Button(STOP_BUTTON_TEXT)]
|
|
|
+ ]
|
|
|
+
|
|
|
+
|
|
|
+def create_window(layout):
|
|
|
+ return PySimpleGUI.Window('END_TR300 Arbeitserfassungstool ', layout=layout, size=WINDOW_SIZE)
|
|
|
+
|
|
|
+
|
|
|
+def window_is_closed(event):
|
|
|
+ return event == PySimpleGUI.WIN_CLOSED
|
|
|
+
|
|
|
+
|
|
|
+def stop_button_is_pushed(event):
|
|
|
+ return event == STOP_BUTTON_TEXT
|
|
|
+
|
|
|
+
|
|
|
+def start_button_is_pushed(event):
|
|
|
+ return event == START_BUTTON_TEXT
|
|
|
+
|
|
|
+
|
|
|
+def pause_button_is_pushed(event):
|
|
|
+ return event == PAUSE_BUTTON_TEXT
|
|
|
+
|
|
|
+
|
|
|
+def event_loop(window):
|
|
|
+ while True:
|
|
|
+ event, values = window.read()
|
|
|
+ if window_is_closed(event):
|
|
|
+ break
|
|
|
+ if start_button_is_pushed(event):
|
|
|
+ print('Start Time')
|
|
|
+ if 'start_time' in locals():
|
|
|
+ if 'pause_time' in locals():
|
|
|
+ print('Time updated, Pause Timer Reseted')
|
|
|
+ start_time = start_time + (pause_time - save_recorded_time_in_table.get_current_time_as_timestamp())
|
|
|
+ pause_time = 'reseted'
|
|
|
+ else:
|
|
|
+ pass
|
|
|
+ else:
|
|
|
+ start_time = save_recorded_time_in_table.get_current_time_as_timestamp()
|
|
|
+ if pause_button_is_pushed(event):
|
|
|
+ print('Pause Timer Activated')
|
|
|
+ if 'pause_time' in locals():
|
|
|
+ if pause_time == 'reseted':
|
|
|
+ print('New Pause Timer Activated')
|
|
|
+ pause_time = save_recorded_time_in_table.get_current_time_as_timestamp()
|
|
|
+ else:
|
|
|
+ pass
|
|
|
+ else:
|
|
|
+ pause_time = save_recorded_time_in_table.get_current_time_as_timestamp()
|
|
|
+ if stop_button_is_pushed(event):
|
|
|
+ print('Timer Stoped Recording, Close the Window')
|
|
|
+ if 'start_time' in locals():
|
|
|
+ worked_time_in_minutes = (save_recorded_time_in_table.get_current_time_as_timestamp() - start_time) / 60
|
|
|
+ save_recorded_time_in_table.save_recorded_time_in_table(worked_time_in_minutes)
|
|
|
+ else:
|
|
|
+ pass
|
|
|
+
|
|
|
+
|
|
|
+def gui_main():
|
|
|
+ layout = create_layout()
|
|
|
+ window = create_window(layout)
|
|
|
+ event_loop(window)
|
|
|
+ window.close()
|
|
|
+
|
|
|
+
|
|
|
+if __name__ == '__main__':
|
|
|
+ gui_main()
|