Exemple #1
0
    def __init__(self, parent_view):
        super().__init__(parent_view)
        self.parent = parent_view
        self.title('AU/krank Eintragen')
        startdatum_label = tk.Label(self, text="von")
        self.startdatum_input = Calendar(self, date_pattern='MM/dd/yyyy')
        enddatum_label = tk.Label(self, text="bis")
        self.enddatum_input = Calendar(self, date_pattern='MM/dd/yyyy')

        self.save_button = tk.Button(self, text="Daten speichern")
        self.exit_button = tk.Button(self,
                                     text="Abbrechen",
                                     command=self.destroy)
        self.saveandnew_button = tk.Button(self,
                                           text="Daten speichern und neu")

        # ins Fenster packen
        startdatum_label.grid(row=1, column=0, sticky=tk.NW)
        self.startdatum_input.grid(row=1, column=1, columnspan=2, sticky=tk.NW)
        enddatum_label.grid(row=1, column=3, sticky=tk.NW)
        self.enddatum_input.grid(row=1, column=4, sticky=tk.NW)

        self.save_button.grid(row=15, column=0, sticky=tk.NW)
        self.exit_button.grid(row=15, column=1, sticky=tk.NW)
        self.saveandnew_button.grid(row=15, column=2, sticky=tk.NW)
Exemple #2
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'))
  def datesInput():
    today = datetime.today()
    todayList = [int(today.strftime('%Y')), int(today.strftime('%m')), int(today.strftime('%d'))]

    # Checking if dates make sense
    def dateValidate():
      departDate = datetime.strptime(toCal.get_date(), '%m/%d/%y')
      returnDate = datetime.strptime(fromCal.get_date(), '%m/%d/%y')

      if departDate > returnDate:
        messagebox.showerror(title="Date Validation Error", message="The return date must be after the departure date.")
        calRoot.lift()
      elif (departDate < today) or (returnDate < today):
        messagebox.showerror(title="Date Validation Error", message="The selected dates cannot be in the past!")
        calRoot.lift()
      elif departDate <= returnDate:
        schedule.setSearchDate(departDate.date())
        schedule.setReturnDate(returnDate.date())
        calRoot.destroy()
      else:
        pass
    
    def onClose():
      calRoot.destroy()
      return False

    ## Window Creation
    calRoot = Tk()
    calRoot.title("Southwest Flight Schedules")
    calCalFrame = Frame(calRoot)
    calTitleFrame = Frame(calRoot)
    calButtonFrame = Frame(calRoot)
    gridConfigure(calRoot, [0,1,2], [0])

    ## Title
    calTitleFrame.grid(row=0,column=0,sticky='ew')
    gridConfigure(calTitleFrame, [0,1], [0,1])
    Label(calTitleFrame, text="Date Selection", font=('', 18, 'bold')).grid(row=0, column=0, pady=4, columnspan=2)
    Label(calTitleFrame, text="Departing").grid(row=1, column=0, padx=4, columnspan=1, sticky='ew')
    Label(calTitleFrame, text="Returning").grid(row=1, column=1, padx=4, columnspan=1, sticky='ew')

    ## Two Calendars
    calCalFrame.grid(row=1,column=0,sticky='ew')
    gridConfigure(calCalFrame, [0], [0,1])
    toCal = Calendar(calCalFrame, selectmode = 'day', year = todayList[0], month = todayList[1], day = todayList[2])
    toCal.grid(row=0, column=0, padx=4)
    fromCal = Calendar(calCalFrame, selectmode = 'day', year = todayList[0], month = todayList[1], day = todayList[2]+1)
    fromCal.grid(row=0, column=1, padx=4)

    ## Submit Button
    calButtonFrame.grid(row=2, column=0, sticky='ew')
    gridConfigure(calButtonFrame, [0], [0])
    Button(calButtonFrame, text="Submit", command=dateValidate).grid(row=2,column=0,pady=4, columnspan=1)

    calRoot.lift()
    calRoot.protocol("WM_WINDOW_DESTROY", onClose)
    calRoot.mainloop()
    del calRoot
    gc.collect()
Exemple #4
0
def getWeight():
	windowWeight = Toplevel(window)
	windowWeight.geometry("700x700")
	windowWeight['background']='#B7FCF8'

	lblWeightTitle = Label(windowWeight, text="Weight", bg='#B7FCF8', font=("Arial Bold", 30))
	lblWeightTitle.place(relx=0.5, rely=0.1, anchor=CENTER)
	
	lblWeight = Label(windowWeight, text="", bg='#B7FCF8', fg='BLUE', font=("Arial Bold", 20))
	lblWeight.place(relx=0.5, rely=0.4, anchor=CENTER)

	Weight = StringVar(windowWeight)
	Weight.set("Choose day")

	w = OptionMenu(windowWeight, Weight, "Yesterday", "Today", "Custom")
	w.config(width=40, height=3)
	w.config(bg = "#E7C7FC")
	w.config(font=12)
	w.config(bd=5)
	w.place(relx = 0.2, rely = 0.2)

	def customDate():
		date1 = cal1.get_date().split("/")
		dateS1 = int(date1[1])
		date2 = cal2.get_date().split("/")
		dateS2 = int(date2[1])
		dateWeight = []
		for x in range(dateS1, dateS2):
			dateWeight.append(dataDf.at[x + 2, 'weight'])
		plt.xlabel('Time')
		plt.ylabel('Weight')
		plt.title('Weight')
		plt.plot(range(dateS1, dateS2), dateWeight)
		plt.show()

	def callback(*args):
		if Weight.get() == 'Today':
			lblWeight.config(text="Your weight is " + str(dataDf.at[0, 'weight']))
		if Weight.get() == 'Yesterday':
			lblWeight.config(text="Your weight was " + str(dataDf.at[1, 'weight']))
		if Weight.get() == 'Custom':
			cal1.place(relx=0.15, rely=0.45)
			cal2.place(relx=0.55, rely=0.45)
			buttonCalendar.place(relx=0.32, rely = 0.8)
	Weight.trace("w", callback)

	cal1 = Calendar(windowWeight, selectmode="day", year=2020)
	cal2 = Calendar(windowWeight, selectmode="day", year=2020)
	buttonCalendar = Button(windowWeight, text = "Check Weight", bg='#E7C7FC', command=customDate)
	buttonCalendar.config(height=3, width=30)
Exemple #5
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 #6
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 #7
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 #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 __init__(self, master, label):
        self.master = master
        self.frame = tk.Frame(self.master)
        self.frame.config(bg="white")
        self.cal = Calendar(self.frame,
                            select="day",
                            year=2021,
                            month=2,
                            day=9)
        self.cal.grid(row=0, column=0, padx=20, pady=20)
        self.time = App(self.frame)
        self.time.grid(row=1, column=0, padx=10, pady=10)
        self.label = label

        # -----------Buttons-----------

        # Select datetime button
        self.pickDateButton = tk.Button(self.frame,
                                        text="Seleccionar fecha y hora",
                                        command=self.grab_date)
        self.pickDateButton.grid(row=2, column=0, pady=20, padx=20)

        # Exit button
        self.quitButton = tk.Button(self.frame,
                                    text='Salir',
                                    width=25,
                                    command=self.close_windows)
        self.quitButton.grid(row=3, column=0, padx=20, pady=20)

        self.frame.pack()
Exemple #10
0
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.
Exemple #11
0
    def odczytaj(self):
        self.newWindow1 = tk.Toplevel(self.master)
        self.ramka1 = tk.Frame(self.newWindow1, bg='blue', bd=2)
        self.ramka1.grid()
        self.szukajd = tk.Label(
            self.ramka1, text="SZUKAJ PO DACIE", font=('Calibri Light', 15))
        self.szukajd.grid(column=0, row=0)
        self.szukajde = Calendar(self.ramka1)
        self.szukajde.grid(column=0, row=2)
        self.szukajdb = Button(self.ramka1, text="SZUKAJ!", bg="slategray2", font=('Calibri Light', 15), command=self.wyniki2)
        self.szukajdb.grid(column=0, row=4)
        self.separator = Frame(self.newWindow1, height=3, width=300, bg="slategray4")
        self.separator.grid(column=0, row=5)
        self.szukajt = tk.Label(
            self.newWindow1, text="SZUKAJ PO TYTULE", font=('Calibri Light', 15))
        self.szukajt.grid(column=0, row=5)
        self.szukajte = tk.Entry(self.newWindow1, width=40)
        self.szukajte.grid(column=0, row=7)
        self.szukajtb = Button(
            self.newWindow1, text="SZUKAJ!", bg="slategray2", font=('Calibri Light', 15), command=self.wyniki)
        self.szukajtb.grid(column=0, row=9)

        self.newWindow1.grid_rowconfigure(3, minsize=10)
        self.newWindow1.grid_rowconfigure(5, minsize=30)
        self.newWindow1.grid_rowconfigure(8, minsize=30)
        self.newWindow1.grid_rowconfigure(10, minsize=30)
        self.szukajte.grid(column=0, row=6)
        #self.szukajtb = Button(
        #    self.newWindow1, text="Szukaj!", command=lambda: self.searchDatabase(self.szukajte.get()))
        self.szukajtb = Button(
            self.newWindow1, text="Szukaj!", command=self.wyniki)
        self.szukajtb.grid(column=0, row=7)
Exemple #12
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 #13
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 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()
    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 #16
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 #17
0
    def create_widgets(self):
        self.selected_date = StringVar()
        cal = Calendar(self,
                       selectmode='day',
                       locale='en_US',
                       date_pattern="yyyy-mm-dd",
                       maxdate=datetime.date.today(),
                       disabledforeground='red',
                       textvariable=self.selected_date)
        cal.grid(column=0, row=0, columnspan=2, sticky='nesw')

        self.shift = StringVar()
        ttk.Radiobutton(self, text='day', variable=self.shift,
                        value='day').grid(column=0, row=2, sticky='e')
        ttk.Radiobutton(self, text='night', variable=self.shift,
                        value='night').grid(column=1, row=2, sticky='w')

        self.uid = StringVar()
        uid_entry = Entry(self, textvariable=self.uid)
        uid_entry.grid(column=1, row=3, sticky=(W, E))
        uid_entry.focus()

        self.pw = StringVar()
        Entry(self, textvariable=self.pw, show='*').grid(column=1,
                                                         row=4,
                                                         sticky=(W, E))

        ttk.Button(self, text='Submit', command=self.submit).grid(column=0,
                                                                  row=5,
                                                                  sticky='we')
        ttk.Button(self, text='Quit', command=self.stop).grid(column=1,
                                                              row=5,
                                                              sticky='we')
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()
    def __init__(self):
        """Interface build."""
        UI(
            None,
            title='MY GUI PLAYGROUND',
            banner='MY GUI PLAYGROUND',
            win_color='#003366',
            window_width=800,
            window_height=800,
        )

        # self.menu_button()
        # self.a_message()

        # self.panedWindow()
        # self.toplevel()

        # self.m_button()
        # self.my_notebook()

        # TradeProgressWin('CDEV')

        jd_cal = Calendar(UI.w)
        jd_cal.grid(row=1, column=0, sticky=W)

        mainloop()
Exemple #20
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 #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)
Exemple #22
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 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 __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 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 #26
0
        def pop_up_cal():
            # make a window pop up with a calander, return to the sender the date picked
            win = tk.Toplevel()
            win.wm_title('Choose Calander')

            start_date_cal = Calendar(win)
            start_date_cal.grid()
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()
Exemple #28
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()
    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 dob_picker(self):
     today = datetime.date.today()
     self.dob_date_picker = Tk()
     self.dob_date_picker.iconbitmap('giocomo_lab.ico')
     self.dob_date_picker.wm_title("Select Date")
     mindate = datetime.date(year=2015, month=1, day=1)
     maxdate = today + datetime.timedelta(days=1)
     self.cal_dob = Calendar(self.dob_date_picker,
                             font="Arial 14",
                             selectmode='day',
                             locale='en_US',
                             mindate=mindate,
                             maxdate=maxdate,
                             background='darkblue',
                             foreground='white',
                             borderwidth=2,
                             cursor="hand1",
                             year=2019,
                             month=2,
                             day=5)
     self.cal_dob.grid(row=1, pady=40, padx=50, column=1, sticky="W")
     self.dob_button = Button(self.dob_date_picker,
                              text="Done",
                              command=self.dob_selected,
                              background="#d3d3d3")
     self.dob_button.grid(row=2,
                          column=1,
                          padx=220,
                          pady=(0, 30),
                          sticky='sW')