Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import tkinter
- import grcalendar
- import random
- import datetime
- class App():
- def __init__(self, root):
- self.large_font = "Consolas 20" # άλλαξε το μορφότυπο για τα πλήκτρα
- self.medium_font = "Consolas 12" # άλλαξε το μορφότυπο για το ημερολόγιο
- self.colors = self.load_colors()
- root.title("Ελληνικό Ημερολόγιο")
- root.wm_geometry("800x800-50+50")
- self.year = int(datetime.datetime.now().year)
- self.widgets()
- def widgets(self):
- medium_font = "Consolas 12"
- self.f1 = tkinter.Frame(root)
- color = random.randint(1, len(self.colors))
- self.f1.pack()
- self.entryText = tkinter.StringVar()
- button_previous = tkinter.Button(self.f1, font=self.large_font, text=" << ", command=self.previous_year)
- button_previous.pack(side='left', expand=True)
- label = tkinter.Label(self.f1, font=self.large_font, text=" Έτος: ")
- label.pack(side='left', expand=True)
- self.year_box = tkinter.Entry(self.f1, font=self.large_font, textvariable=self.entryText, width=5)
- self.year_box.insert(0, self.year)
- self.year_box.pack(side='left', expand=True)
- self.year_box.bind("<Return>", self.this_year)
- button = tkinter.Button(self.f1, font=self.large_font, text=" ΟΚ ")
- button.pack(side='left', expand=True)
- button.bind('<Button-1>', self.this_year)
- button_next = tkinter.Button(self.f1, font=self.large_font, text=" >> ", command=self.next_year)
- button_next.pack(side='left', expand=True, fill='both')
- self.f2 = tkinter.Frame(root)
- self.f2.pack(expand=True, fill='both')
- self.text = tkinter.Text(self.f2, font=self.medium_font)
- self.scroll = tkinter.Scrollbar(self.f2, command=self.text.yview)
- self.scroll.pack(side='right', fill='both')
- self.text.configure(yscrollcommand=self.scroll.set)
- self.text.pack(side='left', fill='both', padx=20, pady=20)
- self.text.configure(background = self.colors[color])
- self.show_year()
- def load_colors(self):
- self.color_list=[]
- try:
- file_color = open('light_colors.txt', 'r')
- content = file_color.read().split('\n')
- for i in content:
- self.color_list.append(i)
- except: pass
- finally: return self.color_list
- def previous_year(self):
- self.year -= 1
- self.year_box.delete('0', 'end')
- self.year_box.insert(0, self.year)
- color = random.randint(1, len(self.colors) - 1)
- self.text.configure(background = self.colors[color])
- self.show_year()
- def next_year(self):
- self.year += 1
- self.year_box.delete('0', 'end')
- self.year_box.insert(0, self.year)
- color = random.randint(1, len(self.colors) - 1)
- self.text.configure(background = self.colors[color])
- self.show_year()
- def this_year(self, event):
- if str(self.year) != str(self.year_box.get()):
- color = random.randint(1, len(self.colors) - 1)
- self.text.configure(background = self.colors[color])
- year = self.year_box.get()
- try:
- self.year = int(year)
- self.show_year()
- except:
- pass
- def show_year(self):
- self.text.delete('1.0', 'end')
- bruh = grcalendar.Gr_Calendar(self.year)
- self.text.insert('end', bruh)
- root = tkinter.Tk()
- a = App(root)
- root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment