- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How do I create a date picker in tkinter?
Tkcalendar is a Python package which provides DateEntry and Calendar widgets for tkinter applications. In this article, we will create a date picker with the help of DateEntry Widget.
A DateEntry widget contains three fields that refer to the general format of Date as MM/DD/YY. By creating an object of DateEntry widget, we can choose a specific Date in the application.
Example
#Import tkinter library from tkinter import * from tkcalendar import Calendar, DateEntry #Create an instance of tkinter frame win= Tk() #Set the Geometry win.geometry("750x250") win.title("Date Picker") #Create a Label Label(win, text= "Choose a Date", background= 'gray61', foreground="white").pack(padx=20,pady=20) #Create a Calendar using DateEntry cal = DateEntry(win, width= 16, background= "magenta3", foreground= "white",bd=2) cal.pack(pady=20) win.mainloop()
Output
Execute the above code snippet to display a date picker in the window.
Now pick any date from the DateEntry Widget to set and reflect the output.
Advertisements