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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
| # -*- coding: utf-8 -*-
import os
import Time_lib
from kivy.uix.behaviors import ButtonBehavior as bh
from kivy.app import App
from kivy.uix.image import Image as img
from kivy.uix.anchorlayout import AnchorLayout as al
from kivy.uix.textinput import TextInput as ti
from kivy.uix.button import Button as bt
from kivy.uix.boxlayout import BoxLayout as bl
from kivy.uix.widget import Widget as wd
from kivy.core.window import Window
from kivy.uix.gridlayout import GridLayout as gl
from kivy.uix.floatlayout import FloatLayout as fl
from kivy.graphics import (Color,Line,Ellipse,Rectangle)
import time
from kivy.uix.label import Label as lbl
class AppApp(App,wd):
def __init__(self, **kwargs):
super(AppApp, self).__init__(**kwargs)
i=0
with self.canvas:
Color(0,0.6,0.8,1)
Rectangle(size=(2000,2000),pos=(0,0))
self.click_date=[]
def Quanity_of_day(self):
ind=Time_lib.mounth_ru.index(self.Mounth.text)+1
quanity_of_day=len(os.listdir(r'C:\Users\Nikit\OneDrive\Рабочий стол\NewApp\Diary\year_{}\mounth_{}'.format(self.Caps_year.text,ind)))
return quanity_of_day
def update_calendar(self):
K=0
qua=self.Quanity_of_day()
ind=Time_lib.mounth_ru[Time_lib.mounth_ru.index(self.Mounth.text)]
for child in self.Grid_Cald.children[:]:
self.Grid_Cald.remove_widget(child)
if (self.year_calendar-2020)/4==int((self.year_calendar-2020)/4):
start_week_day=self.find_week_day(ind,1)
else:
start_week_day=self.find_week_day(ind,1)
#print(Time_lib.mounth_ru[Time_lib.mounth_ru.index(self.Mounth.text)+1])
for space in range(start_week_day+int(self.Caps_year.text)-2020):
self.Grid_Cald.add_widget(wd())
K+=1
if K>=7:
sp=K%7
for child in self.Grid_Cald.children[:space-sp+1]:
self.Grid_Cald.remove_widget(child)
for date in range(qua):
self.Date_cald=bt(text=str(date+1),background_color=[0.46,0.46,0.46,1],background_normal='',on_press=self.click_calender_date)
if self.Date_cald.text==str(Time_lib.is_day()):
if self.Caps_year.text==str(Time_lib.is_year()):
if Time_lib.mounth_ru.index(self.Mounth.text)+1==Time_lib.is_mounth():
self.Date_cald.background_color=[1,0.3,0,1]
b=os.path.getsize(r'C:\Users\Nikit\OneDrive\Рабочий стол\NewApp\Diary\year_{}\mounth_{}\day_{}\Diary.txt'.format(self.Caps_year.text,str(Time_lib.mounth_ru.index(self.Mounth.text)+1),str(date+1)))
if b>0:
self.Date_cald.background_color=[0,1,0,1]
self.Grid_Cald.add_widget(self.Date_cald)
print(self.Caps_year.text)
def click_calender_date(self,btn):
self.click_date.append(btn.text)
self.lb.text='Ежедневник'
self.blocknode1.pos_hint={'x':0,'y':0}
self.Cald.pos_hint={'x':1,'y':0}
with open (r'C:\Users\Nikit\OneDrive\Рабочий стол\NewApp\Diary\year_{}\mounth_{}\day_{}\Diary.txt'.format(self.Caps_year.text,str(self.month_calendar),str(btn.text)),'r') as file_Diary:
self.blocknode1.text=file_Diary.read()
#print(file_Diary.read())
def find_week_day(self,month,Date):
Dict=dict()
if month in self.winter:
Dict=self.winter
elif month in self.spring:
Dict=self.spring
elif month in self.summer:
Dict=self.summer
elif month in self.auttumn:
Dict=self.auttumn
week_day=(Date+Dict[month])%7+1
return week_day
def click_year_right(self,inst):
s=int(self.Caps_year.text)
a=len(self.Caps_year.text)-1
num=self.Caps_year.text[a]
if s<2100:
num=int(num)
num=s+1
else:
num=0+s
self.Caps_year.text=str(num)
self.Year=self.Caps_year.text
self.update_calendar()
def click_Month_left(self,File):
ind=Time_lib.mounth_ru.index(self.Mounth.text)
year=self.Caps_year.text
year=int(year)
if ind<=1 and year<=2020:
ind=0
year=2020
self.Caps_year.text=str(year)
elif ind<=0 and year!=2020:
year-=1
ind=11
self.Caps_year.text=str(year)
else:
ind-=1
self.Mounth.text=str(Time_lib.mounth_ru[ind])
self.update_calendar()
def click_Month_right(self,func):
ind=Time_lib.mounth_ru.index(self.Mounth.text)
year=self.Caps_year.text
year=int(year)
if ind>=len(Time_lib.mounth_ru)-1 and year>=2100:
ind=11
year=2100
self.Caps_year.text=str(year)
elif ind>=len(Time_lib.mounth_ru)-1 and year!=2100:
year+=1
ind=0
self.Caps_year.text=str(year)
else:
ind+=1
self.Mounth.text=str(Time_lib.mounth_ru[ind])
self.update_calendar()
def cick_year_left(self,inst):
s=int(self.Caps_year.text)
a=len(self.Caps_year.text)-1
num=self.Caps_year.text[a]
if s>2020:
num=int(num)
num=s-1
else:
num=0+s
self.Caps_year.text=str(num)
self.Year=self.Caps_year.text
self.update_calendar()
def click_diary(self,inst):
self.lb.text='Ежедневник'
self.blocknode1.pos_hint={'x':0,'y':0}
self.Cald.pos_hint={'x':1,'y':0}
def click_calendar(self,func):
self.lb.text="Календарь"
self.blocknode.pos_hint={'x':-1,'y':0}
self.blocknode1.pos_hint={'x':1,'y':0}
self.Cald.pos_hint={'x':0,'y':0}
def click_black_list(self,func):
self.lb.text='Блокнот'
self.blocknode.pos_hint={'x':0,'y':0}
self.blocknode1.pos_hint={'x':1,'y':0}
self.Cald.pos_hint={'x':1,'y':0}
def save(self,b):
if self.blocknode.pos_hint=={'x':0,'y':0}:
with open ('Black_node.txt','w') as f:
f.write(self.blocknode.text)
elif self.blocknode1.pos_hint=={'x':0,'y':0}:
with open(r'C:\Users\Nikit\OneDrive\Рабочий стол\NewApp\Diary\year_{}\mounth_{}\day_{}\Diary.txt'.format(self.Caps_year.text,str(self.month_calendar),self.click_date[len(self.click_date)-1]),'w') as D:
D.write(self.blocknode1.text)
self.update_calendar()
def build(self):
self.winter={'Декабрь':6,'Январь':1,'Февраль': 4}
self.spring={'Март':4,'Апрель':0,'Май':2}
self.summer={'Июнь':5,'Июль':0,'Август':3}
self.auttumn={'Сентябрь':6,'Октябрь':1,'Ноябрь':4}
menu=bl(padding=[3,3],size_hint=[1,0.2],spacing=3)
pre_menu=bl(orientation='vertical',size_hint=[1,1],spacing=20)
main=al(anchor_x='center',anchor_y='top')
back_view=al(anchor_x='center',anchor_y='top')
#pre_main=al(anchor_x='')
self.save_button=bt(background_normal='disketa2_2.jpg',size_hint=[1,1],on_press=self.save)
self.calendar=bt(text='Календарь',background_color=[0,0.9,0.4,1],background_normal='',font_size=10,on_press=self.click_calendar)
self.black_list=bt(text='Блокнот',background_color=[0,0.9,0.4,1],background_normal='',font_size=10,on_press=self.click_black_list)
self.diary=bt(text='Ежедневник',background_color=[0,0.9,0.4,1],background_normal='',font_size=10,on_press=self.click_diary)
self.lb=lbl(text='',size_hint=[1,0.05],font_size=25)
self.List=fl(size_hint=[3,0.75])
self.blocknode=ti(size_hint=[1/3,1],background_color=[0.7,1,0.3,1],font_size=20,background_normal='')
with open('Black_node.txt','r') as file:
self.blocknode.text=file.read()
self.blocknode1=ti(size_hint=[1/3,1],background_color=[0.48,0.8,0.38,1],font_size=20,background_normal='')
with open('Diary.txt','r') as file1:
self.blocknode1.text=file1.read()
#Создаем виджеты года в календаре
year_cald_layout=bl(size_hint=[0.8,1/7],orientation='horizontal')
year_layout=bl(size_hint=[0.8,1])
self.Caps_year=bt(background_color=[1,0.5,0.153,1],background_normal='',text=str(Time_lib.is_year()))
click_right=bt(background_normal='Click_right.png',size_hint=[0.4459,1],on_press=self.click_year_right)
click_left=bt(background_normal='CLick_left.png',size_hint=[0.4459,1],on_press=self.cick_year_left)
#Создаем виджеты месяца в календаре
mounth_cald_layout=bl(size_hint=[0.8,1/4])
click_right_month=bt(background_normal='Click_right.png',size_hint=[0.4459,0.5783],on_press=self.click_Month_right)
click_left_month=bt(background_normal='CLick_left.png',size_hint=[0.4459,0.5783],on_press=self.click_Month_left)
#Создаем наброски календаря
self.Mounth=bt(background_color=[1,0.5,0.153,1],background_normal='',text=str(Time_lib.mounth_ru[Time_lib.is_mounth()-1]),size_hint=[1,0.5783])
self.Cald=bl(orientation='vertical',size_hint=[1/3,1],spacing=-24)
Calen=bl(orientation='vertical')
self.Grid_Cald=gl(cols=7,size_hint=[1,2],spacing=3)
self.year_calendar=int(self.Caps_year.text)
Day_week=bl(size_hint=[1,1],padding=[0,14,0,0])
for i in range(7):
Day_week.add_widget(lbl(text=Time_lib.week_day_ru[i],font_size=16,color=[1,0,0,1],size_hint=[1,1]))
self.month_calendar=Time_lib.mounth_ru.index(self.Mounth.text)+1
self.yc=str(self.year_calendar)
quanity_of_day=len(os.listdir(r'C:\Users\Nikit\OneDrive\Рабочий стол\NewApp\Diary\year_{}\mounth_{}'.format(self.year_calendar,self.month_calendar)))
for date in range(quanity_of_day+1):
if date==0:
if (self.year_calendar-2020)/4==int((self.year_calendar-2020)/4):
start_week_day=self.find_week_day(self.Mounth.text,date)+1
else:
start_week_day=self.find_week_day(self.Mounth.text,date)
K=0
for space in range(start_week_day+int(self.Caps_year.text)-2020):
self.Grid_Cald.add_widget(wd())
K+=1
if K>=7:
sp=K%7
for child in self.Grid_Cald.children[:space-sp+1]:
self.Grid_Cald.remove_widget(child)
else:
self.Date_cald=bt(text=str(date),background_color=[0.46,0.46,0.46,1],background_normal='',on_press=self.click_calender_date)
if self.Date_cald.text==str(Time_lib.is_day()) and self.Caps_year.text==str(Time_lib.is_year()) and self.month_calendar==Time_lib.is_mounth():
self.Date_cald.background_color=[1,0.3,0,1]
if date>=0 and date<quanity_of_day:
pass
self.Grid_Cald.add_widget(self.Date_cald)
Calen.add_widget(Day_week)
Calen.add_widget(self.Grid_Cald)
#Добавляем виджеты года в календаре
year_cald_layout.add_widget(click_left)
year_cald_layout.add_widget(self.Caps_year)
year_cald_layout.add_widget(click_right)
#Добавляем виджеты месяца в календаре
mounth_cald_layout.add_widget(click_left_month)
mounth_cald_layout.add_widget(self.Mounth)
mounth_cald_layout.add_widget(click_right_month)
#Соединяем друг с другом виджеты календаря
self.Cald.add_widget(year_cald_layout)
self.Cald.add_widget(mounth_cald_layout)
self.Cald.add_widget(Calen)
#Добавляем виджеты меню
menu.add_widget(self.save_button)
menu.add_widget(self.calendar)
menu.add_widget(self.black_list)
menu.add_widget(self.diary)
#Скрепляем задний фон и меню
pre_menu.add_widget(menu)
pre_menu.add_widget(self.lb)
self.List.add_widget(self.Cald)
self.List.add_widget(self.blocknode)
self.List.add_widget(self.blocknode1)
pre_menu.add_widget(self.List)
back_view.add_widget(AppApp())
back_view.add_widget(pre_menu)
main.add_widget(back_view)
return main
if __name__=='__main__':
AppApp().run()
else:
exit() |