class CusCalendar():
    def __init__(self, root):
        self.top = tk.Toplevel(root)
        self.cal = Calendar(self.top,
                            font="Arial 14",
                            selectmode='day',
                            cursor="hand1",
                            year=2018,
                            month=2,
                            day=5)
        self.cal.pack(fill="both", expand=True)
        ttk.Button(self.top, width="14", text="선택",
                   command=self.select_date).pack(side="left", padx=5, pady=5)
        ttk.Button(self.top, width="14", text="창닫기",
                   command=self.destory_win).pack(side="left", padx=5, pady=5)
        # self.date = ''
        # self.top.grab_set()

    def select_date(self):
        self.date = self.cal.selection_get()
        self.top.destroy()

    def destory_win(self):
        self.date = ''
        self.top.destroy()

    pass
Exemple #2
0
    def abrir_calendario(self, event):
        def print_sel():
            f = (cal.selection_get()).weekday()
            if f < 5:
                print(cal.selection_get())
                event.widget.delete(0, tk.END)
                event.widget.insert(0, cal.selection_get())
                top.destroy()
            else:
                tk.messagebox.showerror(
                    parent=top,
                    message="Por favor elija un dia valido",
                    title="Seleccionar fecha")

        top = tk.Toplevel(self)
        now = datetime.datetime.now()
        day = now.day
        month = now.month
        year = now.year

        cal = Calendar(top,
                       font="Arial 14",
                       selectmode='day',
                       cursor="hand1",
                       year=year,
                       month=month,
                       day=day)
        cal.pack(fill="both", expand=True)
        ttk.Button(top, text="ok", command=print_sel).pack()
Exemple #3
0
    def test_calendar_buttons_functions(self):
        widget = Calendar(self.window)
        widget.pack()
        widget._prev_month()
        widget._next_month()
        widget._prev_year()
        widget._next_year()
        widget._remove_selection()
        widget.selection_set(format_date(date(2018, 12, 31), 'short'))
        self.assertEqual(widget.selection_get(), date(2018, 12, 31))
        with self.assertRaises(ValueError):
            widget.selection_set("ab")
        widget.selection_set(None)
        self.assertIsNone(widget.selection_get())
        widget.selection_set(date(2015, 12, 31))
        self.assertEqual(widget.selection_get(), date(2015, 12, 31))

        widget.config(selectmode='none')
        self.assertIsNone(widget.selection_get())
        l = ttk.Label(widget, text="12")
        widget._on_click(TestEvent(widget=l))
        self.assertIsNone(widget.selection_get())
        self.window.update()
        widget.config(selectmode='day')
        l = ttk.Label(widget, text="12")
        widget._on_click(TestEvent(widget=l))
        self.window.update()
        self.assertEqual(widget.selection_get(), date(2015, 12, 12))
        widget.config(state='disabled')
        l = ttk.Label(widget, text="14")
        widget._on_click(TestEvent(widget=l))
        self.window.update()
        self.assertEqual(widget.selection_get(), date(2015, 12, 12))
def PickDate():  # To pick a date for the task.
    def print_sel():
        global addedTask
        global tasks_list
        global task
        if addedTask == "":  # Solves a problem where the program would die if the user enters an empty string. Idk who'd do that, but yeah. Just in case.
            messagebox.showinfo(
                "Something bad happened :(", "Please enter your task first!"
            )  # Also to keep everything in order. (Task first, date second)
        else:
            print(task)
            this_date = cal.selection_get()
            task["tasks"].append(
                str(addedTask) + " --- Task Date: " + str(this_date)
            )  # Combines the task & date into a single string so it is easier to display.
            messagebox.showinfo(
                "Success!",
                "Set the date for the task! Don't forget to submit the task to your list!"
            )  # Just to give some feedback to the user.

    top = tk.Toplevel(root)
    cal = Calendar(top,
                   font="Arial 14",
                   selectmode='day',
                   cursor="hand1",
                   year=date.today().year,
                   month=date.today().month,
                   day=date.today().day)  # The date-picker system.
    cal.pack(fill="both", expand=True)  # Packing it.
    ttk.Button(top, text="Choose",
               command=print_sel).pack()  # The pick date button.
def viewCalendar():
    top = tk.Toplevel(root)

    today = datetime.date.today()

    mindate = datetime.date.today()
    #exception handling

    try:
        maxdate = datetime.date(mindate.year + 4, mindate.month, mindate.day)
    except:
        #then we were on a leap year on last day of Feb
        maxdate = datetime.date(mindate.year + 4, mindate.month + 1, 1)

    cal = Calendar(top,
                   font="Arial 14",
                   selectmode='day',
                   locale='en_US',
                   mindate=mindate,
                   maxdate=maxdate,
                   disabledforeground='red',
                   cursor="hand1",
                   year=mindate.year,
                   month=mindate.month,
                   day=mindate.day)
    cal.pack(fill="both", expand=True)
Exemple #6
0
    def test_calendar_virtual_events(self):
        widget = Calendar(self.window, year=2010, month=1, day=3)
        widget.pack()
        self.window.update()

        self.event_triggered = False

        def binding(event):
            self.event_triggered = True

        widget.bind('<<CalendarSelected>>', binding)
        widget._on_click(TestEvent(widget=widget._calendar[2][1]))
        self.window.update()
        self.assertTrue(self.event_triggered)

        widget.bind('<<CalendarMonthChanged>>', binding)
        self.event_triggered = False
        widget._l_month.invoke()
        self.window.update()
        self.assertTrue(self.event_triggered)
        self.event_triggered = False
        widget._r_month.invoke()
        self.window.update()
        self.assertTrue(self.event_triggered)
        self.event_triggered = False
        widget._l_year.invoke()
        self.window.update()
        self.assertTrue(self.event_triggered)
        self.event_triggered = False
        widget._r_year.invoke()
        self.window.update()
        self.assertTrue(self.event_triggered)
Exemple #7
0
def example1():
    def print_sel():
        print(cal.selection_get())
        cal.see(datetime.date(year=2016, month=2, day=5))

    top = tk.Toplevel(root)

    import datetime
    today = datetime.date.today()

    mindate = datetime.date(year=2018, month=1, day=21)
    maxdate = today + datetime.timedelta(days=5)
    print(mindate, maxdate)

    cal = Calendar(top,
                   font="Arial 14",
                   selectmode='day',
                   locale='en_US',
                   mindate=mindate,
                   maxdate=maxdate,
                   disabledforeground='red',
                   cursor="hand1",
                   year=2018,
                   month=2,
                   day=5)
    cal.pack(fill="both", expand=True)
    ttk.Button(top, text="ok", command=print_sel).pack()
Exemple #8
0
def datePicker():

    root = tk.Tk()

    def print_sel():
        sel = cal.selection_get()
        print(sel)
        #cal.see(datetime.date(year=2016, month=2, day=5))
        root.destroy()
        return sel

    top = tk.Toplevel(root)
    import datetime
    today = datetime.date.today()
    mindate = datetime.date(year=2018, month=1, day=21)
    maxdate = today + datetime.timedelta(days=1)
    #print(mindate, maxdate)
    print(today.year)
    print(today.month)
    print(today.day)
    cal = Calendar(top,
                   font="Arial 14",
                   selectmode='day',
                   locale='en_US',
                   mindate=mindate,
                   maxdate=maxdate,
                   disabledforeground='red',
                   cursor="hand1",
                   year=today.year,
                   month=today.month,
                   day=today.day)
    cal.pack(fill="both", expand=True)
    ttk.Button(top, text="ok", command=print_sel).pack()
    root.mainloop()
Exemple #9
0
    def pickDateCmd(self):

        def print_sel():
            #print(cal.selection_get())
            global expenseDate
            expenseDate = cal.selection_get()
            #print(expenseDate)

        win = tk.Toplevel(self)
        win.resizable(0,0)

        # Get full day
        today = date.strftime(date.today(), '%Y-%m-%d')
        # Strip year
        fyear = int(today[:4])
        # Strip month
        tmp_month = today[5:7]
        if tmp_month[0] == "0":
            fmonth = int(tmp_month[1])
        else:
            fmonth = int(tmp_month)
        # Strip day
        tmp_day = today[8:10]
        if tmp_day[0] == "0":
            fday = int(tmp_day[1])
        else:
            fday = int(tmp_day)

        cal = Calendar(win, font="Arial 7", selectmode='day', cursor="hand1", year=fyear, month=fmonth, day=fday)
        cal.pack(fill="both", expand=True)
        ttk.Button(win, text="ok", command=print_sel).pack()
Exemple #10
0
    def get_calendar(self):
        print('in get_calendar app')
        window = tk.Tk()
        cal = Calendar(window)
        year = time.localtime(time.time())[0]
        month = time.localtime(time.time())[1]
        date = time.localtime(time.time())[2]

        if month == 12:
            cal.config(mindate=datetime.date(year, month, date),
                       maxdate=datetime.date(year, 1, date))
        elif month == 1 and date > 28:
            cal.config(mindate=datetime.date(year, month, date),
                       maxdate=datetime.date(year, month + 1, 28))
        else:
            try:
                cal.config(mindate=datetime.date(year, month, date),
                           maxdate=datetime.date(year, month + 1, date))
            except ValueError:
                cal.config(mindate=datetime.date(year, month, date),
                           maxdate=datetime.date(year, month + 1, date - 1))

        cal.config(showweeknumbers=False,
                   disabledbackground='red',
                   disabledforeground='blue',
                   disabledselectbackground='pink',
                   disabledselectforeground='purple',
                   disableddaybackground='red')
        cal.pack()

        select_button = tk.Button(cal,
                                  text='Select Date',
                                  command=lambda: print(cal.selection_get()))
        select_button.pack()
        cal.mainloop()
Exemple #11
0
class HebrewSchedulerGUI(object):
    def __init__(self, input_handler):
        self.input_handler = input_handler
        self.root = tk.Tk(className=' HebrewScheduler')
        s = ttk.Style(self.root)
        s.theme_use('clam')
        tk.Label(self.root, text="Summary").grid(row=0)
        tk.Label(self.root, text="Description").grid(row=1)
        tk.Label(self.root, text="Location").grid(row=2)
        tk.Label(self.root, text="Number of years").grid(row=3)
        tk.Label(self.root, text="Color").grid(row=4)
        ttk.Button(self.root, text='Calendar',
                   command=self.open_calendar).grid(row=5)

        self.summary = tk.Entry(self.root)
        self.desc = tk.Entry(self.root)
        self.loc = tk.Entry(self.root)
        self.num_of_years = tk.Entry(self.root)

        self.color_listbox = tk.Listbox(self.root,
                                        selectmode=tk.SINGLE,
                                        height=len(configuration.COLOR_CODES))
        for i, (c_n, c) in enumerate(
                zip(configuration.COLOR_CODES_LEGEND.keys(),
                    configuration.COLOR_CODES)):
            self.color_listbox.insert("end", c_n)
            self.color_listbox.itemconfig(i, {'bg': c})

        self.summary.grid(row=0, column=1)
        self.desc.grid(row=1, column=1)
        self.loc.grid(row=2, column=1)
        self.num_of_years.grid(row=3, column=1)
        self.color_listbox.grid(row=4, column=1)

        self.top = None
        self.cal = None

    def open_calendar(self):
        self.top = tk.Toplevel(self.root)
        ttk.Label(self.top, text='Choose date').pack(padx=10, pady=10)
        self.cal = Calendar(self.top,
                            font="Arial 14",
                            selectmode='day',
                            cursor="hand1")
        self.cal.pack(fill="both", expand=True)
        ttk.Button(self.top, text="ok", command=self.process_inputs).pack()

    def process_inputs(self):
        picked_vals = (self.cal.selection_get(), self.summary.get(),
                       self.desc.get(), self.loc.get(),
                       configuration.COLOR_CODES_LEGEND[
                           self.color_listbox.selection_get()],
                       int(self.num_of_years.get()))
        print(picked_vals)
        self.top.destroy()
        self.root.destroy()
        self.input_handler(*picked_vals)

    def run_gui(self):
        self.root.mainloop()
Exemple #12
0
    def _orderDateFun(self, ver):
        def print_sel():
            if ver == 0:
                self._orderDate = cal.selection_get()
                self.DateOrderLabel.config(text=str(self._orderDate.day) +
                                           '-' + str(self._orderDate.month) +
                                           '-' + str(self._orderDate.year))
            elif ver == 1:
                self._collectDate = cal.selection_get()
                self.DateCollectLabel.config(text=str(self._collectDate.day) +
                                             '-' +
                                             str(self._collectDate.month) +
                                             '-' + str(self._collectDate.year))
            top.destroy()

        top = Toplevel(self.root)
        today = datetime.date.today()

        cal = Calendar(top,
                       font="Arial 14",
                       selectmode='day',
                       disabledforeground='red',
                       cursor="hand1",
                       year=today.year,
                       month=today.month,
                       day=today.day)
        cal.pack(fill="both", expand=True)
        Button(top, text="zatwierdź", command=print_sel).pack()
Exemple #13
0
        def dateSelector():
                def print_sel():
                    global date_selected
                    dateselected = cal.selection_get()
                    date_selected = dateselected
                    print(dateselected)
                    labelstatus = ttk.Label(top, text="Close this window.",width=20,font=("bold", 12)).pack()
                    label_3 = ttk.Label(labelframe_2, text=dateselected,width=30,font=("bold", 10))
                    label_3.grid(row=4,column = 6, pady=4)
            
                    top.destroy()
                    return dateselected

                top = Toplevel(ingoal)
     
                import datetime
                today = datetime.date.today()

                mindate = datetime.date(year=2000, month=5, day=1)
                maxdate = today + datetime.timedelta(days=100)
        

                cal = Calendar(top, font="Arial 14", selectmode='day', locale='en_US',
                            mindate=mindate, maxdate=maxdate, disabledforeground='red',
                            cursor="hand1", year=2020, month=5, day=5)
                cal.pack(fill="both", expand=True)
                incomebtn2 = ttk.Button(top, text="Select", command=print_sel).pack() 
Exemple #14
0
    def tkinterCalendar(self, event):
        # respuesta = tk.messagebox.askquestion(parent=self, message="¿Cuenta con la fecha especifica? \n\n Conteste NO para guardar como PENDIENTE", title="Agregar fecha",icon = 'info')
        # if respuesta == 'yes':
            def print_sel():
                f = (cal.selection_get()).weekday()
                if f < 5:
                    event.widget.config(state="normal")
                    self.updateDate(cal.selection_get())
                    event.widget.delete(0, tk.END)
                    event.widget.insert(0, cal.selection_get())
                    event.widget.config(state="disabled")
                    top.destroy()
                else:
                    tk.messagebox.showerror(parent=top, message="Por favor elija un dia valido", title="Seleccionar fecha")

            def print_pendiente():
                event.widget.config(state="normal")
                self.updateDate(cal.selection_get())
                event.widget.delete(0, tk.END)
                event.widget.insert(0, 'Pediente')
                event.widget.config(state="disabled")
                top.destroy()
        
            top = tk.Toplevel(self)
            cal = Calendar(top,
                    font="Arial 14", selectmode='day',
                    cursor="hand1", year=self.anio, month=self.mes, day=self.dia)
            cal.pack(fill="both", expand=True)
            ttk.Button(top, text="ok", command=print_sel).pack(expand=True, fill=tk.BOTH, ipadx=10, ipady=10, pady=2)   
            ttk.Button(top, text="Guardar como pendiente", command= print_pendiente).pack(expand=True, fill=tk.BOTH, ipadx=10, ipady=10, pady=2)   
Exemple #15
0
def calendar():
    def scrapy_start():
        start=cal.selection_get()
        cal.see(datetime.date(year=2020, month=11, day=1))
        string_date.append(start)


    def scrapy_end():
        end=cal.selection_get()
        cal.see(datetime.date(year=2020, month=11, day=1))
        string_date.append(end)


    top = tk.Toplevel(root)

    import datetime
    today = datetime.date.today()

    mindate = datetime.date(year=2017, month=1, day=1)
    maxdate = today + datetime.timedelta(days=5)

    cal = Calendar(top, font="Arial 14", selectmode='day', locale='en_US',
                   mindate=mindate, maxdate=maxdate, disabledforeground='red',
                   cursor="hand1", year=maxdate.year, month=maxdate.month, day=maxdate.day)
    cal.pack(fill="both", expand=True)

    ttk.Button(top, text="Set Start", command=scrapy_start).pack()
    ttk.Button(top, text="Set End", command=scrapy_end).pack()
class Cal:
    def __init__(self, root):

        self.date = ''

        self.top = tk.Toplevel(root)
        self.top.title('Select Start Date')

        self.cal = Calendar(
            self.top,
            font='Arial 14',
            selectmode='day',
            cursor='hand1',
        )
        self.cal.pack(fill='both', expand=True)
        tk.Button(self.top, text='OK', command=self.set_date).pack()
        tk.Button(self.top, text='Close', command=self.quit).pack()

    def set_date(self):
        self.date = self.cal.selection_get()
        self.top.destroy()

    def get_date(self):
        return self.date

    def quit(self):
        self.top.destroy()
Exemple #17
0
    def test_calendar_selection(self):
        widget = Calendar(self.window,
                          month=3,
                          year=2011,
                          day=10,
                          maxdate=date(2013, 1, 1),
                          mindate=date(2010, 1, 1))
        widget.pack()
        self.assertEqual(widget.selection_get(), date(2011, 3, 10))

        widget.selection_set(date(2012, 4, 11))
        self.assertEqual(widget.selection_get(), date(2012, 4, 11))
        self.assertEqual(widget._date, date(2012, 4, 1))
        widget.selection_set(datetime(2012, 5, 11))
        self.assertEqual(widget.selection_get(), date(2012, 5, 11))
        self.assertNotIsInstance(widget.selection_get(), datetime)
        self.assertIsInstance(widget.selection_get(), date)
        widget.selection_set(datetime(2012, 5, 21).strftime('%x'))
        self.assertEqual(widget.selection_get(), date(2012, 5, 21))
        self.assertNotIsInstance(widget.selection_get(), datetime)
        self.assertIsInstance(widget.selection_get(), date)

        widget.selection_set(date(2018, 4, 11))
        self.assertEqual(widget.selection_get(), date(2013, 1, 1))
        widget.selection_set(date(2001, 4, 11))
        self.assertEqual(widget.selection_get(), date(2010, 1, 1))
        widget.selection_clear()
        self.assertIsNone(widget.selection_get())
        # test Swedish locale
        widget.destroy()
        widget = Calendar(self.window, locale='sv_SE')
        widget.pack()
        widget.selection_set(format_date(date(2012, 4, 11), 'short', 'sv_SE'))
Exemple #18
0
    def example1():
        def print_sel():
            print(cal.selection_get())
            var.append(cal.selection_get())
            # cal.see(datetime.date(year=2016, month=2, day=5))
            var1 = str(var[0])
            l4.config(text=var1)
            top.destroy()

        top = Toplevel(donate)

        import datetime
        today = datetime.date.today()

        mindate = today
        maxdate = today + datetime.timedelta(days=5)

        cal = Calendar(top,
                       font="Arial 14",
                       selectmode='day',
                       locale='en_US',
                       mindate=mindate,
                       maxdate=maxdate,
                       disabledforeground='red',
                       cursor="hand1",
                       year=2018,
                       month=2,
                       day=5)
        cal.pack(fill="both", expand=True)
        ttk.Button(top, text="ok", command=print_sel).pack()
Exemple #19
0
class CalendarGUI:
    is_open = False
    #새로 생성되는 클래스의 인자에 MainGUI을 넣어서 MainGUI 객체를 가져오게 함 그렇게 되면 MainGUI에 있는 변수들을 수정 가능

    def __init__(self, MainGui, selectCommand=None):

        if CalendarGUI.is_open:
            return
        CalendarGUI.is_open = True
        self.main_gui = MainGui
        self.gui = Toplevel(self.main_gui.gui)
        self.gui.title("Calendar")
        now = datetime.datetime.now()
        self.cal = Calendar(self.gui, selectmode='day', year=now.year, month=now.month, day=now.day)
        self.cal.pack(pady=10)

        Button(self.gui, text="날짜 선택", command=lambda cmd=selectCommand: self.SetTravelDate(command=cmd)).pack()

        self.gui.protocol("WM_DELETE_WINDOW", self.Closing)

    #현재는 시간이 20, 30으로 고정되어 있는데 이 부분은 xml 데이터 파일의 정보를 가져와서 설정해 주어야함.
    def SetTravelDate(self, command=None):
        date = self.cal.selection_get()

        if command is not None:
            command(date)

    def Closing(self):
        CalendarGUI.is_open = False
        self.gui.destroy()
Exemple #20
0
    def datepick(ob):
        if str(ob.var2.get()) == '0':
            ob.dateLabel.configure(text='')
        if str(ob.var2.get()) == '1':

            def print_sel():
                ob.requestdate = str(cal.selection_get())
                ob.dateLabel.configure(text=ob.requestdate)
                root.destroy()

            root = Tk()
            root.title("Calendar")
            #s = ttk.Style(root)
            #s.theme_use('clam')
            top = tk.Toplevel(root)

            cal = Calendar(top,
                           font="Arial 14",
                           selectmode='day',
                           cursor="hand1",
                           year=2019,
                           month=4,
                           day=15)
            cal.pack(fill="both", expand=True)
            ttk.Button(top, text="ok", command=print_sel).pack()
            root.mainloop()
Exemple #21
0
    def dateFunction(self):
        # Create Object
        rootNew = Tk()

        # Set geometry
        rootNew.geometry("300x300")

        rootNew.title("Calendar")

        # Add Calender
        cal = Calendar(
            rootNew,
            foreground="black",
            selectforeground="red",
            selectmode="day",
            year=2021,
            month=5,
            day=13,
        )

        cal.pack(pady=20)

        def grad_date():
            self.defaultDob.set(str(cal.get_date()))
            rootNew.destroy()

        # Add Button and Label
        Button(rootNew, text="Get Date", command=grad_date).pack(pady=20)

        date = Label(rootNew, text="")
        date.pack(pady=20)
    def example1():
        '''def doo():
            cr = sheet.max_row
            sheet.cell(row=cr + 1, column=1).value = w.get() 
            sheet.cell(row=cr + 1, column=2).value = y.get() 
            sheet.cell(row=cr + 1, column=3).value = R
            sheet.cell(row=cr + 1, column=4).value = cal.selection_get()
            sheet.cell(row=cr + 1, column=5).value = t.get()
            fb.save('Database1.xlsx')
            main = tk.Tk() 
            ourMessage ='Your ride will arrive in minute'
            messageVar = Message(main, text = ourMessage) 
            messageVar.pack( ) 
            main.mainloop( ) '''
        def fu():
            global fu2
            fu2 = cal.selection_get()

        top = tk.Toplevel(root)

        cal = Calendar(top,
                       font="Arial 14",
                       selectmode='day',
                       cursor="hand1",
                       year=2019,
                       month=11,
                       day=5)
        cal.pack(fill="both", expand=True)
        ttk.Button(top, text="ok", command=fu).pack()
Exemple #23
0
	def __init__(self, parent, controller):
		Frame.__init__(self, parent)
		self.controller = controller
		self.parent = parent

		global back_img, create_img

		back_img = ImageTk.PhotoImage(Image.open("assets/back.png"))
		back_btn = Button(self, text="Back to Menu", image=back_img, anchor="center", compound="left", bd=0, padx=-10, command=lambda: controller.show_frame("Homescreen"), cursor="hand1")
		back_btn.pack(pady=(0,20))

		image = Label(self, image=diary_img, text="Diary", compound="left", padx=10, font=('Arial', 16))
		image.pack()

		diary_help = Label(self, text="Use the diary to store your thoughts or narrate how your day went.\nDon't worry, Andy will never reveal your secrets :]")
		diary_help.pack(pady=10)

		create_img = ImageTk.PhotoImage(Image.open("assets/create.png").resize((45, 45), Image.ANTIALIAS))
		create_btn = Button(self, text="Create new entry", image=create_img, anchor="center", compound="left", bd=0, command=lambda: controller.show_frame("DiaryCreateFrame"), cursor="hand1")
		create_btn.pack(pady=(10, 20))

		cal = Calendar(self, firstweekday="sunday", showweeknumbers=False, borderwidth=0, date_pattern="yyyy-mm-dd")
		cal.pack(padx=20, pady=10)
		check_entries_btn = Button(self, text="Check Entries for the selected date", bd=0, command=lambda: self.check_records(cal.get_date()), cursor="hand1")
		check_entries_btn.pack(padx=10, pady=10)
    def enterDate():
        '''Let user set the date'''

        top = Toplevel(window_2)
        topText = 'Choose Date'
        top.title(topText)
        top.geometry('300x300+30+30')
        chooseDateText = 'Please click to choose a date'
        chooseDateLabel = Label(top, padx=10, pady=10, text=chooseDateText)
        chooseDateLabel.pack()

        mindate = currentDatePara
        maxdate = mindate + datetime.timedelta(days=365)

        cal = Calendar(top, mindate=mindate, maxdate=maxdate, width=12, background='darkblue',
                        foreground='white', borderwidth=2)
        cal.pack(padx=10, pady=10)

        def getUserDate():
            global userDate
            userDate = cal.selection_get()
            dateLabel['text']=userDate  #update userDate in the dateLabel of window_2
            top.destroy()
        
            # end of getUserDate()

        okDateButton = Button(top, padx=10, pady=5, bg='purple', fg='white', text='OK', command=getUserDate)
        okDateButton.pack()
Exemple #25
0
class CalenderUI:
    """Calendar interface. Example taken from the official documentation of tkcalendar."""

    def __init__(self, cal_root):
        """Construct widget with master as parent widget"""
        self.top = tk.Toplevel(cal_root)

        self.cal = Calendar(self.top, font="Arial 14", selectmode='day',
                            cursor="hand1", year=int(settings.year), month=int(settings.month), day=int(settings.day))
        self.cal.pack(fill="both", expand=True)
        ttk.Button(self.top, text="ok", command=self.print_sel).pack()
        ttk.Button(self.top, text="exit", command=self.quit1).pack()

        self.date = ''

        self.top.grab_set()

    def print_sel(self):
        """Callback function saving the date to a variable."""
        self.date = self.cal.selection_get()

    def quit1(self):
        """Callback function that saves the date to a variable and exits the calendar window"""
        self.date = self.cal.selection_get()
        self.top.destroy()
Exemple #26
0
def date():
    def print_sel():
        global cal, DATE
        DATE = calen.selection_get()
        if DATE != '':
            cal = Label(root, text=DATE, bg='red', fg='black')
            cal.place(x=300, y=280)
            top.destroy()

    top = tk.Toplevel(root)
    top.geometry('300x300+650+400')

    import datetime
    today = datetime.date.today()

    #mindate = today
    mindate = datetime.date(year=2018, month=1, day=1)
    #maxdate = today + datetime.timedelta(days=5)
    maxdate = datetime.date(year=2030, month=1, day=1)

    #print(mindate, maxdate)

    calen = Calendar(top,
                     font="Arial 10",
                     selectmode='day',
                     locale='en_US',
                     mindate=mindate,
                     maxdate=maxdate,
                     disabledforeground='red',
                     cursor="hand1",
                     year=2020,
                     month=1,
                     day=1)
    calen.pack(fill="both", expand=True)
    ttk.Button(top, text="ok", command=print_sel).pack()
Exemple #27
0
def end_date_selector():

    # This function retrieves the user's selected end date and puts it in the textbox.
    def retrieve_end_date():
        # Retrieves value of StringVar
        global end_date_value
        end_date_value = end_cal.selection_get()

        # Before we insert the chosen date into the textbox, we need to erase whatever
        # was there before.
        end_textbox.delete(1.0, END)

        # Inserts the chosen date into the textbox.
        end_textbox.insert(END, end_date_value)

        # Since the OK Button has been clicked, the user now expects the calendar window
        # to close itself.
        end_top.destroy()

    # The toplevel widget functions like a frame to hold our calendar.
    end_top = Toplevel(window)

    end_cal = Calendar(end_top,
                       font="Arial 10",
                       selectmode='day',
                       cursor="hand1",
                       year=datetime.now().year,
                       month=datetime.now().month,
                       day=datetime.now().day)
    end_cal.pack(fill="both", expand=True)
    Button(end_top, text="Done", command=retrieve_end_date).pack()
def Calendrier():
    def print_sel():
        #bouton_ok.pack_forget()
        valeur_cal = cal.selection_get()
        print("la date est", cal.selection_get())
        label = Label(fenetre,
                      text=cal.selection_get().strftime('%d/%m/%Y'),
                      bg="grey").pack(padx=30, pady=10)  # Label

        cal.destroy()

    def recupere_date():
        return cal.selection_get()

    cal = Calendar(fenetre,
                   font="Arial 14",
                   selectmode='day',
                   locale='en_US',
                   cursor="hand1",
                   year=2018,
                   month=2,
                   day=5)
    cal.pack(fill="both", expand=True)
    bouton_ok = ttk.Button(fenetre, text="ok", command=print_sel).pack()
    bouton_ok.bind("<Button-1>", print_sel)  # clic gauche
    def calendarWindow(self):
        def selecting_start_date():
            if cal.selection_get().weekday() == 0:
                db.startdate = cal.selection_get()
                self.controller.show_frame(0)
            else:
                top2 = tk.Toplevel(self)
                label5 = ttk.Label(top2, text="Please select a Monday")
                label5.pack()

        top = tk.Toplevel(self)
        style = ttk.Style(top)
        style.theme_use('clam')
        cal = Calendar(top,
                       font="Arial 14",
                       selectmode='day',
                       cursor="hand2",
                       year=2020,
                       month=2,
                       day=5,
                       background="black",
                       disabledbackground="black",
                       bordercolor="black",
                       headersbackground="black",
                       normalbackground="black",
                       foreground='white',
                       normalforeground='white',
                       headersforeground='white')
        cal.pack(fill="both", expand=True)
        ttk.Button(top, text="confirm", command=selecting_start_date).pack()
Exemple #30
0
    def calendar(self):
        """ So far only displays calendar."""
        def print_sel():
            print(cal.selection_get())
            cal.see(datetime.date(year=2021, month=2, day=2))

        top = self.root

        today = datetime.date.today()

        maxdate = datetime.date(year=2022, month=1, day=1)
        mindate = today + datetime.timedelta(days=5)
        print(mindate, maxdate)

        cal = Calendar(top,
                       font="Arial 14",
                       selectmode='day',
                       locale='en_US',
                       mindate=mindate,
                       maxdate=maxdate,
                       disabledforeground='red',
                       cursor="hand1",
                       year=2018,
                       month=2,
                       day=5)
        cal.pack()
        ttk.Button(top, text="ok", command=print_sel).pack()