# --------------------定义获取开始时间的函数-------------------------------------- def start_calendar(self): def print_sel(): self.Text3.configure(state="normal") print(str(cal.selection_get())) s_data = str(cal.selection_get()) self.Text3.delete(0, END) self.Text3.insert("0", s_data) self.Text3.configure(state="disabled") cal.see(datetime.date(year=2016, month=2, day=5)) top.destroy() # 关闭并退出日期选择器 top = tk.Toplevel() top.geometry("300x250+350+450") # 定义日期界面的尺寸,及后面加上“+300+300”,表示距离左边300和距离上边的距离300。 today = datetime.date.today() mindate = datetime.date(year=1990, month=1, day=1) # 获取的最小日期 maxdate = today + datetime.timedelta(days=5) # 获取的最大日期 cal = Calendar(top, font="黑体加粗 10", selectmode='day', locale='zh_CN', mindate=mindate, maxdate=maxdate, background="green", foreground="red", bordercolor="green", selectbackground="green", selectforeground="red", disabledselectbackground=False) cal.place(x=0, y=0, width=300, height=200) tk.Button(top, text="确定", command=print_sel).place(x=240, y=205) # --------------------定义获取开始时间的函数-------------------------------------- # --------------------定义获取结束时间的函数-------------------------------------- def end_calendar(self): def print_sel(): self.Text4.configure(state="normal") print(str(cal.selection_get())) s_data = str(cal.selection_get()) self.Text4.delete(0, END) self.Text4.insert("0", s_data) self.Text4.configure(state="disabled") cal.see(datetime.date(year=2016, month=2, day=5)) top.destroy() # 关闭并退出日期选择器 top = tk.Toplevel() top.geometry("300x250+910+450") # 定义日期界面的尺寸和显示位置 today = datetime.date.today() mindate = datetime.date(year=1990, month=1, day=1) # 获取的最小日期 maxdate = today + datetime.timedelta(days=5) # 获取的最大日期 cal = Calendar(top, font="黑体加粗 10", selectmode='day', locale='zh_CN', mindate=mindate, maxdate=maxdate, background="green", foreground="red", bordercolor="green", selectbackground="green", selectforeground="red", disabledselectbackground=False) cal.place(x=0, y=0, width=300, height=200) tk.Button(top, text="确定", command=print_sel).place(x=240, y=205) # --------------------定义获取结束时间的函数--------------------------------------
04-14
554
07-19
1万+
09-19
2055