-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTask 3 to do list.txt
116 lines (62 loc) · 2.24 KB
/
Task 3 to do list.txt
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
from tkinter import *
from tkinter import messagebox
tasks_list = []
counter = 1
def inputError() :
if enterTaskField.get() == "" :
messagebox.showerror("Input Error")
return 0
return 1
def clear_taskNumberField() :
taskNumberField.delete(0.0, END)
def clear_taskField() :
enterTaskField.delete(0, END)
def insertTask():
global counter
value = inputError()
if value == 0 :
return
content = enterTaskField.get() + "\n"
tasks_list.append(content)
TextArea.insert('end -1 chars', "[ " + str(counter) + " ] " + content)
counter += 1
clear_taskField()
def delete() :
global counter
if len(tasks_list) == 0 :
messagebox.showerror("No task")
return
number = taskNumberField.get(1.0, END)
if number == "\n" :
messagebox.showerror("input error")
return
else :
task_no = int(number)
clear_taskNumberField()
tasks_list.pop(task_no - 1)
counter -= 1
TextArea.delete(1.0, END)
for i in range(len(tasks_list)) :
TextArea.insert('end -1 chars', "[ " + str(i + 1) + " ] " + tasks_list[i])
if __name__ == "__main__" :
gui = Tk()
gui.configure(background = "light green")
gui.title("ToDo App")
gui.geometry("250x300")
enterTask = Label(gui, text = "Enter Your Task", bg = "light green")
enterTaskField = Entry(gui)
Submit = Button(gui, text = "Submit", fg = "Black", bg = "pink", command = insertTask)
TextArea = Text(gui, height = 5, width = 25, font = "lucida 13")
taskNumber = Label(gui, text = "Delete Task Number", bg = "light blue")
taskNumberField = Text(gui, height = 1, width = 2, font = "lucida 13")
delete = Button(gui, text = "Delete", fg = "Black", bg = "pink", command = delete)
Exit = Button(gui, text = "Exit", fg = "Black", bg = "pink", command = exit)
enterTask.grid(row = 0, column = 2)
enterTaskField.grid(row = 1, column = 2, ipadx = 50)
Submit.grid(row = 2, column = 2)
TextArea.grid(row = 3, column = 2, padx = 10, sticky = W)
taskNumber.grid(row = 4, column = 2, pady = 5)
taskNumberField.grid(row = 5, column = 2)
delete.grid(row = 6, column = 2, pady = 5)
Exit.grid(row = 7, column = 2)
gui.mainloop()