tkcalendar 与 ttkbootstrap 兼容性问题

问题描述 投票:0回答:1

我在 python 脚本中使用 ttkbootstrap。我尝试使用 ttkbootstrap 中的 DateEntry,但它不会像 tkcalendar 那样触发事件(至少我找不到任何东西),而且我喜欢 tkcalendar 侧面有一个周计数器。

所以我想使用 tkcalendar DateEntry 而不是 ttkbootstrap DateEntry。现在单独使用它可以完美地工作,但是当我一起使用 ttkbootstrap 和 tkcalendar 时我总是得到

AttributeError:“DateEntry”对象没有属性“_calendar”

这是我的代码,不起作用:

import ttkbootstrap as ttk
from tkcalendar import DateEntry

#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 =  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()

当我使用 ttkbootstrap DateEntry 时,它会立即起作用。

我尝试更新这两个模块,但没有成功。并切换到 ttkbootstram DateEntry,然后就可以了。

python tkinter ttk tkcalendar ttkbootstrap
1个回答
0
投票

所以我想使用 tkcalendar DateEntry 而不是 ttkbootstrap 日期条目。现在它自己可以完美地工作,但不是 当我一起使用 ttkbootstrap 和 tkcalendar 时,我总是得到

AttributeError:“DateEntry”对象没有属性“_calendar”

问题可以解决:

  • 在第 11 行,设置缩进。

同时更改此:

print(cal.get_date())

至:

print(cal.entry.get())

截图:

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.