-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCalendar.py
59 lines (43 loc) · 1.57 KB
/
Calendar.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
import calendar
import tkinter as tk
import os
def getCalendar():
gui = tk.Tk()
gui.config(background='grey')
year = int(year_field.get())
gui.title(f"Calendar for {year}")
gui.geometry("600x560")
gui.minsize(600, 560)
gui_text = calendar.calendar(year)
calYear = tk.Text(gui, width=600, height=600, font="Consolas 10 bold")
calYear.insert(tk.INSERT, gui_text)
calYear.config(state="disabled")
calYear.grid(row=1, column=1, padx=20, pady=5)
print(gui_text)
gui.grid_rowconfigure(1, weight=1)
gui.grid_columnconfigure(1, weight=1)
gui.mainloop()
if __name__ == '__main__':
root = tk.Tk()
root.config(background='grey')
root.title("Calendar")
root.geometry("242x200")
icon = tk.PhotoImage(file = os.path.join(os.path.dirname(__file__), 'calendar-512.png'))
root.iconphoto(True, icon)
cal = tk.Label(root, text=" Calendar ",
bg='grey', font=("times", 32, "bold"))
year = tk.Label(root, text="Enter year below", bg='dark grey')
year_field = tk.Entry(root)
button = tk.Button(root, text='Show Calendar',
fg='Black', bg='Green', command=getCalendar)
Exit = tk.Button(root, text='Exit', fg='Black',
bg='Red', command=root.destroy)
cal.grid(row=1, column=1)
year.grid(row=2, column=1)
year_field.grid(row=3, column=1)
button.grid(row=4, column=1)
Exit.grid(row=6, column=1)
for i in range(6):
root.grid_rowconfigure(i, weight=1)
root.grid_columnconfigure(1, weight=1)
root.mainloop()