-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgui.py
More file actions
40 lines (36 loc) · 1.3 KB
/
gui.py
File metadata and controls
40 lines (36 loc) · 1.3 KB
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
import functions
import FreeSimpleGUI as sg
label = sg.Text("Type in a To-Do")
input_box = sg.InputText(tooltip = "Enter a To-Do", key = "todo")
add_button = sg.Button("Add")
list_box = sg.Listbox(values = functions.get_todos(), key = "todos",
enable_events = True, size = [45, 10])
edit_button = sg.Button("Edit")
window = sg.Window("My To-Do App",
layout=[[label],[input_box, add_button], [list_box, edit_button]],
font=("Helvetica", 20))
while True:
event, values = window.read()
print(1, event)
print(2, values)
print(3, values["todos"])
match event:
case "Add":
todos = functions.get_todos()
new_todo = values["todo"] + "\n"
todos.append(new_todo)
functions.write_todos(todos)
window["todos"].update(values=todos)
case "Edit":
todo_to_edit = values["todos"][0]
new_todo = values["todo"]
todos = functions.get_todos()
index = todos.index(todo_to_edit)
todos[index] = new_todo
functions.write_todos(todos)
window["todos"].update(values = todos)
case "todos":
window["todo"].update(value = values["todos"][0])
case sg.WIN_CLOSED:
break
window.close()