Skip to content

WebNinjaDeveloper.com

Programming Tutorials




Menu
  • Home
  • Youtube Channel
  • Official Blog
  • Nearby Places Finder
  • Direction Route Finder
  • Distance & Time Calculator
Menu

Python 3 Tkinter Tutorial to Display Calendar Widget to Pick Dates Using tk_datecalendar Library GUI Desktop App

Posted on October 26, 2022

Welcome folks today in this blog post we will be adding the calendar widget to pick dates using tk_datecalendar library in tkinter All the full source code of the application is shown below.

 

 

Get Started

 

 

In order to get started you need to install the below library using the pip command as shown below

 

 

pip install tk_datepicker

 

 

Now after installing this you nee to make an app.py file and copy paste the below code

 

 

app.py

 

 

Python
1
2
3
4
5
6
7
8
9
10
11
from tkinter import Tk, Entry, Button
from tk_datepicker import Datepicker
 
root = Tk()
root.geometry("600x600")
entry = Entry()
entry.pack()
button = Button(text="Click me!")
button.pack()
dp = Datepicker(entry, button)
root.mainloop()

 

 

As you can see first of all we are importing the tk_datepicker library from the datepicker library. And also we are importing all the methods from the tkinter. And in this guys we have two widgets on the screen first is the simple Entry widget which is also equal to input field and then we have a button to pick the date from the datepicker. If you execute the app it will show something like this

 

 

 

 

As you can see we are using this above datepicker to select the correct date and time for your respective application where you want to store locally

 

 

Changing the Theme of the Datepicker

 

 

You can also change the theme and the colors of the datepicker widget as shown above.

 

 

1
2
3
dp = Datepicker(entry, button)
dp.ui_settings(days_bg="#888", days_fg="#FFF", t_days_bg="#FFF", t_days_fg="#FFF",
               back_month_text="<= Back", next_month_text="Next =>")

 

 

As you can see this takes the argument for backgroud color and the foreground play. And also we have the css variables.

 

 

Rendering Calendar

 

Now we will be defining on how to define and render this calendar which is defining the alignment of the calculator as shown below

 

 

1
2
3
4
5
6
7
8
1) TOP CENTER
2) TOP LEFT
3) TOP RIGHT
4) BOTTOM CENTER
5) BOTTOM LEFT
6) BOTTOM RIGHT
7) RIGHT CENTER
8) LEFT CENTER

 

 

Recent Posts

  • Node.js Puppeteer Project to Export Handlebars Resume Template to PDF Document in Express Using Javascript
  • Node.js Express Passwordless Login Example to Send Magic Auth Link Using Nodemailer
  • Python 3 Tkinter Script to Encrypt PDF Documents With Password Using PyPDF2 Library GUI Desktop App
  • Node.js Express Project to Upload Image Buffer & BLOB Data to MongoDB Database & Display it in Browser Using Javascript
  • Node.js Tutorial to Export Images to PDF Document With Effects Using FilePix Library in Javascript
  • Angular
  • Bunjs
  • C#
  • Deno
  • django
  • Electronjs
  • java
  • javascript
  • Koajs
  • kotlin
  • Laravel
  • meteorjs
  • Nestjs
  • Nextjs
  • Nodejs
  • PHP
  • Python
  • React
  • ReactNative
  • Svelte
  • Tutorials
  • Vuejs




©2023 WebNinjaDeveloper.com | Design: Newspaperly WordPress Theme