DateEntry widget of ttkbootstrap

Ttkbootstrap DateEntry
Date can be selected from a Calendar and inserted to a Combobox.


Parameters


dateformatThe date format to be returned. Check all Date formats here.
firstweekday0=Monday, 1=Tuesday ... To display on Calendar
startdateDatetime, the date to be infocus, default is current date
bootstyleStyle keyword, options are
primary, secondary, success,info,warning,danger, light, dark
**kwargsOther keyword arguments.


DateEntry of Ttkbootstrap to select date from a Calendar with options and parameters #13


import ttkbootstrap as ttk
from ttkbootstrap.constants import *
from datetime import date
my_w = ttk.Window()
my_w.geometry("420x300")  # width and height
dt2=date(2023,12,30) # start date 

de = ttk.DateEntry(dateformat='%Y-%m-%d',firstweekday=2,startdate=dt2)
de.grid(row=1, column=1, padx=10, pady=20)

my_w.mainloop()

Reading and displaying selected date on a Label on click of a button.

Ttkbootstrap DateEntry get selected date
import ttkbootstrap as ttk
from ttkbootstrap.constants import *
from datetime import date
my_w = ttk.Window()
my_w.geometry("520x320")  # width and height
dt2=date(2023,12,30) # for startdate 
sel=ttk.StringVar()
de = ttk.DateEntry(dateformat='%Y-%m-%d',firstweekday=2,startdate=dt2)
de.grid(row=1, column=1, padx=10, pady=20)

def my_upd():
    l1.configure(text=de.entry.get()) # displaying date 

b1=ttk.Button(my_w,text='Show date',command=lambda:my_upd())
b1.grid(row=1,column=2)
l1=ttk.Label(my_w,text='Date') # to display date here 
l1.grid(row =1,column=3)
my_w.mainloop()
All ttkbootstrap styles are applied using the bootstyle parameter. We can use all the avilable styles and apply to DateEntry.
DateEntry all bootstyle colours
import ttkbootstrap as ttk
from ttkbootstrap.constants import *
from datetime import date
my_w = ttk.Window()
my_w.geometry("700x200")  # width and height
c,r=0,0
for my_style in my_w.style.colors: # List of styles 
    de = ttk.DateEntry(bootstyle=my_style)
    de.grid(row=r, column=c, padx=2, pady=20)
    c=c+1
    if c==4:
        c,r=0,1
my_w.mainloop()

state

After creation of the DateEntry we can update the state option. It can take values : readonly, disabled or invalid.
de.configure(state='readonly')
#de.configure(state='disabled')
de.configure(state='invalid')

ttkbootstrap tkcalendar DateEntry
Subscribe to our YouTube Channel here


Subscribe

* indicates required
Subscribe to plus2net

    plus2net.com



    Post your comments , suggestion , error , requirements etc here





    Python Video Tutorials
    Python SQLite Video Tutorials
    Python MySQL Video Tutorials
    Python Tkinter Video Tutorials
    We use cookies to improve your browsing experience. . Learn more
    HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
    ©2000-2024 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer