-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1.To-Do-List.py
More file actions
75 lines (64 loc) · 2.33 KB
/
1.To-Do-List.py
File metadata and controls
75 lines (64 loc) · 2.33 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
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
#importing packages
from tkinter import *
import tkinter.messagebox
window=Tk()
#giving a title
window.title("To-Do List APPLICATION")
window.mainloop()
#creating the initial window
window=Tk()
#giving a title
window.title("To-Do List APPLICATION")
#Frame widget to hold the listbox and the scrollbar
frame_task=Frame(window)
frame_task.pack()
#to hold items in a listbox
listbox_task=Listbox(frame_task,bg="black",fg="white",height=15,width=50,font = "Helvetica")
listbox_task.pack(side=tkinter.LEFT)
#Scrolldown in case the total list exceeds the size of the given window
scrollbar_task=Scrollbar(frame_task)
scrollbar_task.pack(side=tkinter.RIGHT,fill=tkinter.Y)
listbox_task.config(yscrollcommand=scrollbar_task.set)
scrollbar_task.config(command=listbox_task.yview)
#Button widget
entry_button=Button(window,text="Add task",width=50,command="ENTERTASK")
entry_button.pack(pady=3)
delete_button=Button(window,text="Delete selected task",width=50,command="deletetask")
delete_button.pack(pady=3)
mark_button=Button(window,text="Mark as completed ",width=50,command="markcompleted")
mark_button.pack(pady=3)
window.mainloop()
def entertask():
#A new window to pop up to take input
input_text=""
def add():
input_text=entry_task.get(1.0, "end-1c")
if input_text=="":
tkinter.messagebox.showwarning(title="Warning!",message="Please Enter some Text")
else:
listbox_task.insert(END,input_text)
#close the root1 window
root1.destroy()
root1=Tk()
root1.title("Add task")
entry_task=Text(root1,width=40,height=4)
entry_task.pack()
button_temp=Button(root1,text="Add task",command=add)
button_temp.pack()
root1.mainloop()
#function to facilitate the delete task from the Listbox
def deletetask():
#selects the selected item and then deletes it
selected=listbox_task.curselection()
listbox_task.delete(selected[0])
#Executes this to mark completed
def markcompleted():
marked=listbox_task.curselection()
temp=marked[0]
#store the text of selected item in a string
temp_marked=listbox_task.get(marked)
#update it
temp_marked=temp_marked+" ✔"
#delete it then insert it
listbox_task.delete(temp)
listbox_task.insert(temp,temp_marked)