-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNew_Task_Window.py
59 lines (48 loc) · 2.21 KB
/
New_Task_Window.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
import tinydb
from guizero import PushButton, Text, TextBox, Window
def Export(database): # Export data to database
global finish, name, description, priority
global window2
tasks = database.table("Tasks")
# Check if task name already exists
ExistingTasks = tasks.search(tinydb.Query().task_name == name.value)
if len(ExistingTasks) != 0:
# If it does, add '- Copy' to the end of the name
name.value = name.value + "- Copy"
tasks.insert(
{
"task_name": name.value,
"task_description": description.value,
"task_priority": priority.value,
"process_status": "UTILIZE",
}
) # Add task to database
window2.destroy() # Close window
def CancelTask():
global finish, name, description, priority
global window2
# If all fields are empty, close window
if name.value == "" and description.value == "" and priority.value == "0":
window2.destroy()
else:
# Ask user if they are sure they want to cancel
result = window2.yesno("Cancel", "Are you sure you want to cancel?")
if result == True: # If user is sure, close window
window2.destroy()
def NewTask(main_window, database): # Create new task window
global finish, name, description, priority
global window2
window2 = Window(main_window, title="New Task", layout="grid", width=1100, height=700)
welcome_message = Text(window2, text="Task Maker", size=18, font="Times New Roman", grid=[1, 0])
name_text = Text(window2, text="Task Name", size=15, font="Times New Roman", grid=[0, 1])
name = TextBox(window2, grid=[1, 1], width=30)
# shipping info
description_text = Text(
window2, text="Description", size=15, font="Times New Roman", grid=[0, 3]
)
description = TextBox(window2, grid=[1, 3], width=60, multiline=True, height=15)
priority_text = Text(window2, text="Priority", size=15, font="Times New Roman", grid=[0, 7])
priority = TextBox(window2, grid=[1, 7], width=10, text="0")
# items header
finish = PushButton(window2, command=Export, text="Save", grid=[0, 19], args=[database])
cancel = PushButton(window2, command=CancelTask, text="Cancel", grid=[1, 19])