POP UP CALENDAR
Create a pop-up calendar to all the user to select a date by clicking on the calendar. It is neat for the user and avoids incorrect dates being typed in. Watch the video and please feel free to copy the code from below.
|
#calendar from tkinter import * from tkcalendar import * screen = Tk() screen.minsize(800,600) screen.title("My Python Project") screen.configure(background="#A1CDEC") def selectDate(): myDate = myCal.get_date() selectedDate = Label(text = myDate) selectedDate.place(x = 425, y = 350) myCal = Calendar(screen, setmode = 'day', date_pattern = 'd/m/yy') myCal.place(x = 350, y = 100) openCal = Button(screen, text = "Select Date", command = selectDate) openCal.place(x = 425, y = 300)
Please feel free to copy and paste the code from above.
CHANGING THE CALENDAR STYLE
Some of the styling methods might not work on a MAC OS so below is a different way of styling your calendar.
Some of the colour methods to play with are listed below:
background = "yourcolour"
disabledbackground="yourcolour"
bordercolor ="yourcolour"
headersbackground = "yourcolour"
normalbackground ="yourcolour"
foreground = "yourcolour"
normalforeground = "yourcolour"
headersforeground = "yourcolour"
font = "Arial 12 bold"
See the example code below how some of the styling methods have been used.
Some of the colour methods to play with are listed below:
background = "yourcolour"
disabledbackground="yourcolour"
bordercolor ="yourcolour"
headersbackground = "yourcolour"
normalbackground ="yourcolour"
foreground = "yourcolour"
normalforeground = "yourcolour"
headersforeground = "yourcolour"
font = "Arial 12 bold"
See the example code below how some of the styling methods have been used.
import tkinter from tkinter import ttk from tkinter import * from tkcalendar import * screen = tkinter.Tk() screen.minsize(800,600) screen.title("My Python Project") screen.configure(background="#A1CDEC") style = ttk.Style(screen) style.theme_use('clam') def selectDate(): myDate = myCal.get_date() selectedDate = Label(text = myDate) selectedDate.place(x = 425, y = 350) myCal = Calendar(screen, setmode = 'day', font = "Arial 12 bold", bordercolor = "pink", bg = "#aa0000", date_pattern = 'd/m/yy', foreground = "#00ff00") myCal.place(x = 350, y = 100) openCal = Button(screen, text = "Select Date", command = selectDate) openCal.place(x = 425, y = 300)