我的問題是我想獲取在 ttk.DateEntry 小部件中選擇的日期的值。根據此檔案,您需要使用 get_date() Docs
可能是我誤解了它的用法,但我收到以下錯誤
AttributeError:“DateEntry”物件沒有屬性“get_date”
我確實使用這個庫來設計ttkboostrap
這是我的代碼示例:
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()
uj5u.com熱心網友回復:
檔案鏈接是 about tkcalendar.DateEntry,但是您的代碼使用DateEntryfrom ttkbootstrapmodule 而不是tkcalendarmodule。
要從中獲取日期ttkbootstrap.DateEntry,您需要使用以下方法從內部Entry小部件中獲取內容.get():
def seedate():
print(cal.entry.get())
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/455120.html
