-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdoing.py
143 lines (106 loc) · 3.4 KB
/
doing.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
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#import module
from tkinter import *
from tkinter import messagebox
import importlib
import coins as cn
from openpyxl import Workbook
from openpyxl import load_workbook
wb = load_workbook("Tasks.xlsx")
wsheet = wb.active
#create mainloop
def doing_main():
global ws
ws =Tk()
ws.geometry('800x400+500+200')
ws.title('Your Tasklist')
ws.config(bg='#8ebebd')
ws.resizable(width=False,height=False)
frame=Frame(ws)
frame.pack(pady=10)
global lb
lb=Listbox(
frame,#putting the listbox on the frame
width=25,
height=8,
font=('Courier',16, 'bold'),
bd=0,
fg='#464646',
highlightthickness=10,
selectbackground='#000000',
activestyle="none",
)
lb.pack(side=LEFT, fill=BOTH)
for row in wsheet.iter_rows(values_only=True):
task = row[0]
lb.insert(END, task)
sb=Scrollbar(frame, activebackground = '#5da2a1')
sb.pack(side=RIGHT, fill=Y)
lb.config(yscrollcommand=sb.set)
sb.config(command=lb.yview)
global my_entry
my_entry=Entry(
ws,
font=('Courier',24, 'bold')
)
my_entry.pack(pady=20)
button_frame=Frame(ws)
button_frame.pack(pady=20)
addTask_btn=Button(
button_frame,
text='Add Task',
font=('Courier', 14, 'bold'),
bg='#c5f776',
padx=20,
pady=10,
command=newTask
)
addTask_btn.pack(fill=BOTH, expand=True, side=LEFT)
delTask_btn = Button(
button_frame,
text='Delete Task',
font=('Courier', 14, 'bold'),
bg='#ff8b61',
padx=20,
pady=10,
command=deleteTask
)
delTask_btn.pack(fill=BOTH,expand=True,side=LEFT)
return_btn = Button(
button_frame,
text = 'Return to Menu',
font = ('Courier', 14, 'bold'),
bg = '#ff8b61',
padx = 20,
pady = 10,
command = goBack
)
return_btn.pack(fill=BOTH,expand=True,side=LEFT)
ws.mainloop()
def newTask():
task=my_entry.get()#storing the task entered by the user in taask variable
if task !="":
lb.insert(END, task)#indicates every new task will be added at the end of the listbox
wsheet.append([task,])
my_entry.delete(0, "end")#to erase the new task from the entry box
wb.save("Tasks.xlsx")
else:
messagebox.showwarning("Warning","Please enter some task")
def deleteTask():
selected_task_index = lb.curselection()
if selected_task_index:
task_index = selected_task_index[0] #index of selected task in listbox
lb.delete(task_index) # Delete the selected task from the Listbox
cn.coin_increase(100)
## wb = load_workbook("Tasks.xlsx")
## wsheet = wb.active
rowcount=wsheet.max_row
for row in range (rowcount):
if row == task_index:
wsheet.delete_rows(row+1) #because .xlsx file mein index 1 zyaada hota hai
wb.save("Tasks.xlsx")
else:
messagebox.showwarning("Warning", "Please select a task to delete")
def goBack():
ws.destroy()
main = importlib.import_module('menu')
main.main_menu()