【发布时间】:2018-01-17 09:56:53
【问题描述】:
我正在尝试为日期条目创建下拉日历。 以下是我的部分代码:
它的下拉部分不起作用,我似乎无法在任何地方找到 ttk 日历的 DateEntry() 的语法来包含日历小部件选项!
#creating the frame
from tkinter import *
from tkcalendar import *
root = Tk()
f1=Frame(root,width=1500,height=100,relief=SUNKEN,bd=4,bg='light steel blue')
f1.pack(side=TOP)
f2=Frame(root,width=1500,height=550,relief=SUNKEN,bd=4,bg='white')
f2.pack()
f3=Frame(root,width=1600,height=100,relief=SUNKEN,bd=4,bg='white')
f3.pack(side=BOTTOM)
#Creating the date column
l4=Label(f2,text='DATE',font=('tahoma',20,'bold'),fg='black',anchor='w')
l4.grid(row=0,column=3)
cal=DateEntry(f2,dateformat=3,width=12, background='darkblue',
foreground='white', borderwidth=4,Calendar =2018)
cal.grid(row=1,column=3,sticky='nsew')
【问题讨论】:
-
你提供的代码有问题,你使用的是
root(在f1=..定义之前) -
另外,我不明白你到底想达到什么目的。你在说github.com/j4321/tkcalendar吗?
-
@j_4321 抱歉手动错误。我的问题是,我正在尝试创建一个日历下拉列表,一旦用户单击它,就会有一个小的日历下拉列表,他可以选择日期;然后选择的日期出现在空间中。我的问题是这行代码 cal=DateEntry(f2,dateformat=3,width=12, background='darkblue', foreground='white', borderwidth=4,Calendar =2018 )
-
DateEntry没有关键字Calendar,直接传日历关键字即可。
标签: python tkinter ttk tkcalendar