-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
77 lines (65 loc) · 2.64 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# Doc: https://raw.githubusercontent.com/PySimpleGUI/PySimpleGUI/master/PySimpleGUI.py
import PySimpleGUI as sg
from database.models import create_tables
from ui.menu import create_menu
from ui.shortcuts import create_shortcut
from ui.footer import create_footer
from component import projects_tasks
from component import project
from component import task
def create_todo_gui():
"""
This function is creating the GUI for this application.
"""
sg.theme("DarkAmber")
menu = create_menu()
shortcut = create_shortcut()
footer = create_footer()
projects_tasks_section = projects_tasks.create_projects_tasks_section()
layout = [
[menu],
[shortcut],
[projects_tasks_section],
[footer],
]
right_click_menu = ["unused", ["Open", "Quit"]]
window = sg.Window("Time Tracker Application",
layout=layout,
right_click_menu=right_click_menu,
resizable=True,
icon=r"./assets/icon.png",
size=(600, 400)) # Adjust the size as per your needs
tree = window['-PROJECT-TASK-TREE-']
while True:
event, values = window.read()
print(event, values)
if event == sg.WINDOW_CLOSED or event == "Quit":
break
elif event == "Open":
pass
# filename = sg.popup_get_file("File to open", no_window=False)
# print(filename)
elif event == "About":
window.disappear()
sg.popup('Time Tracker', 'Version 1.0', 'Simple time tracker application', 'Track your time by task')
window.reappear()
elif event == "New Project":
project.project_form(tree)
elif event == "New Task":
task.task_form(tree)
elif event == "-PROJECT-TASK-TREE-":
if values["-PROJECT-TASK-TREE-"][0].startswith('task-'): # Check if any item is selected in the tree
window['-START-TASK-'].update(disabled=False)
window['-PAUSE-TASK-'].update(disabled=False)
window['-END-TASK-'].update(disabled=False)
else:
window['-START-TASK-'].update(disabled=True)
window['-PAUSE-TASK-'].update(disabled=True)
window['-END-TASK-'].update(disabled=True)
elif event.endswith('-TASK-') and values["-PROJECT-TASK-TREE-"][0].startswith('task-'):
task.update_task(event=event, value=values["-PROJECT-TASK-TREE-"][0])
# print(event, values["-PROJECT-TASK-TREE-"])
window.close()
if __name__ == "__main__":
create_tables()
create_todo_gui()