Home > front end >  Cannot get value from DateEntry widget in tkinter window. - object has no attribute 'get_date&#
Cannot get value from DateEntry widget in tkinter window. - object has no attribute 'get_date&#

Time:04-01

My problem is I want to get the value of the date that was selected in the ttk.DateEntry widget. According to this documentation you need to use get_date() Docs

It may be that I am misunderstanding the usage of that but I get the following error

AttributeError: 'DateEntry' object has no attribute 'get_date'

I do use this library for styling ttkboostrap

Here is my code example:

import tkinter as tk
import tkinter
import ttkbootstrap as ttk

##setup the window
pwin = ttk.Window(themename="cyborg")
pwin.title('test')
    
##function to get the date
def seedate():
    print(cal.get_date())
    
##this is he DateEntry widget
cal =  ttk.DateEntry(pwin,bootstyle="info")
cal.place(x=10, y=80)

#button to get the selected date
btnpt = ttk.Button(pwin, text="Save Schedule", bootstyle="light-outline", command=seedate)
btnpt.place(x=10, y=140)

pwin.mainloop()

CodePudding user response:

The document link is about tkcalendar.DateEntry, however your code uses DateEntry from ttkbootstrap module instead of tkcalendar module.

To get the date from ttkbootstrap.DateEntry, you need to get the content from the internal Entry widget using .get():

def seedate():
    print(cal.entry.get())
  • Related