This repository was archived by the owner on Jul 2, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
210 lines (172 loc) · 3.71 KB
/
main.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
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
# ============================
# Imports
# ============================
import tkinter as tk
import datetime
from tkinter import PhotoImage, Button, Tk, Label, Frame, Text, Toplevel
from tkcalendar import Calendar
from modules.functions import closeWindow, getCacheDir, getEntriesDir, done
from modules.menubar import menu
# ============================
#
# ============================
# ============================
# Defining Variables
# ============================
cacheDir = getCacheDir()
entriesDir = getEntriesDir()
# ============================
#
# ============================
# ============================
# Gui Config
# ============================
window = Tk()
width= window.winfo_screenwidth()
height= window.winfo_screenheight()
window.geometry(
str(width) + "x" + str(height-70) + "+0+0"
)
window.title(
"Diary Journal"
)
window.configure(
bg='#444444'
)
# ============================
#
# ============================
# ============================
# Defining Functions
# ============================
def close():
closeWindow(window, entriesDir)
def other():
top = Toplevel(
window
)
today = datetime.date.today()
cal = Calendar(
top,
font="Ubuntu 14",
selectmode='day',
locale='en_US',
cursor="hand1",
maxdate=today
).pack(
fill="both",
expand=True
)
def otherDone():
date = datetime.date.fromisoformat(
str(
cal.selection_get()
)
)
done(entry.get("1.0", tk.END), date, entry, entriesDir)
top.destroy()
Button(
top,
text=" OK ",
font="Ubuntu 15",
command=otherDone
).pack(
padx=5,
pady=5
)
def yesterday():
date = datetime.date.today() - datetime.timedelta(
days=1
)
done(entry.get("1.0", tk.END), date, entry, entriesDir)
def today():
date = datetime.date.today()
done(entry.get("1.0", tk.END), date, entry, entriesDir)
# ============================
#
# ============================
# ============================
# Body
# ============================
frame = Frame(
window,
bg='#444444'
)
greeting = Label(
text="Hello Naffy, What is new today?",
height=3,
font=("Comic Sans MS", 20, "bold"),
bg='#444444',
fg='#cccccc'
).pack()
entry = Text(
height=20,
font=("Comic Sans MS", 13),
bg='#cccccc'
)
entry.pack()
nowImg = PhotoImage(
file='./assets/today.png'
)
yestImg = PhotoImage(
file='./assets/yesterday.png'
)
otherImg = PhotoImage(
file='./assets/other.png'
)
button2 = Button(
frame,
image=yestImg,
borderwidth=0,
bg='#444444',
command=yesterday
).pack(
side="left",
padx=5,
pady=2
)
button3 = Button(
frame,
image=otherImg,
borderwidth=0,
bg='#444444',
command=other
).pack(
side="right",
padx=5,
pady=2
)
button = Button(
frame,
image=nowImg,
borderwidth=0,
bg='#444444',
command=today
).pack(
side="right",
padx=5,
pady=2
)
frame.pack(
expand=True,
padx=10,
pady=10
)
# ============================
#
# ============================
# ============================
# Calling and Binding Functions
# ============================
menu(window, close, entriesDir)
window.protocol(
'WM_DELETE_WINDOW',
close
)
# ============================
#
# ============================
# ============================
# Start App
# ============================
window.mainloop()