OlgaKo commited on
Commit
bfeb399
1 Parent(s): 9bb2f41

Upload 15 files

Browse files
Files changed (15) hide show
  1. Dokerfile +6 -0
  2. README.md +1 -10
  3. aaa.png +0 -0
  4. bb.png +0 -0
  5. c.png +0 -0
  6. cr.png +0 -0
  7. m.png +0 -0
  8. money.png +0 -0
  9. pc.png +0 -0
  10. picture.png +0 -0
  11. planer.py +390 -0
  12. requirements.txt +10 -0
  13. ru +378 -0
  14. settings +1 -0
  15. your_story.txt +1 -0
Dokerfile ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ FROM python:alpine
2
+ WORKDIR /app
3
+ COPY _ /app
4
+ RUN pip3 install -r requiremens.txt
5
+ EXPOSE 5000
6
+ CMD ["python3", "planer.py"]
README.md CHANGED
@@ -1,10 +1 @@
1
- ---
2
- title: Hellper
3
- emoji: 🌖
4
- colorFrom: blue
5
- colorTo: gray
6
- sdk: docker
7
- pinned: false
8
- ---
9
-
10
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
+ # Planer
 
 
 
 
 
 
 
 
 
aaa.png ADDED
bb.png ADDED
c.png ADDED
cr.png ADDED
m.png ADDED
money.png ADDED
pc.png ADDED
picture.png ADDED
planer.py ADDED
@@ -0,0 +1,390 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from tkinter import *
2
+ import geocoder
3
+ from tkcalendar import Calendar, DateEntry
4
+ from tkinter import Label, Tk, ttk
5
+ from PIL import Image, ImageTk
6
+ import requests
7
+ from tkinter import font
8
+ import smtplib
9
+ from datetime import timedelta
10
+ from datetime import datetime
11
+ from datetime import *
12
+ import os
13
+
14
+ sring_my = '''\n\n\n\nHello!\n\nI am called to rescue you from the hellish chaos of life. Where you can define your path, divide it into stages, understand the possibilities of time and your pace. And what is very important, you can see all the work done and admire yourself.\n\nI'll always keep you posted.'''
15
+ type_to_image = {'programming': Image.open("pc.png"), 'health': Image.open("m.png"), 'erudition': Image.open("cr.png"),
16
+ 'work': Image.open("money.png"), 'cleanliness': Image.open("c.png")}
17
+
18
+
19
+ # gmail_message
20
+ # smtpobj = smtplib.SMTP('smtp.gmail.com', 587)
21
+ # smtpobj.starttls()
22
+ # smtpobj.login('anastasiya.schabanowa2014@gmail.com','NIkapirog992!')
23
+ # smtpobj.sendmail("anastasiya.schabanowa2014@gmail.com", "massage here!")
24
+ # smtpObj.quit()
25
+
26
+
27
+ # Работа с календарем удаление
28
+ def updateLabel(a):
29
+ # settings_window()select()get_schedule()
30
+
31
+ labelblue.config(text="Selected Date: " + tkc.get_date(), font=85)
32
+ for i in frame3.winfo_children(): # тут др фрейм
33
+ i.destroy()
34
+ print('current dict state : ', dict_)
35
+ curr_date = tkc.get_date()
36
+ dict_for_variables = {}
37
+ if curr_date in dict_:
38
+ for i in range(len(dict_[curr_date])):
39
+ dict_for_variables[curr_date] = dict_for_variables.get(curr_date, []) + [IntVar()]
40
+ dict_for_variables[curr_date][i].set(dict_[curr_date][i][-1])
41
+ for i in range(len(dict_[curr_date])): # восстановление окна с задачами
42
+ current_task = dict_[curr_date][i][0]
43
+ # current_task[-1].pack(fil=X, font=40)
44
+ print(current_task)
45
+ curr_frame = Frame(frame3, background='white', borderwidth=0, highlightthickness=0, bd=0)
46
+ curr_frame.pack(side='top', fill=X)
47
+ # a = 'Checkbutton' + str(i) + '_'.join(curr_date.split('/'))
48
+ # locals()[a] = IntVar() # в a переменая кнопки
49
+ # dict_for_variables[curr_date] = dict_for_variables.get(curr_date,[]) + [eval(a)]
50
+ print('dict_for_variables', dict_for_variables)
51
+
52
+ # eval(a).set(dict_[curr_date][i][-1])
53
+ def callBackFunc(): # обновление всех галочек по текущей дате
54
+ print('функция работает исправно')
55
+ n = 0
56
+ print('dict_for_variables', dict_for_variables)
57
+ for form in frame3.winfo_children():
58
+ for widget in form.winfo_children():
59
+ # print(widget)
60
+ # print(type(widget))
61
+ if str(type(widget)) == "<class 'tkinter.Checkbutton'>":
62
+ print('dict_for_variables[curr_date][n]', repr(dict_for_variables[curr_date][n]))
63
+ print('dict_for_variables[curr_date][n].get()', dict_for_variables[curr_date][n].get())
64
+ # print('widget.variable.get()', widget.variable.get())
65
+ dict_[curr_date][n][-1] = dict_for_variables[curr_date][n].get()
66
+ print(dict_)
67
+ n += 1
68
+
69
+ current_task = Checkbutton(curr_frame, text=current_task, font=45, bg='white',
70
+ variable=dict_for_variables[curr_date][i], onvalue=1, offvalue=0,
71
+ highlightthickness=0,
72
+ bd=0) # command= callBackFunc aaaaaaaaaaaaaaaaaaaaa Checkbutton.command
73
+
74
+ print('current_task.cget("text")', current_task.cget("text"))
75
+ current_task['command'] = callBackFunc
76
+ # print('dict_[curr_date][i]', dict_[curr_date][i] )
77
+ print()
78
+ # dict_[curr_date][i][-1] = eval(a).get()
79
+ print(dict_)
80
+ current_task.pack(side='left', padx=7)
81
+ print(dict_)
82
+ img = type_to_image[dict_[curr_date][i][1]] # Image.open('mass.png')
83
+ resized_image = img.resize((30, 30))
84
+ photo = ImageTk.PhotoImage(resized_image)
85
+ lab = Label(curr_frame, image=photo)
86
+ lab.image = photo
87
+ lab.pack(side='right')
88
+
89
+
90
+ # first run
91
+ def hello():
92
+ global tkc
93
+ hello = Toplevel(root)
94
+ root['bg'] = 'white'
95
+ hello.title("Hellper_2.0")
96
+ hello.geometry("1000x480")
97
+ # hello.eval('tk::PlaceWindow . center')
98
+ frame1 = Frame(hello, bg='white', width=200, height=200)
99
+ frame1.pack(fill=BOTH, expand=True, side='left')
100
+ frame2 = Frame(hello, bg='white', width=200, height=200)
101
+ frame2.pack(fill=BOTH, expand=True, side='left')
102
+ global icon1
103
+ # photo = ImageTk.PhotoImage(image)
104
+ Label(frame1, image=icon1, bg='white').pack(fill=BOTH, expand=True, padx=12)
105
+ global my_font
106
+ noteditor = Text(frame2, wrap='word', bg='white', font=my_font, highlightthickness=0, borderwidth=0, height=14)
107
+ noteditor.pack(fill=BOTH, expand=1, padx=35)
108
+ # noteditor.insert(5.5, 'Hello!')
109
+ global sring_my
110
+ noteditor.insert(7.0, sring_my)
111
+ noteditor.config(state=DISABLED)
112
+
113
+ def open_settings():
114
+ global tkc
115
+ hello.withdraw()
116
+ settings_window()
117
+
118
+ frame3 = Frame(frame2, bg='white', width=200, height=100)
119
+ frame3.pack(fill=BOTH, expand=True, side='bottom')
120
+ global my_font2
121
+ btn = Button(frame3, bg='white', text='start settings', font=my_font2, foreground='red', justify=RIGHT,
122
+ command=open_settings, highlightthickness=0, borderwidth=0)
123
+ btn.configure(width=200, height=100)
124
+ btn.pack(anchor='se')
125
+
126
+
127
+ # settings window
128
+ def settings_window():
129
+ global tkc
130
+ settings.deiconify()
131
+ frame1 = Frame(settings, bg='white')
132
+ frame1.pack()
133
+ title = Label(frame1, text='Settings', font=my_font2, bg='white', highlightthickness=0, bd=0, pady=15).pack()
134
+ frame_email = Frame(settings, bg='white', width=200, height=100)
135
+ frame_email.pack(fill=BOTH, expand=True)
136
+ title = Label(frame_email, text='Enter your mail: ', font=my_font, bg='white', highlightthickness=0, bd=0,
137
+ pady=15).pack(side=LEFT, fill=X)
138
+ entry1 = Entry(frame_email, width=30)
139
+ entry1.pack(side=LEFT, fill=X)
140
+ frame_name = Frame(settings, bg='white', width=200, height=100)
141
+ frame_name.pack(fill=BOTH, expand=True)
142
+ title = Label(frame_name, text='Enter your name: ', font=my_font, bg='white', highlightthickness=0, bd=0,
143
+ pady=15).pack(side=LEFT, fill=X)
144
+ entry2 = Entry(frame_name, width=30)
145
+ entry2.pack(side=LEFT, fill=X)
146
+ frame_work = Frame(settings, bg='white', width=200, height=100)
147
+ frame_work.pack(fill=BOTH, expand=True)
148
+ title = Label(frame_work, text='Сhoose your work schedule: ', font=my_font, bg='white', highlightthickness=0, bd=0,
149
+ pady=15).pack(side=LEFT, fill=X)
150
+ # frame_worktime = Frame(settings, bg='white', width=200, height=100).pack(side=LEFT, fill = X).pack()
151
+ counter = 0
152
+
153
+ def select(selected):
154
+ nonlocal counter
155
+ counter += 1
156
+ if counter > 1: frame_worktime.destroy()
157
+ frame_worktime = Frame(settings, bg='white', width=200, height=100)
158
+ frame_worktime.pack(side=LEFT, fill=X)
159
+ title = Label(frame_worktime, text='Set your worktime (08:00 20:00): ', font=my_font, bg='white',
160
+ highlightthickness=0, bd=0, pady=15).pack(side=LEFT, fill=X)
161
+ entry_start = Entry(frame_worktime)
162
+ entry_start.pack(side=LEFT, fill=X)
163
+ entry_end = Entry(frame_worktime)
164
+ entry_end.pack(side=LEFT, fill=X)
165
+ title = Label(frame_worktime, text='Last workday: ', font=my_font, bg='white', highlightthickness=0, bd=0,
166
+ pady=15).pack(side=LEFT, fill=X)
167
+ datentry = DateEntry(frame_worktime)
168
+ datentry.pack(side=LEFT, fill=X)
169
+
170
+ def saving_and_destroy():
171
+ settings_list = [entry1.get(), entry2.get(), btn.get(), datentry.get_date(), entry_start.get(),
172
+ entry_end.get()]
173
+ with open('settings', mode='w') as f:
174
+ f.write(str(settings_list))
175
+ settings.withdraw()
176
+
177
+ btnn = Button(frame_worktime, text="OK", padx=30, command=saving_and_destroy).pack(side=RIGHT, fill=BOTH)
178
+
179
+ list_of_workdays = []
180
+
181
+ # print(settings_list)
182
+ def get_schedule(*A): # работа над заполнением рабочих дней
183
+ date = datentry.get_date()
184
+ date_last = date + timedelta(days=int(selected.split('/')[-1]) + 1)
185
+ if A:
186
+ selected = settings[2]
187
+ date = settings[3]
188
+ if list_of_workdays:
189
+ tkc.calevent_remove(*list_of_workdays)
190
+ step = int(selected.split('/')[-1])
191
+ step_weekend = int(selected.split('/')[0]) - 1
192
+ # последний введеный выходной день
193
+ for i in range(130):
194
+ for j in range(int(selected.split('/')[0])):
195
+ work_event = tkc.calevent_create(date=date_last, text='EVENT HERE', tags='tag')
196
+ tkc.tag_config('tag', background='azure2', foreground='dodgerblue4')
197
+ list_of_workdays.append(work_event)
198
+ date_last = date_last + timedelta(days=1)
199
+ date_last = date_last + timedelta(days=step)
200
+
201
+ datentry.bind('<<DateEntrySelected>>', get_schedule)
202
+
203
+ btn = StringVar()
204
+
205
+ def f():
206
+ selected = btn.get()
207
+ select(selected)
208
+
209
+ list_ = ['5/2', '1/3', '2/2']
210
+ for schedule in list_:
211
+ schedule = Radiobutton(frame_work, text=schedule, value=schedule, variable=btn, command=f, bg='white')
212
+ schedule.pack(side=LEFT, fill=X)
213
+
214
+
215
+ def func(): # Опреде��яет геолокацию и погоду
216
+ BASE_URL = "https://api.open-meteo.com/v1/forecast"
217
+ g = geocoder.ip('me')
218
+ city = g.latlng
219
+ # Параметры запроса для Краснодара
220
+ params = {
221
+ "latitude": city[0], # широта Краснодара
222
+ "longitude": city[1], # долгота Краснодара
223
+ "daily": "temperature_2m_min,temperature_2m_max,precipitation_sum",
224
+ # минимальная и максимальная температура, сумма осадков
225
+ "timezone": "Europe/Moscow"} # временная зона для Краснодара
226
+ response = requests.get(BASE_URL, params=params)
227
+ data = response.json()
228
+ user_name['text'] = str(g.city) + ' : ' + str(data['daily']['temperature_2m_max'][1])
229
+
230
+
231
+ # get_schedule(tkc) #вызываю функцию заполнения рабочими днями
232
+
233
+ # add events
234
+ # print(datetime.strptime(tkc.get_date(), '%m/%d/%y'))
235
+ # print(f'tags names - {tkc.tag_names()}')
236
+
237
+ # color of event
238
+ # print(f'tags names - {tkc.tag_names()}')
239
+ # event_my = tkc.calevent_create(date=datetime.strptime(tkc.get_date(), '%m/%d/%y'), text='EVENT HERE', tags='tag')
240
+ # tkc.tag_config('tag', background='azure3', foreground='white')
241
+ # print(tkc.get_calevents(date=datetime.strptime(tkc.get_date(), '%m/%d/%y'), tag=None))
242
+
243
+ number = 0
244
+ position = 0
245
+ dict_ = {}
246
+
247
+
248
+ def func1():
249
+ stroka = tkc.get_date()
250
+
251
+ newWindow = Toplevel(root)
252
+ newWindow.title("Add your task/goal")
253
+ newWindow.geometry("700x300")
254
+ class_tasks = ['Goal', 'Task']
255
+ combobox = ttk.Combobox(newWindow, values=class_tasks)
256
+ combobox.pack()
257
+ combobox.insert(0, 'Task')
258
+
259
+ def goal_or_task(a, b=False):
260
+
261
+ if combobox.get() == 'Task' or b == True:
262
+ def fetch():
263
+ task_name, task_type = tasky.get(), combobox1.get()
264
+ global number
265
+ dict_[stroka] = dict_.get(stroka, []) + [[task_name, task_type, number, False]]
266
+ print(dict_)
267
+ number += 1
268
+ updateLabel('a')
269
+ newWindow.destroy()
270
+
271
+ newWindow.update()
272
+ frame11 = Frame(newWindow, background='green')
273
+ frame11.pack(fill=BOTH, expand=True)
274
+ print('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!', newWindow)
275
+ taskname = Label(frame11, text='Set the task')
276
+ taskname.pack(side=LEFT, fill=BOTH)
277
+ tasky = Entry(frame11)
278
+ tasky.pack(side=LEFT)
279
+ frame22 = Frame(newWindow, background='white')
280
+ frame22.pack(fill=BOTH, expand=True)
281
+ print('!!!!!!!!!!!!!!!!!!!!!!!!', frame22)
282
+ types_of_tasks = Label(frame22, text='Set type')
283
+ types_of_tasks.pack(side=LEFT, fill=BOTH)
284
+ # tasky.bind('<Return>', fetch)
285
+ tasks_types = ['programming', 'health', 'erudition', 'work', 'cleanliness']
286
+ combobox1 = ttk.Combobox(frame22, values=tasks_types, background='white')
287
+ combobox1.pack(side=LEFT)
288
+ Button(newWindow, text='add task', command=fetch).pack(anchor='se')
289
+ newWindow.protocol("WM_DELETE_WINDOW", updateLabel) # close window trigger
290
+ elif combobox.get() == 'Goal':
291
+ newWindow.update()
292
+
293
+ goal_or_task('a', b=True)
294
+
295
+ combobox.bind("<<ComboboxSelected>>", goal_or_task)
296
+
297
+
298
+ def record():
299
+ with open('your_story.txt', 'w') as f:
300
+ data = str(dict_)
301
+ f.write(data)
302
+ root.destroy()
303
+
304
+
305
+ def read_dict():
306
+ isempty = os.stat('your_story.txt').st_size
307
+ print('isempty', isempty)
308
+ if isempty != 0:
309
+ with open('your_story.txt') as f:
310
+ global dict_
311
+ dict_ = eval(f.readlines()[0])
312
+ print('HERE===========', type(dict_))
313
+
314
+
315
+ read_dict()
316
+ root = Tk()
317
+ root.title('Hellper_2.0')
318
+ root['bg'] = '#fafafa'
319
+ icon = PhotoImage(file="aaa.png")
320
+ icon1 = PhotoImage(file="bb.png")
321
+ root.iconphoto(True, icon)
322
+ # root.eval('tk::PlaceWindow . center')
323
+ #root.wm_attributes()
324
+ root.geometry('780x400')
325
+ # create settings window:
326
+ settings = Toplevel(root)
327
+ root['bg'] = 'white'
328
+ settings.title("Hellper_2.0")
329
+ settings.geometry("1000x480")
330
+ root.protocol("WM_DELETE_WINDOW", record)
331
+
332
+ # root.wm_withdraw() #скрываем окно до окончания настройки
333
+ settings.wm_withdraw() # скрываем окно до окончания настройки
334
+ my_font2 = font.Font(family="Arial", size=17, weight='bold')
335
+ my_font = font.Font(family="Arial", size=17, weight="normal")
336
+ hello()
337
+ frame = Frame(root, bg='white', width=200, height=200)
338
+ frame.pack(fill=BOTH, expand=True, side=RIGHT)
339
+
340
+ current_font = font.Font(weight='bold', size=13)
341
+ dt_now = str(datetime.now()).split()[0].split('-')
342
+ tkc = Calendar(frame, selectmode="day", year=int(dt_now[0]), month=int(dt_now[1]), date=int(dt_now[2]),
343
+ foreground='darkorange1', font=current_font, background='white', bordercolor='azure2',
344
+ headersbackground='white', weekendbackground='white', othermonthbackground='floralwhite',
345
+ weekendforeground='black', othermonthwebackground='floralwhite', showweeknumbers=False,
346
+ day=int(dt_now[2]), disabledselectbackground='yellow', disabledselectforeground='blue',
347
+ disableddaybackground='pink', selectbackground='green')
348
+ tkc.pack(fill='both', expand=True, padx=17, pady=4)
349
+ tkc.bind('<<CalendarSelected>>', updateLabel) # нажатие на дату
350
+
351
+ frame1 = Frame(root, bg='white', width=200, height=200)
352
+ # frame.configure(width=520, height=500)
353
+ frame1.pack(fill=BOTH, expand=True, side=RIGHT)
354
+ frame4 = Frame(frame1, bg='white')
355
+ frame4.pack(side='top', fill=X)
356
+ frame3 = Frame(frame1, bg='white')
357
+ frame3.pack(side=TOP, fill=BOTH, expand=True)
358
+ btn1 = Button(frame4, text='ADD', bg='white', command=func1)
359
+ btn1.pack(side=LEFT)
360
+ labelblue = Label(frame4, text="Selected Date: ", font=40, bg='white')
361
+ labelblue.pack(side=LEFT)
362
+ labelblue.config(text="Selected Date: " + tkc.get_date(), font=85)
363
+
364
+ # Для погоды по геолокации
365
+ image = Image.open("picture.png")
366
+ resized_image = image.resize((28, 28))
367
+ photo = ImageTk.PhotoImage(resized_image)
368
+
369
+ # фрейм с погодой
370
+ frame2 = Frame(frame, bg='white', width=100, height=100)
371
+ frame2.pack(side='top', fill=X, pady=13)
372
+
373
+ # кнопка с фото
374
+ # title = Label(frame2, bg='white')
375
+ btn = Button(frame2, text='Создать задачу', bg='white', image=photo, command=func)
376
+ btn.configure(width=28, height=28)
377
+ btn.pack(side=LEFT, padx=17, pady=1)
378
+ # title.pack(side='left')
379
+
380
+ user_name = Label(frame2, text='wheather', font=25, bg='white', highlightthickness=0, bd=0)
381
+ user_name.pack(side=LEFT)
382
+
383
+ btn.invoke() # кнопка погоды нажатие
384
+ print('cick')
385
+
386
+ updateLabel('a')
387
+
388
+ root.mainloop()
389
+
390
+ root.mainloop()
requirements.txt ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ tkinter
2
+ geocoder
3
+ tkcalendar
4
+ PIL
5
+ requests
6
+ smtplib
7
+ datetime
8
+ os
9
+ Fastapi
10
+ uvicorn
ru ADDED
@@ -0,0 +1,378 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from tkinter import *
2
+ import geocoder
3
+ from tkcalendar import Calendar, DateEntry
4
+ from tkinter import Label, Tk, ttk
5
+ from PIL import Image, ImageTk
6
+ import requests
7
+ from tkinter import font
8
+ import smtplib
9
+ from datetime import timedelta
10
+ from datetime import datetime
11
+ from datetime import *
12
+ import os
13
+ sring_my = '''\n\n\n\nHello!\n\nI am called to rescue you from the hellish chaos of life. Where you can define your path, divide it into stages, understand the possibilities of time and your pace. And what is very important, you can see all the work done and admire yourself.\n\nI'll always keep you posted.'''
14
+ type_to_image = {'programming': Image.open("pc.png"), 'health': Image.open("m.png"), 'erudition': Image.open("cr.png"), 'work':Image.open("money.png"), 'cleanliness': Image.open("c.png")}
15
+ #gmail_message
16
+ #smtpobj = smtplib.SMTP('smtp.gmail.com', 587)
17
+ #smtpobj.starttls()
18
+ #smtpobj.login('anastasiya.schabanowa2014@gmail.com','NIkapirog992!')
19
+ #smtpobj.sendmail("anastasiya.schabanowa2014@gmail.com", "massage here!")
20
+ #smtpObj.quit()
21
+
22
+
23
+
24
+
25
+ #Работа с календарем удаление
26
+ def updateLabel(a):
27
+ #settings_window()select()get_schedule()
28
+
29
+ labelblue.config(text="Selected Date: " + tkc.get_date(), font=85)
30
+ for i in frame3.winfo_children(): #тут др фрейм
31
+ i.destroy()
32
+ print('current dict state : ',dict_)
33
+ curr_date = tkc.get_date()
34
+ dict_for_variables = {}
35
+ if curr_date in dict_:
36
+ for i in range( len(dict_[curr_date])):
37
+ dict_for_variables[curr_date] = dict_for_variables.get(curr_date,[]) + [IntVar()]
38
+ dict_for_variables[curr_date][i].set(dict_[curr_date][i][-1])
39
+ for i in range( len(dict_[curr_date])): #восстановление окна с задачами
40
+ current_task = dict_[curr_date][i][0]
41
+ #current_task[-1].pack(fil=X, font=40)
42
+ print(current_task)
43
+ curr_frame = Frame(frame3, background='white',borderwidth=0,highlightthickness=0,bd=0)
44
+ curr_frame.pack(side='top',fill = X)
45
+ #a = 'Checkbutton' + str(i) + '_'.join(curr_date.split('/'))
46
+ #locals()[a] = IntVar() # в a переменая кнопки
47
+ #dict_for_variables[curr_date] = dict_for_variables.get(curr_date,[]) + [eval(a)]
48
+ print('dict_for_variables', dict_for_variables)
49
+ #eval(a).set(dict_[curr_date][i][-1])
50
+ def callBackFunc(): #обновление всех галочек по текущей дате
51
+ print('функция работает исправно')
52
+ n =0
53
+ print('dict_for_variables',dict_for_variables)
54
+ for form in frame3.winfo_children():
55
+ for widget in form.winfo_children():
56
+ #print(widget)
57
+ #print(type(widget))
58
+ if str(type(widget)) == "<class 'tkinter.Checkbutton'>":
59
+ print('dict_for_variables[curr_date][n]',repr(dict_for_variables[curr_date][n]))
60
+ print('dict_for_variables[curr_date][n].get()', dict_for_variables[curr_date][n].get())
61
+ #print('widget.variable.get()', widget.variable.get())
62
+ dict_[curr_date][n][-1] = dict_for_variables[curr_date][n].get()
63
+ print(dict_)
64
+ n += 1
65
+ current_task = Checkbutton(curr_frame, text = current_task, font=45,bg='white', variable = dict_for_variables[curr_date][i], onvalue = 1, offvalue = 0, highlightthickness=0,bd=0 ) # command= callBackFunc aaaaaaaaaaaaaaaaaaaaa Checkbutton.command
66
+
67
+ print('current_task.cget("text")',current_task.cget("text"))
68
+ current_task['command'] = callBackFunc
69
+ #print('dict_[curr_date][i]', dict_[curr_date][i] )
70
+ print()
71
+ #dict_[curr_date][i][-1] = eval(a).get()
72
+ print(dict_)
73
+ current_task.pack(side='left', padx=7)
74
+ print(dict_)
75
+ img = type_to_image[dict_[curr_date][i][1]] #Image.open('mass.png')
76
+ resized_image = img.resize((30, 30))
77
+ photo = ImageTk.PhotoImage(resized_image)
78
+ lab = Label(curr_frame, image=photo )
79
+ lab.image = photo
80
+ lab.pack(side='right')
81
+
82
+
83
+ #first run
84
+ def hello():
85
+ global tkc
86
+ hello = Toplevel(root)
87
+ root['bg'] = 'white'
88
+ hello.title("Hellper_2.0")
89
+ hello.geometry("1000x480")
90
+ #hello.eval('tk::PlaceWindow . center')
91
+ frame1 = Frame(hello, bg='white', width=200, height=200)
92
+ frame1.pack(fill = BOTH, expand = True, side='left')
93
+ frame2 = Frame(hello, bg='white', width=200, height=200)
94
+ frame2.pack(fill = BOTH, expand = True, side='left')
95
+ global icon1
96
+ #photo = ImageTk.PhotoImage(image)
97
+ Label(frame1, image=icon1, bg='white').pack(fill = BOTH, expand = True, padx=12)
98
+ global my_font
99
+ noteditor = Text(frame2,wrap='word', bg='white', font=my_font, highlightthickness = 0, borderwidth=0, height=14)
100
+ noteditor.pack(fill=BOTH, expand=1, padx=35)
101
+ #noteditor.insert(5.5, 'Hello!')
102
+ global sring_my
103
+ noteditor.insert(7.0, sring_my)
104
+ noteditor.config(state=DISABLED)
105
+ def open_settings():
106
+ global tkc
107
+ hello.withdraw()
108
+ settings_window()
109
+ frame3 = Frame(frame2, bg='white', width=200, height=100)
110
+ frame3.pack(fill = BOTH, expand = True, side='bottom')
111
+ global my_font2
112
+ btn = Button(frame3, bg='white', text='start settings', font=my_font2, foreground='red', justify=RIGHT, command=open_settings, highlightthickness = 0, borderwidth=0)
113
+ btn.configure(width=200, height=100)
114
+ btn.pack(anchor='se')
115
+
116
+ #settings window
117
+ def settings_window():
118
+ global tkc
119
+ settings.deiconify()
120
+ frame1 = Frame(settings, bg='white')
121
+ frame1.pack()
122
+ title = Label(frame1, text='Settings', font=my_font2, bg='white', highlightthickness=0, bd=0, pady=15).pack()
123
+ frame_email = Frame(settings, bg='white', width=200, height=100)
124
+ frame_email.pack(fill = BOTH, expand = True)
125
+ title = Label(frame_email, text='Enter your mail: ', font=my_font, bg='white', highlightthickness=0, bd=0, pady=15).pack(side=LEFT, fill = X)
126
+ entry1 = Entry(frame_email, width=30)
127
+ entry1.pack(side=LEFT, fill = X)
128
+ frame_name = Frame(settings, bg='white', width=200, height=100)
129
+ frame_name.pack(fill = BOTH, expand = True)
130
+ title = Label(frame_name, text='Enter your name: ', font=my_font, bg='white', highlightthickness=0, bd=0, pady=15).pack(side=LEFT, fill = X)
131
+ entry2 = Entry(frame_name, width=30)
132
+ entry2.pack(side=LEFT, fill = X)
133
+ frame_work = Frame(settings, bg='white', width=200, height=100)
134
+ frame_work.pack(fill = BOTH, expand = True)
135
+ title = Label(frame_work, text='Сhoose your work schedule: ', font=my_font, bg='white', highlightthickness=0, bd=0, pady=15).pack(side=LEFT, fill = X)
136
+ #frame_worktime = Frame(settings, bg='white', width=200, height=100).pack(side=LEFT, fill = X).pack()
137
+ counter = 0
138
+ def select(selected):
139
+ nonlocal counter
140
+ counter +=1
141
+ if counter >1: frame_worktime.destroy()
142
+ frame_worktime = Frame(settings, bg='white', width=200, height=100)
143
+ frame_worktime.pack(side=LEFT, fill = X)
144
+ title = Label(frame_worktime, text='Set your worktime (08:00 20:00): ', font=my_font, bg='white', highlightthickness=0, bd=0, pady=15).pack(side=LEFT, fill = X)
145
+ entry_start = Entry(frame_worktime)
146
+ entry_start.pack(side=LEFT, fill = X)
147
+ entry_end = Entry(frame_worktime)
148
+ entry_end.pack(side=LEFT, fill = X)
149
+ title = Label(frame_worktime, text='Last workday: ', font=my_font, bg='white', highlightthickness=0, bd=0, pady=15).pack(side=LEFT, fill = X)
150
+ datentry = DateEntry(frame_worktime)
151
+ datentry.pack(side=LEFT, fill = X)
152
+ def saving_and_destroy():
153
+ settings_list = [entry1.get(), entry2.get(), btn.get(), datentry.get_date(), entry_start.get(), entry_end.get()]
154
+ with open('settings', mode='w') as f:
155
+ f.write(str(settings_list))
156
+ settings.withdraw()
157
+ btnn = Button(frame_worktime, text="OK",padx=30, command=saving_and_destroy).pack(side=RIGHT, fill = BOTH)
158
+
159
+ list_of_workdays = []
160
+
161
+ #print(settings_list)
162
+ def get_schedule(*A): # работа над заполнением рабочих дней
163
+ date = datentry.get_date()
164
+ date_last = date + timedelta(days=int(selected.split('/')[-1])+1)
165
+ if A:
166
+ selected = settings[2]
167
+ date = settings[3]
168
+ if list_of_workdays:
169
+ tkc.calevent_remove(*list_of_workdays)
170
+ step = int(selected.split('/')[-1])
171
+ step_weekend = int(selected.split('/')[0])-1
172
+ #последний введеный выходной день
173
+ for i in range(130):
174
+ for j in range(int(selected.split('/')[0])):
175
+ work_event = tkc.calevent_create(date=date_last, text='EVENT HERE', tags='tag')
176
+ tkc.tag_config('tag', background='azure2', foreground='dodgerblue4')
177
+ list_of_workdays.append(work_event)
178
+ date_last = date_last + timedelta(days=1)
179
+ date_last = date_last + timedelta(days=step)
180
+
181
+ datentry.bind('<<DateEntrySelected>>', get_schedule)
182
+
183
+ btn = StringVar()
184
+ def f():
185
+ selected = btn.get()
186
+ select(selected)
187
+ list_ = ['5/2', '1/3', '2/2']
188
+ for schedule in list_:
189
+ schedule = Radiobutton(frame_work, text=schedule, value=schedule, variable=btn, command=f, bg='white')
190
+ schedule.pack(side=LEFT, fill = X)
191
+
192
+
193
+
194
+
195
+
196
+
197
+
198
+
199
+ def func(): # Определяет геолокацию и погоду
200
+ BASE_URL = "https://api.open-meteo.com/v1/forecast"
201
+ g = geocoder.ip('me')
202
+ city = g.latlng
203
+ # Параметры запроса для Краснодара
204
+ params = {
205
+ "latitude": city[0], # широта Краснодара
206
+ "longitude": city[1], # долгота Краснодара
207
+ "daily": "temperature_2m_min,temperature_2m_max,precipitation_sum", # минимальная и максимальная температура, сумма осадков
208
+ "timezone": "Europe/Moscow" } # временная зона для Краснодара
209
+ response = requests.get(BASE_URL, params=params)
210
+ data = response.json()
211
+ user_name['text'] = str(g.city) + ' : '+str(data['daily']['temperature_2m_max'][1])
212
+
213
+
214
+
215
+
216
+
217
+
218
+ #get_schedule(tkc) #вызываю функцию заполнения рабочими днями
219
+
220
+ #add events
221
+ #print(datetime.strptime(tkc.get_date(), '%m/%d/%y'))
222
+ #print(f'tags names - {tkc.tag_names()}')
223
+
224
+ #color of event
225
+ #print(f'tags names - {tkc.tag_names()}')
226
+ #event_my = tkc.calevent_create(date=datetime.strptime(tkc.get_date(), '%m/%d/%y'), text='EVENT HERE', tags='tag')
227
+ #tkc.tag_config('tag', background='azure3', foreground='white')
228
+ #print(tkc.get_calevents(date=datetime.strptime(tkc.get_date(), '%m/%d/%y'), tag=None))
229
+
230
+ number = 0
231
+ position = 0
232
+ dict_ = {}
233
+ def func1():
234
+ stroka = tkc.get_date()
235
+
236
+
237
+
238
+ newWindow = Toplevel(root)
239
+ newWindow.title("Add your task/goal")
240
+ newWindow.geometry("700x300")
241
+ class_tasks = ['Goal','Task']
242
+ combobox = ttk.Combobox(newWindow, values=class_tasks)
243
+ combobox.pack()
244
+ combobox.insert(0, 'Task')
245
+
246
+
247
+ def goal_or_task(a, b=False):
248
+
249
+ if combobox.get() == 'Task' or b==True:
250
+ def fetch():
251
+ task_name, task_type = tasky.get(), combobox1.get()
252
+ global number
253
+ dict_[stroka] = dict_.get(stroka, []) + [[task_name, task_type, number, False]]
254
+ print(dict_)
255
+ number += 1
256
+ updateLabel('a')
257
+ newWindow.destroy()
258
+ newWindow.update()
259
+ frame11 = Frame(newWindow, background='green')
260
+ frame11.pack(fill = BOTH, expand = True)
261
+ print('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!', newWindow)
262
+ taskname = Label(frame11, text='Set the task')
263
+ taskname.pack(side=LEFT, fill = BOTH)
264
+ tasky = Entry(frame11)
265
+ tasky.pack(side=LEFT)
266
+ frame22 = Frame(newWindow, background='white')
267
+ frame22.pack(fill = BOTH, expand = True)
268
+ print('!!!!!!!!!!!!!!!!!!!!!!!!',frame22 )
269
+ types_of_tasks = Label(frame22, text='Set type')
270
+ types_of_tasks.pack(side=LEFT, fill = BOTH)
271
+ #tasky.bind('<Return>', fetch)
272
+ tasks_types = ['programming', 'health', 'erudition', 'work', 'cleanliness']
273
+ combobox1 = ttk.Combobox(frame22, values=tasks_types, background='white')
274
+ combobox1.pack(side=LEFT)
275
+ Button(newWindow, text='add task', command=fetch).pack(anchor='se')
276
+ newWindow.protocol("WM_DELETE_WINDOW", updateLabel) #close window trigger
277
+ elif combobox.get() == 'Goal':
278
+ newWindow.update()
279
+
280
+ goal_or_task('a', b=True)
281
+
282
+
283
+ combobox.bind("<<ComboboxSelected>>", goal_or_task)
284
+
285
+ def record():
286
+ with open('your_story.txt', 'w') as f:
287
+ data = str(dict_)
288
+ f.write(data)
289
+ root.destroy()
290
+ def read_dict():
291
+ isempty = os.stat('your_story.txt').st_size
292
+ print('isempty', isempty)
293
+ if isempty != 0:
294
+ with open('your_story.txt') as f:
295
+ global dict_
296
+ dict_ = eval(f.readlines()[0])
297
+ print('HERE===========',type(dict_))
298
+
299
+ read_dict()
300
+ root = Tk()
301
+ root.title('Hellper_2.0')
302
+ root['bg'] = '#fafafa'
303
+ icon = PhotoImage(file="aaa.png")
304
+ icon1 = PhotoImage(file="bb.png")
305
+ root.iconphoto(True, icon)
306
+ #root.eval('tk::PlaceWindow . center')
307
+ root.wm_attributes('-alpha', 0.7)
308
+ root.geometry('780x400')
309
+ #create settings window:
310
+ settings = Toplevel(root)
311
+ root['bg'] = 'white'
312
+ settings.title("Hellper_2.0")
313
+ settings.geometry("1000x480")
314
+ root.protocol("WM_DELETE_WINDOW", record)
315
+
316
+
317
+ #root.wm_withdraw() #скрываем окно до окончания настройки
318
+ settings.wm_withdraw() #скрываем окно до окончания настройки
319
+ my_font2 = font.Font(family= "Arial", size=17,weight='bold')
320
+ my_font = font.Font(family= "Arial", size=17, weight="normal")
321
+ hello()
322
+ frame = Frame(root, bg='white', width=200, height=200)
323
+ frame.pack(fill = BOTH, expand = True, side=RIGHT)
324
+
325
+ current_font = font.Font(weight='bold', size=13)
326
+ dt_now = str(datetime.now()).split()[0].split('-')
327
+ tkc = Calendar(frame,selectmode = "day", year=int(dt_now[0]),month=int(dt_now[1]),date=int(dt_now[2]), foreground='darkorange1', font=current_font, background='white', bordercolor='azure2', headersbackground='white', weekendbackground='white', othermonthbackground='floralwhite', weekendforeground='black', othermonthwebackground='floralwhite', showweeknumbers=False,
328
+ day=int(dt_now[2]), disabledselectbackground='yellow', disabledselectforeground='blue', disableddaybackground='pink', selectbackground='green')
329
+ tkc.pack(fill='both', expand=True, padx=17, pady=4)
330
+ tkc.bind('<<CalendarSelected>>', updateLabel) #нажатие на дату
331
+
332
+
333
+ frame1 = Frame(root, bg='white', width=200, height=200)
334
+ #frame.configure(width=520, height=500)
335
+ frame1.pack(fill = BOTH, expand = True, side=RIGHT)
336
+ frame4 = Frame(frame1, bg='white')
337
+ frame4.pack(side='top',fill = X)
338
+ frame3 = Frame(frame1, bg='white')
339
+ frame3.pack(side=TOP,fill = BOTH,expand = True)
340
+ btn1 = Button(frame4, text='ADD', bg='white', command=func1)
341
+ btn1.pack(side=LEFT)
342
+ labelblue = Label(frame4, text="Selected Date: ", font=40, bg='white')
343
+ labelblue.pack(side=LEFT)
344
+ labelblue.config(text="Selected Date: " + tkc.get_date(), font=85)
345
+
346
+
347
+ #Для погоды по геолокации
348
+ image = Image.open("picture.png")
349
+ resized_image = image.resize((28, 28))
350
+ photo = ImageTk.PhotoImage(resized_image)
351
+
352
+ #фрейм с погодой
353
+ frame2 = Frame(frame, bg='white', width=100, height=100)
354
+ frame2.pack(side='top', fill = X, pady=13)
355
+
356
+ #кнопка с фото
357
+ #title = Label(frame2, bg='white')
358
+ btn = Button(frame2, text='Создать задачу', bg='white', image=photo, command=func)
359
+ btn.configure(width=28, height=28)
360
+ btn.pack(side=LEFT, padx=17, pady=1)
361
+ #title.pack(side='left')
362
+
363
+ user_name = Label(frame2, text='wheather', font=25, bg='white', highlightthickness=0,bd=0)
364
+ user_name.pack(side=LEFT)
365
+
366
+ btn.invoke() #кнопка погоды нажатие
367
+ print('cick')
368
+
369
+
370
+
371
+ updateLabel('a')
372
+
373
+
374
+
375
+ root.mainloop()
376
+
377
+
378
+ root.mainloop()
settings ADDED
@@ -0,0 +1 @@
 
 
1
+ ['--', '--', '2/2', datetime.date(2023, 12, 14), '', '']
your_story.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ {'12/12/23': [['Настроить сохранение отметок выполнения', 'programming', 0, 1]]}