class MyCalendar(tk.Tk):
    def __init__(self, *args, **kwargs):
        tk.Tk.__init__(self, *args, **kwargs)

        #Create calendar
        self.cal = Calendar(self,
                            font="Arial 14",
                            selectmode='day',
                            tooltipforeground='black',
                            tooltipbackground='pink',
                            tooltipalpha='1',
                            tooltipdelay='0')
        date = self.cal.datetime.today()

        #Add in events
        self.cal.c1 = self.cal.calevent_create(
            date + self.cal.timedelta(days=5), "F**k me in the ass", 'message')
        self.cal.calevent_create(date, 'Bake cookies at 3am', 'reminder')
        self.cal.calevent_create(date + self.cal.timedelta(days=-2),
                                 'Date at McDonalds', 'reminder')
        self.cal.calevent_create(date + self.cal.timedelta(days=3),
                                 'Mine Diamonds with Jimothy', 'message')

        #Set calendar and adjust colours
        self.cal.tag_config('reminder', background='red', foreground='yellow')
        self.cal.pack(fill="both", expand=True)

        #Set status/tool tip bar
        self.l2 = tk.Label(self,
                           text="Click on a date to check for events!",
                           width=40)
        self.l2.pack(side="bottom")

        #Executes "set_date" when a day is clicked
        self.cal.bind("<<CalendarSelected>>", self.set_date)

    def set_date(self, event):

        #Get the date clicked
        self.date = self.cal.get_date()

        #Convert date from string format to datetime object format
        self.DTObject = datetime.strptime(self.date, '%m/%d/%y')

        #Get tuple of events on the date clicked
        self.eventslist = self.cal.get_calevents(self.DTObject)

        #If there >0 events, display first event on status/tool tip bar
        if len(self.eventslist) > 0:
            self.l2.configure(
                text=self.cal.calevents[self.eventslist[0]]["text"])

        #Display no events
        else:
            self.l2.configure(text="No events for " + self.date)
def calendar_events(): 
    global username 
    top = tk.Toplevel(root)
    cal = Calendar(top, selectmode='none') 
    date = cal.datetime.today()
    cal.calevent_create(date, 'Today', 'message') 
    for item in db.get_tasks(username):
        dd=datetime.strptime(item[5], "%d-%m-%Y")
        cal.calevent_create(dd,item[1], 'reminder')
        cal.tag_config('reminder', background='red', foreground='yellow')
        cal.pack(fill="both", expand=True)
Beispiel #3
0
def example2():
    top = tk.Toplevel(root)

    cal = Calendar(top, selectmode='none')
    date = cal.datetime.today() + cal.timedelta(days=2)
    cal.calevent_create(date, 'Hello World', 'message')
    cal.calevent_create(date, 'Reminder 2', 'reminder')
    cal.calevent_create(date + cal.timedelta(days=-2), 'Reminder 1', 'reminder')
    cal.calevent_create(date + cal.timedelta(days=3), 'Message', 'message')

    cal.tag_config('reminder', background='red', foreground='yellow')

    cal.pack(fill="both", expand=True)
    ttk.Label(top, text="Hover over the events.").pack()
Beispiel #4
0
def create_calendar():
    print("Tworzenie nowego kalendarza...")
    tk_cal = T_cal(root, selectmode='none', headersforeground='white', headersbackground='black',
                   normalbackground='black', normalforeground='white', disabledbackground='black',
                   disabledforeground='gray', weekendbackground='black', weekendforeground='gray',
                   othermonthbackground='black', othermonthforeground='gray',
                   othermonthwebackground='black', tooltipforeground='red', tooltipbackground='black',
                   tooltipalpha=float(1), borderwidth=0, showothermonthdays=False, locale='pl_PL',
                   selectbackground='gray')
    from cal import Calendar
    calendar = Calendar()
    for k, v in calendar.get_holidays().items():
        k = k + str(' 10:47:14.489795')
        date = datetime.datetime.strptime(k, '%Y-%m-%d %H:%M:%S.%f')
        if v[0] == '!':
            tk_cal.calevent_create(date, v, 'other')
        else:
            tk_cal.calevent_create(date, v, 'holidays')
    tk_cal.tag_config('holidays', background='red', foreground='white')
    tk_cal.tag_config('other', background='green', foreground='white')

    tk_cal.pack(fill="none", expand=False)
    ttk.Label(root, textvariable=u_hol_val, background='black', foreground='white', justify='center').pack()
def calendrier():
    destroy_all_frame()
    global f1
    f1 = tk.Frame(fenetre, width=1000, height=900, bg="blue")
    f1.pack(fill="both", expand=1)

    cal = Calendar(f1,
                   selectmode='day',
                   disabledforeground='red',
                   cursor="hand1")

    date = cal.datetime.today() + cal.timedelta(days=2)

    cal.calevent_create(date + cal.timedelta(days=-2), 'Reminder 1',
                        'reminder')
    cal.tag_config('reminder', background='red', foreground='yellow')
    cal.pack(fill="both", expand=True)

    ttk.Button(f1,
               text="Mon emploi sur ce jour",
               padding=5,
               command=lambda: print_sel(cal)).pack(fill="both")

    fenetre.update()
class CalendarView(View):
    def __init__(self, parent, controller):
        View.__init__(self, parent, controller)

        self.mindate = datetime.date.today() - datetime.timedelta(days=30)
        self.calendar = Calendar(self,
                                 font="Comic_Sans 14",
                                 selectmode='day',
                                 locale='en_US',
                                 mindate=self.mindate,
                                 disabledforeground='red',
                                 cursor="hand2")

        self.calendar.tag_config('Komunia',
                                 background='yellow',
                                 foreground='black')
        self.calendar.tag_config('Wesele',
                                 background='red',
                                 foreground='black')
        self.calendar.tag_config('Spotkanie biznesowe',
                                 background='blue',
                                 foreground='white')
        self.calendar.tag_config('Urodziny',
                                 background='black',
                                 foreground='yellow')

        self.button_frame = tk.Frame(self)
        self.buttons = []
        self.__build_grid()

        self.grid_columnconfigure(0, weight=1)

    def __build_grid(self):
        self.calendar.grid(column=0, row=0)
        self.button_frame.grid(column=0, row=1)

    def get_date(self):
        return self.calendar.selection_get()
Beispiel #7
0
from tkinter import ttk
from tkcalendar import Calendar
cal = Calendar(top, selectmode='none')
date = cal.datetime.today() + cal.timedelta(days=2)
cal.calevent_create(date, 'Hello World', 'message')
cal.calevent_create(date, 'Reminder 2', 'reminder')
cal.calevent_create(date + cal.timedelta(days=-2), 'Reminder 1', 'reminder')
cal.calevent_create(date + cal.timedelta(days=3), 'Message', 'message')

cal.tag_config('reminder', background='red', foreground='yellow')

cal.pack(fill="both", expand=True)
ttk.Label(top, text="Hover over the events.").pack()
Beispiel #8
0
Grid.rowconfigure(root, 0, weight=1)
Grid.columnconfigure(root, 0, weight=1)

cal = Calendar(
    root,
    font="Arial 25",
    locale='en_US',
    showweeknumbers=False,
    showothermonthdays=False,
)
entry = ttk.Entry(root)
btn = ttk.Button(root, text="Choose file", command=OnChooseFile)
btn_parse = ttk.Button(root, text="Parse", command=OnParse)

cal.grid(row=0,
         column=0,
         rowspan=8,
         columnspan=8,
         sticky=tk.N + tk.S + tk.W + tk.E)
entry.grid(row=8, column=0, columnspan=7, sticky=tk.W + tk.E)
btn.grid(row=8, column=7)
btn_parse.grid(row=9, column=0, rowspan=1, columnspan=8)

cal.bind("<<CalendarSelected>>", OnSelected)
cal.bind("<<CalendarMonthChanged>>", OnMonthChanged)

cal.tag_config('reminder', background='deep pink',
               foreground='white')  #background='royal blue'

root.mainloop()
Beispiel #9
0
    def test_calendar_calevents(self):
        widget = Calendar(self.window)
        widget.pack()
        self.window.update()
        evdate = date.today() + widget.timedelta(days=2)
        widget.calevent_create(evdate, 'Hello World', 'message')
        widget.calevent_create(evdate, 'Reminder 2', 'reminder')
        widget.calevent_create(evdate + widget.timedelta(days=-2),
                               'Reminder 1', 'reminder')
        widget.calevent_create(evdate + widget.timedelta(days=3), 'Message',
                               'message')

        widget.tag_config('reminder', background='red', foreground='yellow')
        widget.tag_config('test', background='blue', foreground='white')

        # get_calevents
        self.assertEqual(widget.get_calevents(), tuple(i for i in range(4)))
        self.assertEqual(widget.get_calevents(date=evdate), (0, 1))
        self.assertEqual(
            widget.get_calevents(date=evdate + widget.timedelta(days=-5)), ())
        self.assertEqual(widget.get_calevents(tag='message'), (0, 3))
        self.assertEqual(widget.get_calevents(tag='message', date=evdate),
                         (0, ))
        self.assertEqual(
            widget.get_calevents(tag='message',
                                 date=evdate + widget.timedelta(days=-2)), ())
        with self.assertRaises(TypeError):
            widget.get_calevents(date='12/12/2012')

        # cget / configure
        self.assertEqual(widget.calevent_cget(1, 'tags'), ['reminder'])
        self.assertEqual(widget.calevent_cget(0, 'text'), 'Hello World')
        self.assertEqual(widget.calevent_cget(2, 'date'),
                         evdate + widget.timedelta(days=-2))
        widget.calevent_configure(1, tags=['reminder', 'new'])
        self.assertEqual(widget.calevent_cget(1, 'tags'), ['reminder', 'new'])
        widget.calevent_configure(1, tags='reminder')
        self.assertEqual(widget.calevent_cget(1, 'tags'), ['reminder'])
        widget.calevent_configure(0, text='Hi')
        self.assertEqual(widget.calevent_cget(0, 'text'), 'Hi')
        self.assertNotIn(evdate + widget.timedelta(days=5),
                         widget._calevent_dates)
        widget.calevent_configure(3,
                                  date=evdate +
                                  widget.timedelta(days=5, minutes=2))
        self.assertEqual(widget.calevent_cget(3, 'date'),
                         evdate + widget.timedelta(days=5))
        self.assertIn(evdate + widget.timedelta(days=5),
                      widget._calevent_dates)
        widget.calevent_configure(2, date=evdate)
        self.assertEqual(widget.calevent_cget(2, 'date'), evdate)
        with self.assertRaises(ValueError):
            widget.calevent_cget(1, 'arg')
        with self.assertRaises(ValueError):
            widget.calevent_cget(5, 'date')
        with self.assertRaises(ValueError):
            widget.calevent_configure(5, text='a')
        with self.assertRaises(KeyError):
            widget.calevent_configure(1, test='a')
        with self.assertRaises(TypeError):
            widget.calevent_configure(1, date='a')

        # lower / raise
        self.assertEqual(widget._calevent_dates[evdate], [0, 1, 2])
        widget.calevent_lower(0)
        self.assertEqual(widget._calevent_dates[evdate], [1, 2, 0])
        widget.calevent_lower(1, 2)
        self.assertEqual(widget._calevent_dates[evdate], [2, 1, 0])
        widget.calevent_raise(0)
        self.assertEqual(widget._calevent_dates[evdate], [0, 2, 1])
        widget.calevent_raise(1, 2)
        self.assertEqual(widget._calevent_dates[evdate], [0, 1, 2])
        with self.assertRaises(ValueError):
            widget.calevent_raise(4)
        with self.assertRaises(ValueError):
            widget.calevent_raise(1, 4)
        with self.assertRaises(ValueError):
            widget.calevent_lower(4)
        with self.assertRaises(ValueError):
            widget.calevent_lower(1, 4)

        # tags
        self.assertEqual(set(widget.tag_names()),
                         set(('new', 'message', 'reminder', 'test')))
        self.assertEqual(widget.tag_cget('test', 'foreground'), 'white')
        self.assertEqual(widget.tag_cget('test', 'background'), 'blue')
        with self.assertRaises(ValueError):
            widget.tag_cget('hello', 'background')
        with self.assertRaises(ValueError):
            widget.tag_cget('test', 'text')
        with self.assertRaises(ValueError):
            widget.tag_delete('birthday')
        widget.tag_delete('message')
        self.assertEqual(set(widget.tag_names()),
                         set(('new', 'reminder', 'test')))
        self.assertEqual(widget.calevent_cget(0, 'tags'), [])

        # remove
        widget.calevent_remove(0)
        self.assertEqual(widget.get_calevents(), tuple(i for i in range(1, 4)))
        widget.calevent_remove(date=evdate + widget.timedelta(days=3))
        self.assertEqual(widget.get_calevents(), tuple(i for i in range(1, 4)))
        widget.calevent_remove(date=evdate + widget.timedelta(days=5))
        self.assertEqual(widget.get_calevents(), tuple(i for i in range(1, 3)))
        widget.calevent_remove(tag='reminder')
        self.assertEqual(widget.get_calevents(), ())
        widget.calevent_create(evdate, 'Hello World', 'message')
        widget.calevent_create(evdate, 'Reminder 2', 'reminder')
        widget.calevent_create(evdate + widget.timedelta(days=-2),
                               'Reminder 1', 'reminder')
        widget.calevent_create(evdate + widget.timedelta(days=3), 'Message',
                               'message')
        self.window.update()
        self.assertEqual(widget.get_calevents(), tuple(i for i in range(4)))
        widget.calevent_remove(tag='reminder', date=evdate)
        self.assertEqual(widget.get_calevents(), (0, 2, 3))
        widget.calevent_remove(3, tag='reminder', date=evdate)
        self.assertEqual(widget.get_calevents(), (0, 2))
        widget.calevent_remove('all')
        self.assertEqual(widget.get_calevents(), ())
               selectmode='none',
               background='#ececec',
               foreground='Black',
               tooltipforeground='Green',
               bordercolor='Black',
               selectbackground='Red',
               selectforeground='Green',
               weekendbackground='Red',
               weekendforeground='Red',
               othermonthforeground='Lightgray',
               showothermonthdays=True,
               headersforeground='Blue',
               borderwidth=2,
               font='Arial 15 bold')

cal.tag_config('reminder', highlightbackground='red', foreground='green')

cal.pack(fill="both", expand=True)

tab_parent.pack(expand=1, fill='both')

b3 = Button(form,
            text='Close',
            command=closeWindow,
            width=10,
            bd=5,
            fg='black',
            bg='lightblue')
b3.config(font='Arial 15 bold')
b3.pack()
Beispiel #11
0
                year=2015,
                month=5,
                date_pattern='dd/mm/y',
                font='Arial 8')
cal2.configure(state='disabled')
cal2.grid(row=1, column=6, columnspan=2)
datelis = []
for tup in all_log_tup:
    dtf = re.split('/', tup[3])
    dtf = [int(x) for x in dtf]
    log_date = datetime.date(dtf[0], dtf[1], dtf[2])
    if log_date not in datelis:
        datelis.append(log_date)
        cal1.calevent_create(log_date, 'log', tags=['log'])
        cal2.calevent_create(log_date, 'log', tags=['log'])
cal1.tag_config('log', background='Green')
cal2.tag_config('log', background='Green')
##########overall stat##################################
frame_stat = LabelFrame(root, text="Stats")
###
frame_os = LabelFrame(frame_stat, text="Overall")
frame_os.grid(row=0, column=0, sticky='n')
la1 = Label(frame_os, text="Log(DB): " + str(len(all_log_tup)))
la1.grid(row=0, column=0, sticky='w')
la2 = Label(frame_os, text="IP(DB): " + str(len(all_ip_tup)))
la2.grid(row=1, column=0, sticky='w')
Label(frame_os, text="").grid(row=2, column=0)
la3 = Label(frame_os, text="Log(vis): " + str(len(all_log_tup)))
la3.grid(row=3, column=0, sticky='w')
la4 = Label(frame_os, text="IP(vis): " + str(len(all_ip_tup)))
la4.grid(row=4, column=0, sticky='w')
def main():

    grader_menu = Label(grader_menu_Frame,
                        bg="gray26",
                        font=("Times New Roman (Times)", 24,
                              "bold"))  # aristero menu
    gmenu_l_up = Label(grader_menu,
                       image=render2,
                       borderwidth=1,
                       highlightthickness=0,
                       bg="gray26")  # photo parmenidi
    gmenu_l_down = Label(grader_menu,
                         borderwidth=1,
                         highlightthickness=0,
                         bg="gray26")  # button gia menu kai alla frames

    initialGrader_all = Label(grader_intro_Frame,
                              borderwidth=1,
                              highlightthickness=0,
                              bg="floral white")  # dexia arxikh selida
    initialGrader_all_top = Label(initialGrader_all,
                                  text='Καλώς ορίσατε στον Παρμενίδη!',
                                  borderwidth=1,
                                  highlightthickness=0,
                                  bg="floral white",
                                  font=("Times New Roman (Times)", 36, "bold"))
    initialGrader_all_bot = Label(initialGrader_all,
                                  borderwidth=1,
                                  highlightthickness=0,
                                  bg="floral white")
    initialGrader_ab_top = Label(
        initialGrader_all_bot,
        borderwidth=1,
        highlightthickness=0,
        bg="floral white")  #include user name and calendar
    initialGrader_abt_left = Label(
        initialGrader_ab_top,
        borderwidth=1,
        highlightthickness=0,
        bg="floral white")  #user grader name left side
    initialGrader_abtl_top = Label(
        initialGrader_abt_left,
        borderwidth=1,
        highlightthickness=0,
        bg="floral white")  #user grader name top left previous side
    initialGrader_abtlt_left = Label(
        initialGrader_abtl_top,
        borderwidth=1,
        highlightthickness=0,
        bg="floral white")  #user grader name top of left side
    initialGrader_abtltl_left = Label(initialGrader_abtlt_left,
                                      text='Είστε συνδεδεμένοι ως: ',
                                      borderwidth=1,
                                      highlightthickness=0,
                                      bg="floral white",
                                      font=("Times New Roman (Times)", 18,
                                            "bold"))

    initialGrader_abtltl_right = Label(initialGrader_abtlt_left,
                                       text=curGrader.name,
                                       borderwidth=1,
                                       highlightthickness=0,
                                       bg="floral white",
                                       font=("Times New Roman (Times)", 18,
                                             "bold"))
    initialGrader_abt_right = Label(
        initialGrader_ab_top,
        borderwidth=1,
        highlightthickness=0,
        bg="floral white")  #calenar and text include
    initialGrader_abtr_top = Label(initialGrader_abt_right,
                                   text='Ημερολόγιο',
                                   borderwidth=1,
                                   highlightthickness=0,
                                   bg="floral white",
                                   font=("Times New Roman (Times)", 18,
                                         "bold"))  #calendar text
    initialGrader_abtr_bot = Label(initialGrader_abt_right,
                                   borderwidth=1,
                                   highlightthickness=0,
                                   bg="floral white")  #calendar
    initialGrader_ab_bot = Label(initialGrader_all_bot,
                                 borderwidth=1,
                                 highlightthickness=0,
                                 bg="floral white")  #include announcements
    initialGrader_abb_top = Label(initialGrader_ab_bot,
                                  borderwidth=1,
                                  highlightthickness=0,
                                  bg="floral white")
    initialGrader_abbt_left = Label(initialGrader_abb_top,
                                    text='Ανακοινώσεις',
                                    borderwidth=1,
                                    highlightthickness=0,
                                    bg="floral white",
                                    font=("Times New Roman (Times)", 18,
                                          "bold"))  #announcement title
    initialGrader_abb_bot = Frame(initialGrader_ab_bot,
                                  bg="cyan2")  #announcement box

    #orismos listbox anakoinwsewn
    ministry_news_list = Listbox(
        initialGrader_abb_bot,
        bg="floral white",
        borderwidth=2,
        highlightthickness=0)  #width=getRes[0]-50, height=getRes[1]-70

    scrollh = Scrollbar(initialGrader_abb_bot,
                        orient="horizontal",
                        command=ministry_news_list.xview)
    scrollv = Scrollbar(initialGrader_abb_bot,
                        orient="vertical",
                        command=ministry_news_list.yview)
    initialGrader_abb_bot.bind(
        "<Configure>", lambda e: ministry_news_list.configure(
            scrollregion=ministry_news_list.bbox("all")))
    ministry_news_list.configure(yscrollcommand=scrollv.set,
                                 xscrollcommand=scrollh.set,
                                 font=("Times New Roman (Times)", 18))
    initialGrader_abb_bot.bind("<MouseWheel>",
                               scrollv)  #ΚΑΘΕΤΟ SCROLL ΜΕ ΡΟΔΑ ΠΟΝΤΙΚΙΟΥ

    #ορισμος ημερολογιου
    cal_intro = Calendar(initialGrader_abtr_bot, selectmode='none')
    date = cal_intro.datetime.today() + cal_intro.timedelta(days=2)
    cal_intro.calevent_create(date, 'Hello World', 'message')
    cal_intro.calevent_create(date, 'Reminder 2', 'reminder')
    cal_intro.calevent_create(date + cal_intro.timedelta(days=-2),
                              'Reminder 1', 'reminder')
    cal_intro.calevent_create(date + cal_intro.timedelta(days=3), 'Message',
                              'message')
    cal_intro.tag_config('reminder',
                         background='red',
                         normalforeground='black',
                         weekendforeground='black',
                         weekendbackground='gray63',
                         foreground='yellow')

    #orismos buttons
    btn_next0 = Button(
        gmenu_l_down,
        text="Αρχική Σελίδα",
        command=lambda: raiseNdrop_frame(grader_intro_Frame, previous_frame),
        bg="gray26",
        height=2,
        width=35,
        font=("Calibri", 14, "bold"))
    btn_next1 = Button(
        gmenu_l_down,
        text="Στοιχεία Χρήστη",
        command=lambda: raiseNdrop_frame(graderInfo_Frame, previous_frame),
        bg="gray26",
        height=2,
        width=35,
        font=("Calibri", 14, "bold"))
    btn_next2 = Button(
        gmenu_l_down,
        text="Πανελλήνιες",
        command=lambda: raiseNdrop_frame(pexams_Frame, previous_frame),
        bg="gray26",
        height=2,
        width=35,
        font=("Calibri", 14, "bold"))
    btn_next3 = Button(
        gmenu_l_down,
        text="Προβλήματα",
        command=lambda: raiseNdrop_frame(problems_Frame, previous_frame),
        bg="gray26",
        height=2,
        width=35,
        font=("Calibri", 14, "bold"))
    btn_next4 = Button(gmenu_l_down,
                       text="Έξοδος",
                       command=lambda: ExitApp(),
                       bg="gray26",
                       height=2,
                       width=35,
                       font=("Calibri", 14, "bold"))

    #packs εμφάνιση στοιχείων
    grader_menu.pack(side=LEFT, expand=1, fill=Y)
    gmenu_l_up.pack(side=TOP, pady=50)  #PARMENIDIS LOGO
    gmenu_l_down.pack(side=TOP)  #CONTAINS BUTTONS
    initialGrader_all.pack(side=TOP, fill=BOTH,
                           expand=1)  #δεξιο μενου-αρχικη σελίδα
    initialGrader_all_top.pack(side=TOP, fill=X, pady=50)
    initialGrader_all_bot.pack(side=LEFT, expand=1, fill=BOTH)
    initialGrader_ab_top.pack(side=TOP, expand=1, fill=BOTH, ipady=100)
    #αριστερη πλευρα με ονομα βαθμολογητή
    initialGrader_abt_left.pack(side=LEFT, fill=Y, padx=50)
    initialGrader_abtl_top.pack(side=TOP, fill=X)
    initialGrader_abtlt_left.pack(side=LEFT)
    initialGrader_abtltl_left.pack(side=TOP, pady=20)
    initialGrader_abtltl_right.pack(side=TOP)
    #δεξια πλευρα με ημερολογιο
    initialGrader_abt_right.pack(side=RIGHT, expand=1, fill=BOTH, padx=40)
    initialGrader_abtr_top.pack(side=TOP, fill=X)
    initialGrader_abtr_bot.pack(side=TOP, fill=BOTH, expand=1)  #hmerologio
    cal_intro.pack(fill=BOTH, expand=1)
    ttk.Label(initialGrader_abtr_bot, text="Hover over the events.").pack()
    #κατω πλευρα με ανακοινωσεις
    initialGrader_ab_bot.pack(side=TOP, expand=1, fill=BOTH)
    initialGrader_abb_top.pack(side=TOP, fill=X)
    initialGrader_abbt_left.pack(side=LEFT)
    initialGrader_abb_bot.pack(side=TOP, expand=1, fill=BOTH)
    scrollv.pack(side=RIGHT, fill=Y)
    scrollh.pack(side=BOTTOM, fill=X)
    ministry_news_list.pack(side=BOTTOM, expand=1, fill=BOTH)
    initialGrader_abb_bot.pack(side=BOTTOM, expand=1, fill=BOTH)

    #buttons MENU
    btn_next0.pack(side=TOP, pady=2, ipady=5)
    btn_next1.pack(side=TOP, pady=2, ipady=5)
    btn_next2.pack(side=TOP, pady=2, ipady=5)
    btn_next3.pack(side=TOP, pady=2, ipady=5)
    btn_next4.pack(side=TOP, pady=2, ipady=5)

    #add elements to announcements
    ministry_news_list.insert(
        1, "This is a test to see if the announcements works as it should be")
    ministry_news_list.insert(2, "Ανακοινωση Ημερομηνίας Δηλώσεων")
    ministry_news_list.insert(3, "Πρόγραμμα εξεταστικής έτους 2020-2021")
    ministry_news_list.insert(4, "#ΜΕΝΟΥΜΕ_ΣΠΙΤΙ")
    ministry_news_list.insert(5, "Έναρξη δηλώσεων μαθητών")
    ministry_news_list.insert(6, "ΠΑΡΜΕΝΙΔΗΣ ΜΕ TKINTER ΓΙΑ GUI")
    ministry_news_list.insert(
        7,
        "Πεισσότερες Ανακοινώσεις για να δούμε σε πράξη το κάθετο scroll και το horizontal scroll"
    )

    #---------------------------------------------------------------------------------------------------
    #---------------------------------------------------------------------------------------------------
    #---------------------------------------------------------------------------------------------------
    #---------------------------------------------------------------------------------------------------
    #---------------------------------------------------------------------------------------------------
    #---------------------------------------------------------------------------------------------------
    #graderInfo_Frame

    graderinfo_all = Label(graderInfo_Frame, bg="floral white")
    graderinfo_a_top = Label(graderinfo_all,
                             bg="floral white",
                             text="Πληροφορίες Χρήστη",
                             font=("Times New Roman (Times)", 36, "bold"),
                             fg="dodger blue")
    graderinfo_a_mid = Label(graderinfo_all, bg="floral white")  #info
    graderinfo_a_bot = Label(graderinfo_a_mid, bg="floral white")  # buttons

    graderinfo_am_general = Label(graderinfo_a_mid, bg="floral white")
    graderinfo_am_gen_title = Label(graderinfo_am_general,
                                    bg="SkyBlue1",
                                    text="Γενικά:",
                                    font=("Times New Roman (Times)", 18,
                                          "bold"),
                                    fg="black")
    graderinfo_am_gen_info = Label(
        graderinfo_am_general, bg="floral white")  # containt text and photo

    graderinfo_am_gen_info_left = Label(
        graderinfo_am_gen_info, bg="floral white")  #text info container
    #id
    graderinfo_id = Label(graderinfo_am_gen_info_left, bg="floral white")
    graderinfo_id_left = Label(graderinfo_id,
                               bg="floral white",
                               text="ID Χρήστη:\t",
                               font=("Times New Roman (Times)", 18, "bold"),
                               fg="black")
    graderinfo_id_right = Text(graderinfo_id,
                               bg="WHITE",
                               height=1,
                               width=30,
                               fg="black",
                               borderwidth=1,
                               highlightthickness=2,
                               font=("Times New Roman (Times)", 16))
    graderinfo_id_right.insert(END, curGrader.id)
    graderinfo_id_right.config(state=DISABLED)

    #password
    graderinfo_password = Label(graderinfo_am_gen_info_left, bg="floral white")
    graderinfo_pass_left = Label(graderinfo_password,
                                 bg="floral white",
                                 text="Κωδικός:\t",
                                 font=("Times New Roman (Times)", 18, "bold"),
                                 fg="black")
    graderinfo_pass_right = Text(graderinfo_password,
                                 bg="WHITE",
                                 height=1,
                                 width=30,
                                 fg="black",
                                 borderwidth=1,
                                 highlightthickness=2,
                                 font=("Times New Roman (Times)", 16))
    graderinfo_pass_right.insert(END, curGrader.data["password"])
    graderinfo_pass_right.config(state=DISABLED)

    #fullname
    graderinfo_fullname = Label(graderinfo_am_gen_info_left, bg="floral white")
    graderinfo_fullname_left = Label(graderinfo_fullname,
                                     bg="floral white",
                                     text="Ονοματεπώνυμο:\t",
                                     font=("Times New Roman (Times)", 18,
                                           "bold"),
                                     fg="black")
    graderinfo_fullname_right = Text(graderinfo_fullname,
                                     bg="WHITE",
                                     height=1,
                                     width=30,
                                     fg="black",
                                     borderwidth=1,
                                     highlightthickness=2,
                                     font=("Times New Roman (Times)", 16))
    graderinfo_fullname_right.insert(END, curGrader.name)
    graderinfo_fullname_right.config(state=DISABLED)

    #school
    graderinfo_school = Label(graderinfo_am_gen_info_left, bg="floral white")
    graderinfo_school_left = Label(graderinfo_school,
                                   bg="floral white",
                                   text="Σχολείο:\t\t",
                                   font=("Times New Roman (Times)", 18,
                                         "bold"),
                                   fg="black")
    graderinfo_school_right = Text(graderinfo_school,
                                   bg="WHITE",
                                   height=1,
                                   width=30,
                                   fg="black",
                                   borderwidth=1,
                                   highlightthickness=2,
                                   font=("Times New Roman (Times)", 16))
    graderinfo_school_right.insert(END, curGrader.data["school"])
    graderinfo_school_right.config(state=DISABLED)

    #photo
    graderinfo_am_gen_info_right = Label(
        graderinfo_am_gen_info, bg="floral white")  #photo info container
    graderinfo_photo_top = Label(graderinfo_am_gen_info_right,
                                 bg="floral white",
                                 text="Εικόνα Προφιλ:",
                                 font=("Times New Roman (Times)", 18, "bold"),
                                 fg="black")
    graderinfo_photo_mid = Label(graderinfo_am_gen_info_right,
                                 bg="floral white",
                                 image=render3)
    graderinfo_photo_bot = Label(graderinfo_am_gen_info_right,
                                 bg="floral white")  #button change invisible

    #contact information
    graderinfo_am_contact_info = Label(graderinfo_a_mid, bg="floral white")
    graderinfo_contact = Label(graderinfo_am_contact_info,
                               bg="SkyBlue1",
                               text="Επικοινωνία:",
                               font=("Times New Roman (Times)", 18, "bold"),
                               fg="black")
    graderinfo_contact_all = Label(
        graderinfo_am_contact_info,
        bg="floral white")  #contain email and number

    #email
    graderinfo_contact_email = Label(graderinfo_contact_all,
                                     bg="floral white")  #email container
    graderinfo_contact_email_left = Label(graderinfo_contact_email,
                                          bg="floral white",
                                          text="E-mail:\t\t",
                                          font=("Times New Roman (Times)", 18,
                                                "bold"),
                                          fg="black")
    graderinfo_contact_email_right = Text(graderinfo_contact_email,
                                          bg="WHITE",
                                          height=1,
                                          width=30,
                                          fg="black",
                                          borderwidth=1,
                                          highlightthickness=2,
                                          font=("Times New Roman (Times)", 16))
    graderinfo_contact_email_right.insert(END, curGrader.data["email"])
    graderinfo_contact_email_right.config(state=DISABLED)

    #number
    graderinfo_contact_number = Label(graderinfo_contact_all,
                                      bg="floral white")  #contain number
    graderinfo_contact_number_left = Label(graderinfo_contact_number,
                                           bg="floral white",
                                           text="Αριθμός Τηλεφώνου:",
                                           font=("Times New Roman (Times)", 18,
                                                 "bold"),
                                           fg="black")
    graderinfo_contact_number_right = Text(graderinfo_contact_number,
                                           bg="WHITE",
                                           height=1,
                                           width=30,
                                           fg="black",
                                           borderwidth=1,
                                           highlightthickness=2,
                                           font=("Times New Roman (Times)",
                                                 16))
    graderinfo_contact_number_right.insert(END, curGrader.data["number"])
    graderinfo_contact_number_right.config(state=DISABLED)

    btn_grader_info_edit = Button(graderinfo_a_bot,
                                  text="Επεξεργασία",
                                  command=lambda: edit_profile(),
                                  bg="floral white",
                                  font=("Times New Roman (Times)", 14, "bold"),
                                  height=1,
                                  width=12)
    btn_grader_save = Button(graderinfo_a_bot,
                             state=DISABLED,
                             text="Αποθήκευση",
                             command=lambda: save_profile(),
                             bg="floral white",
                             font=("Times New Roman (Times)", 14, "bold"),
                             height=1,
                             width=12)
    btn_grader_pic_edit = Button(graderinfo_photo_bot,
                                 state=DISABLED,
                                 text="Αλλαγή Εικόνας",
                                 command=lambda: edit_pic(),
                                 bg="floral white",
                                 font=("Times New Roman (Times)", 14, "bold"),
                                 height=1,
                                 width=12)

    #χρειαζόμαστε συνάρτηση για τα αρχικά Data sos
    def edit_pic():
        global temp_image
        path = filedialog.askopenfilename(filetypes=[("Image File", '.jpg')])
        im = Image.open(path)
        im = im.resize((100, 100), Image.ANTIALIAS)
        render3 = ImageTk.PhotoImage(im)
        graderinfo_photo_mid.configure(image=render3)
        graderinfo_photo_mid.image = render3
        temp_image = render3

    def edit_profile():
        #kane editable ta Text
        graderinfo_id_right.config(state=DISABLED)
        graderinfo_pass_right.config(state=NORMAL)
        graderinfo_fullname_right.config(state=DISABLED)
        graderinfo_school_right.config(state=DISABLED)
        graderinfo_contact_email_right.config(state=NORMAL)
        graderinfo_contact_number_right.config(state=NORMAL)
        btn_grader_pic_edit.config(state=NORMAL)
        btn_grader_save.config(state=NORMAL)

        #Emfanise duo koympia stis 8eseis pou prepei cancel kai save
        #pop-ups gia la8oi xrhsth
        #old password confirmation
        #password_btn)change

        print("edit")

    def save_profile():

        global temp_image  #Αποθηκευση Φωτογραφίας στη ΒΔ
        curGrader.editdata(
            graderinfo_pass_right.get("1.0", 'end-1c'),
            curGrader.data["school"],
            graderinfo_contact_email_right.get("1.0", 'end-1c'),
            graderinfo_contact_number_right.get("1.0", 'end-1c'))

        btn_grader_save.config(state=DISABLED)
        btn_grader_pic_edit.config(state=DISABLED)
        graderinfo_pass_right.config(state=DISABLED)
        graderinfo_contact_email_right.config(state=DISABLED)
        graderinfo_contact_number_right.config(state=DISABLED)

        print("save")

    #pack reveal
    #general labels
    graderinfo_all.pack(side=TOP, expand=1, fill=BOTH)
    graderinfo_a_top.pack(side=TOP)
    graderinfo_a_mid.pack(side=LEFT, expand=1, fill=BOTH, pady=50)
    graderinfo_a_bot.pack(side=BOTTOM, fill=X)

    #grader
    graderinfo_am_general.pack(side=TOP, expand=1, fill=BOTH)
    graderinfo_am_gen_title.pack(side=TOP, fill=X)
    graderinfo_am_gen_info.pack(side=TOP, fill=X)
    graderinfo_am_gen_info_left.pack(side=LEFT)

    #id
    graderinfo_id.pack(side=TOP, fill=X)
    graderinfo_id_left.pack(side=LEFT)
    graderinfo_id_right.pack(side=LEFT)

    #password
    graderinfo_password.pack(side=TOP, fill=X)
    graderinfo_pass_left.pack(side=LEFT)
    graderinfo_pass_right.pack(side=LEFT)

    #fullname
    graderinfo_fullname.pack(side=TOP, fill=X)
    graderinfo_fullname_left.pack(side=LEFT)
    graderinfo_fullname_right.pack(side=LEFT)

    #school
    graderinfo_school.pack(side=TOP, fill=X)
    graderinfo_school_left.pack(side=LEFT)
    graderinfo_school_right.pack(side=LEFT)

    #photo
    graderinfo_am_gen_info_right.pack(side=RIGHT, ipadx=100, fill=Y)
    graderinfo_photo_top.pack(side=TOP)
    graderinfo_photo_mid.pack(side=TOP)
    graderinfo_photo_bot.pack(side=TOP)

    #contact information
    graderinfo_am_contact_info.pack(side=TOP, expand=0, fill=X)
    graderinfo_contact.pack(side=TOP, fill=X)
    graderinfo_contact_all.pack(side=LEFT, expand=1, fill=BOTH)
    #email
    graderinfo_contact_email.pack(side=TOP, fill=X)
    graderinfo_contact_email_left.pack(side=LEFT)
    graderinfo_contact_email_right.pack(side=LEFT)
    #number
    graderinfo_contact_number.pack(side=TOP, fill=X)
    graderinfo_contact_number_left.pack(side=LEFT)
    graderinfo_contact_number_right.pack(side=LEFT)
    #button edit
    btn_grader_info_edit.pack(side=RIGHT, padx=50)
    btn_grader_save.pack(side=RIGHT)
    btn_grader_pic_edit.pack()

    #---------------------------------------------------------------------------------------------------
    #---------------------------------------------------------------------------------------------------
    #---------------------------------------------------------------------------------------------------
    #---------------------------------------------------------------------------------------------------
    #---------------------------------------------------------------------------------------------------
    #---------------------------------------------------------------------------------------------------
    #pexams_Frame

    pexams_all = Label(pexams_Frame,
                       borderwidth=0,
                       highlightthickness=0,
                       bg="floral white")  # dexia arxikh selida
    pexams_all_top = Label(pexams_all,
                           text='Εκχώρηση Βαθμολογίας',
                           borderwidth=1,
                           highlightthickness=0,
                           bg="floral white",
                           font=("Times New Roman (Times)", 36, "bold"))
    pexams_all_bot = Label(pexams_all,
                           borderwidth=1,
                           highlightthickness=0,
                           bg="floral white")
    pexams_ab_top = Label(pexams_all_bot,
                          borderwidth=1,
                          highlightthickness=0,
                          bg="floral white")  #include user name

    #ONOMA LISTAS
    grd_pexams_create_abt_top = Label(pexams_ab_top,
                                      borderwidth=1,
                                      highlightthickness=0,
                                      bg="floral white")  #LIST  name
    #ΣΤΟΙΧΕΙΑ ΜΑΘΗΤΗ
    pexams_abt_top1 = Label(pexams_ab_top,
                            borderwidth=1,
                            highlightthickness=0,
                            bg="floral white")  #student  name
    pexams_abt_top2 = Label(pexams_ab_top,
                            borderwidth=1,
                            highlightthickness=0,
                            bg="floral white")  #student  lastname
    pexams_abt_top3 = Label(pexams_ab_top,
                            borderwidth=1,
                            highlightthickness=0,
                            bg="floral white")  #student email

    std_reg_create_abtltl_l1 = Label(pexams_abt_top1,
                                     text='Κωδικός Υποψηφίου:',
                                     borderwidth=1,
                                     highlightthickness=0,
                                     bg="floral white",
                                     font=("Times New Roman (Times)", 18,
                                           "bold"))
    std_reg_create_abtltl_l2 = Label(pexams_abt_top2,
                                     text='Μάθημα:',
                                     borderwidth=1,
                                     highlightthickness=0,
                                     bg="floral white",
                                     font=("Times New Roman (Times)", 18,
                                           "bold"))
    std_reg_create_abtltl_l3 = Label(pexams_abt_top3,
                                     text='Βαθμός:',
                                     borderwidth=1,
                                     highlightthickness=0,
                                     bg="floral white",
                                     font=("Times New Roman (Times)", 18,
                                           "bold"))

    #TEXTS AS INPUTS!!!!!!!!!!!
    grd_pexams_create_abtltl_r1 = Text(pexams_abt_top1,
                                       bg="WHITE",
                                       height=1,
                                       width=40,
                                       fg="black",
                                       borderwidth=1,
                                       highlightthickness=2,
                                       font=("Calibri", 16))
    grd_pexams_create_abtltl_r2 = Label(pexams_abt_top2,
                                        bg="WHITE",
                                        fg="black",
                                        borderwidth=1,
                                        highlightthickness=2,
                                        font=("Calibri", 16))
    grd_pexams_create_abtltl_r3 = Text(pexams_abt_top3,
                                       bg="WHITE",
                                       height=1,
                                       width=40,
                                       fg="black",
                                       borderwidth=1,
                                       highlightthickness=2,
                                       font=("Calibri", 16))

    #DROP DOWN MENU ΓΙΑ ΕΠΙΛΟΓΗ SELECT ΑΠΟ ΒΑΣΗ ΔΕΔΟΜΕΝΩΝ
    lesson_choice = ["-"]
    for lesson in curGrader.lessons:
        lesson_choice.append(lesson.name)
    lesson_var = StringVar(grd_pexams_create_abtltl_r2)
    lesson_var.set(lesson_choice[0])  #ΑΡΧΙΚΗ ΤΙΜΗ ΤΑ ΝΕΟΤΕΡΑ
    lesson_choice = OptionMenu(grd_pexams_create_abtltl_r2, lesson_var,
                               *lesson_choice)
    lesson_choice.config(bg="snow", width=20)

    std_reg_create_ab_mid = Label(pexams_all_bot,
                                  borderwidth=1,
                                  highlightthickness=0,
                                  bg="floral white")  #include announcements
    std_reg_create_abm_top = Label(std_reg_create_ab_mid,
                                   borderwidth=1,
                                   highlightthickness=0,
                                   bg="floral white")
    std_reg_create_abmt_left = Label(std_reg_create_abm_top,
                                     text='Λίστα Βαθμαλογιών: ',
                                     borderwidth=1,
                                     highlightthickness=0,
                                     bg="floral white",
                                     font=("Times New Roman (Times)", 18,
                                           "bold"))  #announcement title
    std_reg_create_abm_bot = Label(std_reg_create_ab_mid,
                                   bg="floral white")  #list box

    grd_exams_create_ab_bot = Label(
        pexams_all_bot, borderwidth=1, highlightthickness=0,
        bg="floral white")  #ΚΑΤΩ ΠΛΕΥΡΑ ΜΕ ΚΟΥΜΠΙΑ NEXT KAI RETURN

    #ORISMOS BTNS
    btn_grd_create_return = Button(
        grd_exams_create_ab_bot,
        text="Επιστροφή",
        command=lambda: raiseNdrop_frame(grader_intro_Frame, previous_frame),
        bg="red4",
        font=("Times New Roman (Times)", 14, "bold"),
        height=1,
        width=15)
    btn_grd_create_confirm = Button(grd_exams_create_ab_bot,
                                    text="Επιβεβαίωση",
                                    command=lambda: confirm_registry(),
                                    bg="green4",
                                    font=("Times New Roman (Times)", 14,
                                          "bold"),
                                    height=1,
                                    width=15)
    btn_grd_delete_list = Button(grd_exams_create_ab_bot,
                                 text="Διαγραφή Λίστας",
                                 command=lambda: delete_list(),
                                 bg="floral white",
                                 font=("Times New Roman (Times)", 14, "bold"),
                                 height=1,
                                 width=15)
    btn_grd_add = Button(pexams_ab_top,
                         text="Προσθήκη Εγγραφής",
                         command=lambda: add_user(),
                         bg="floral white",
                         font=("Times New Roman (Times)", 14, "bold"),
                         height=1,
                         width=17)
    btn_grd_delete = Button(pexams_ab_top,
                            text="Διαγραφή Εγγραφής",
                            command=lambda: delete_user(),
                            bg="floral white",
                            font=("Times New Roman (Times)", 14, "bold"),
                            height=1,
                            width=17)

    #orismos listbox sos sos edw 8elei tkinterctrl
    user_list = Listbox(std_reg_create_abm_bot,
                        bg="floral white",
                        borderwidth=2,
                        highlightthickness=0,
                        selectmode='single')

    scrollh_usr = Scrollbar(std_reg_create_abm_bot,
                            orient="horizontal",
                            command=user_list.xview)
    scrollv_usr = Scrollbar(std_reg_create_abm_bot,
                            orient="vertical",
                            command=user_list.yview)
    std_reg_create_abm_bot.bind(
        "<Configure>",
        lambda e: user_list.configure(scrollregion=user_list.bbox("all")))
    user_list.configure(yscrollcommand=scrollv_usr.set,
                        xscrollcommand=scrollh_usr.set,
                        font=("Times New Roman (Times)", 16, "bold"))
    std_reg_create_abm_bot.bind("<MouseWheel>",
                                scrollv_usr)  #ΚΑΘΕΤΟ SCROLL ΜΕ ΡΟΔΑ ΠΟΝΤΙΚΙΟΥ

    def addU(grd_sname_ok, lesson_ok, grd_sgrade_ok):
        info_to_add = []
        info_to_add.append("Κωδικός_Υποψηφίου: " + grd_sname_ok)
        info_to_add.append("Μάθημα: " + lesson_ok)
        info_to_add.append("Βαθμός: " + grd_sgrade_ok)

        student_grade = ('  |  '.join(info_to_add))
        print(student_grade)
        #προσθήκη στοιχείων μαθητη listbox:
        user_list.insert(
            'end',
            student_grade)  #end στην τελευταια open θέση δλδ 0,1,2,3,...

    def add_user():

        grd_sname = grd_pexams_create_abtltl_r1.get(
            '1.0',
            'end-1c')  #αντι end-1c αν βαλεις σκετο end βαζει στο τέλος newline
        grd_sgrade = grd_pexams_create_abtltl_r3.get('1.0', 'end-1c')
        lesson = lesson_var.get()

        if (grd_sname != "" and grd_sgrade != "" and lesson != "-"):
            #delete inputs
            grd_pexams_create_abtltl_r1.delete('1.0', 'end')
            grd_pexams_create_abtltl_r3.delete('1.0', 'end')

            #αποθηκευση τελικών στοιχείων
            grd_sname_ok = grd_sname
            grd_sgrade_ok = grd_sgrade
            lesson_ok = lesson
            addU(grd_sname_ok, lesson_ok, grd_sgrade_ok)

        else:
            messagebox.showinfo(
                'Σφάλμα',
                'Παρακαλώ εισάγετε ορθά τα στοιχεία του μαθητή',
                icon='warning')

    def delete_user():
        student_grade_to_remove = [
            user_list.get(idx) for idx in user_list.curselection()
        ]
        w = 1
        while (w <= len(student_grade_to_remove)):
            idx_count = 0
            remove_temp = student_grade_to_remove[w - 1]
            while idx_count <= user_list.size():
                if (remove_temp == user_list.get(idx_count)):
                    print(idx_count, "idxc")
                    user_list.delete(idx_count)
                idx_count = idx_count + 1

            w = w + 1
        print("deleted a user")

    for script in curGrader.scriptList:
        addU(script.student, script.lesson, script.grade)

    def confirm_registry():
        spacer = '  |  '
        final_user_data = []
        if (user_list.size() >= 1):
            msg_conf_student_user = messagebox.askquestion(
                'Προσοχή!',
                'Είστε σίγουροι ότι θέλετε να κάνετε υποβολή δήλωσης με αυτά τα στοιχεία;',
                icon='warning')
            if msg_conf_student_user == 'yes':
                curGrader.deletelist()
                messagebox.showinfo('Oλοκλήρωση',
                                    'Η δήλωση καταχωρήθηκε με επιτυχία!')
                user_list.select_set(0, 'end')
                conf_user_list = [
                    user_list.get(idx) for idx in user_list.curselection()
                ]
                user_list.select_clear(0, 'end')
                #spilt τα στοιχεία για να παίρνουμε μεμονομένα το ονομα επωνυμο κλπ
                for stoixeio in conf_user_list:
                    user_data = stoixeio.split(
                        spacer
                    )  #καθε index σε αυτο το list περιέχει ονομα επώνυμο κλπ στοιχεία με trash strings
                    print("stoixeia xrhsth", user_data)
                    for sub_stoixeio in user_data:
                        #print("sub_stoixeio=",sub_stoixeio)
                        splitted_usr = sub_stoixeio.split(" ")
                        #print("g0",splitted_usr[0])
                        final_user_data.append(splitted_usr[1])
                        splitted_usr.clear()
                    sname_ok = final_user_data[0]
                    lesson_ok = final_user_data[1]
                    sgrade_ok = final_user_data[2]
                    curGrader.submitgrade(sname_ok, lesson_ok, sgrade_ok)
                    # sos sos zisis pros8ese se klaseis edw ta stoixeia
                    final_user_data.clear()
            else:
                messagebox.showinfo(
                    'Επιστροφή',
                    'Παρακαλώ συνεχίστε στην επεξεργασία της λίστας σας!')
                print("Ακύρωση από χρήστη της δήλωσης λίστας")
        else:
            messagebox.showinfo(
                'Σφάλμα',
                'Πρέπει να επιλέξετε προσθέσει τουλάχιστον ένα μαθητή  για την υποβολή της λίστας σας!'
            )

    def delete_list():

        del_msg = messagebox.askquestion(
            'Προσοχή!',
            'Είστε σίγουροι ότι θέλετε να διαγράψετε την τρέχουσα λίστα;\n Τα τρέχουσα στοιχεία της λίστας θα διαγραφτούν μόνιμα αν δεν τα έχετε υποβάλει!',
            icon='warning')
        if del_msg == 'yes':
            user_list.delete(0, 'end')
            curGrader.deletelist()
            print("deleted user")
        else:
            messagebox.showinfo(
                'Επιστροφή',
                'Παρακαλώ συνέχίστε με την συμπλήρωση της λίστας!',
                icon='warning')

    #packs εμφάνιση στοιχείων
    pexams_all.pack(side=TOP, fill=BOTH, expand=1)  #δεξιο μενου-αρχικη σελίδα
    pexams_all_top.pack(side=TOP, fill=X)

    pexams_all_bot.pack(side=TOP, expand=1, fill=BOTH, pady=30)
    pexams_ab_top.pack(side=TOP, fill=X, ipady=10)  #expand=1

    #αριστερη πλευρα με  στοιχεια εγγραφης
    grd_pexams_create_abt_top.pack(side=TOP, fill=X)
    pexams_abt_top1.pack(side=TOP, fill=X)
    pexams_abt_top2.pack(side=TOP, fill=X)
    pexams_abt_top3.pack(side=TOP, fill=X)

    std_reg_create_abtltl_l1.pack(side=LEFT, padx=10)  #ονομα
    std_reg_create_abtltl_l2.pack(side=LEFT, padx=10)  #επωνυμο
    std_reg_create_abtltl_l3.pack(side=LEFT, padx=10)  #e-mail

    grd_pexams_create_abtltl_r1.pack(side=LEFT)  #ονομα
    grd_pexams_create_abtltl_r2.pack(side=LEFT)  #επωνυμο
    grd_pexams_create_abtltl_r3.pack(side=LEFT)  #e-mail
    lesson_choice.pack()

    #κατω πλευρα με Λίστα
    std_reg_create_ab_mid.pack(side=TOP, fill=BOTH,
                               expand=1)  #,ipady=100)#, expand=1, fill=X)#BOTH
    std_reg_create_abm_top.pack(side=TOP, fill=X)
    std_reg_create_abmt_left.pack(side=LEFT, padx=10)
    std_reg_create_abm_bot.pack(side=TOP, expand=1, fill=BOTH)  #BOTH
    scrollv_usr.pack(side=RIGHT, fill=Y)
    scrollh_usr.pack(side=BOTTOM, fill=X)
    user_list.pack(side=BOTTOM, expand=1, fill=BOTH)  #BOTH
    #std_reg_create_abm_bot.pack(side=BOTTOM, expand=1, fill=BOTH)#BOTH

    #κατω πλευρα με buttons σελιδας
    grd_exams_create_ab_bot.pack(side=TOP, fill=X)

    #buttons MENU
    btn_grd_create_confirm.pack(side=RIGHT, padx=50)
    btn_grd_create_return.pack(side=RIGHT)
    btn_grd_add.pack(side=RIGHT, padx=50)
    btn_grd_delete.pack(side=RIGHT)
    btn_grd_delete_list.pack(side=LEFT, padx=50)

    #ΑΡΧΙΚΑ FRAMES ΕΜΦΑΝΙΣΗ
    raiseNdrop_frame(grader_Frame, none)
    raiseNdrop_frame(grader_menu_Frame, none)
    raiseNdrop_frame(grader_intro_Frame, none)

    main_window.mainloop(
    )  # ------------------------------Put always to end of frames
Beispiel #13
0
def calendar(actual_worker):
    """Funkcja tworząca panel do z rezerwacjami
        Argument:
            actual_worker(string)"""
    def show_reservation_on_calendar():
        """Funkcja która korzysta z funkcji zwracającej listę rezerwacji a następnie dodaje ją do kalendarza"""
        all_reservation = sql_query.get_all_reservation()
        for reservation in all_reservation:
            date_of_reservation = datetime.datetime.strptime(
                reservation[2], '%Y-%m-%d')
            cal.calevent_create(date_of_reservation,
                                text=str(reservation[4] + " " +
                                         reservation[5]))

    def book_table():
        """Funkcja służąca do dodanie konktretnej rezerwacji do systemu"""
        def accept_date():
            """Funkcja wyświetlająca poprawność dodania rezerwacji w konkretnym terminie"""
            table_id = sql_query.get_free_table(var.get())
            if table_id:
                date_of_reservation = cal.selection_get()
                cal.calevent_create(date_of_reservation,
                                    text=str(first_name.get() + " " +
                                             last_name.get()))
                id_worker = sql_query.get_id_actual_employee(actual_worker)
                messagebox.showinfo("Success", "You added a reservation")
                reservation_id = sql_query.add_reservation_to_database(
                    var.get(), date_of_reservation, id_worker[0][0],
                    first_name.get(), last_name.get())
                sql_query.add_reservation_to_table(reservation_id[0][0],
                                                   table_id[0][0])
                input_reservation.destroy()
            else:
                messagebox.showinfo("Not free table", "Not free table")

        # New window
        input_reservation = tk.Toplevel()

        # Label
        tk.Label(input_reservation, text="First Name").grid(row=0, column=0)
        tk.Label(input_reservation, text="Last Name").grid(row=1, column=0)

        # Entry
        first_name = tk.Entry(input_reservation)
        first_name.grid(row=0, column=1)
        last_name = tk.Entry(input_reservation)
        last_name.grid(row=1, column=1)

        var = tk.IntVar()  # Zmienna zapamiętująca pojemnośc wybranego stolika

        # Radio Buttons -  możliwość wyboru wielkości stolika
        one_person_table = tk.Radiobutton(input_reservation,
                                          text="One person table",
                                          variable=var,
                                          value=1)
        one_person_table.grid(row=2, column=0)
        two_person_table = tk.Radiobutton(input_reservation,
                                          text="Two person table",
                                          variable=var,
                                          value=2)
        two_person_table.grid(row=3, column=0)
        three_person_table = tk.Radiobutton(input_reservation,
                                            text="Three person table",
                                            variable=var,
                                            value=3)
        three_person_table.grid(row=4, column=0)
        four_person_table = tk.Radiobutton(input_reservation,
                                           text="Four person table",
                                           variable=var,
                                           value=4)
        four_person_table.grid(row=5, column=0)
        five_person_table = tk.Radiobutton(input_reservation,
                                           text="five person table",
                                           variable=var,
                                           value=5)
        five_person_table.grid(row=6, column=0)
        six_person_table = tk.Radiobutton(input_reservation,
                                          text="Six person table",
                                          variable=var,
                                          value=6)
        six_person_table.grid(row=7, column=0)

        tk.Button(input_reservation, text="Book",
                  command=accept_date).grid(row=2,
                                            column=1,
                                            rowspan=6,
                                            columnspan=2)
        input_reservation.mainloop()

    def cancel_table():
        """Funkcja służaca do usunięcia rezerwacji z systemu"""
        def cancel_reservation():
            """funkcja która usuwa zaznaczone rezerwacje z kalendarza"""
            index_of_reservation = list_of_reservation.curselection()
            list_of_reservation_to_delete = []
            if index_of_reservation:
                for index in index_of_reservation:
                    list_of_reservation_to_delete.append(
                        list_of_reservation.get(index))
                delete_window.destroy()
                messagebox.showinfo("Success", "Deleted reservation")

                sql_query.delete_reservation(list_of_reservation_to_delete)
                cal.calevent_remove(event_id[0])
            else:
                messagebox.showwarning("Error", "No mark reservation")

        try:
            event_id = cal.get_calevents(cal.selection_get())
            if event_id:
                # New window
                delete_window = tk.Toplevel()
                list_of_reservation = tk.Listbox(delete_window,
                                                 selectmode='multiple')
                tk.Button(delete_window,
                          text="Cancel",
                          command=cancel_reservation).grid(row=1, column=0)
                for counter, event in enumerate(event_id):
                    list_of_reservation.insert(
                        counter, cal.calevent_cget(event, "text"))

                list_of_reservation.grid(row=0, column=0)
                delete_window.mainloop()

            else:
                messagebox.showwarning("Empty", "This date is already free")
        except:
            messagebox.showwarning("Empty", "This date is already free")

    def print_reservation():
        """Funkcja służąca do wyświetlenia danej rezerwacji"""
        try:
            event_id = cal.get_calevents(cal.selection_get())
            if event_id:
                reservation_data = []
                for event in event_id:
                    reservation_data.append(cal.calevent_cget(event, "text"))
                messagebox.showinfo("Who's reservation?", reservation_data)
            else:
                messagebox.showwarning("Empty", "This date is free")
        except:
            messagebox.showwarning("Empty", "This date is free")

    # Window configuration
    root = tk.Tk()
    root.title("AGZ Restaurant")
    root.iconbitmap(r'..\..\resources\graphics\lg.ico')
    cal = Calendar(root,
                   selectmode='day',
                   selectbackground='red',
                   normalbackground='yellow')

    # Delete old reservation
    date = datetime.datetime.today().strftime('%Y-%m-%d')
    sql_query.delete_old_reservation(date)

    # Fill calendar
    show_reservation_on_calendar()

    cal.tag_config('reminder', background='red', foreground='yellow')

    cal.pack(fill="both", expand=True)
    # Buttons
    tk.Button(root, text="Book", command=book_table).pack()
    tk.Button(root, text="Cancel", command=cancel_table).pack()
    tk.Button(root, text="Print", command=print_reservation).pack()
    tk.Button(root, text="Exit", command=lambda: root.destroy()).pack()

    root.mainloop()