tkinter日历选择

from tkcalendar import Calendar, DateEntry

def insert_INSERT():
	text1.insert(INSERT, cal_value.get())
     text1.insert(INSERT, cal.get_date())
cal_value = StringVar() cal = DateEntry(win, date_pattern='y-mm-dd', locale = 'zh_CN', width=10, bg="darkblue", fg="white", textvariable = cal_value)
cal.grid(row=1,column=4) b = Button(win, text="insert INSERT方式插入", command=insert_INSERT).grid(row=1,column=0) year : int intinitially displayed year, default is current year. month : int initially displayed month, default is current month. day : int initially selected day, if month or year is given but not day, no initial selection, otherwise, default is today. firstweekday : "monday" (default) or "sunday" first day of the week weekenddays : list days to be displayed as week-end days given as a list of integers corresponding to the number of the day in the week (e.g. [6, 7] for the last two days of the week). mindate : None (default), datetime.date or datetime.datetime minimum allowed date maxdate : None (default), datetime.date or datetime.datetime maximum allowed date showweeknumbers : bool (default is True) whether to display week numbers. showothermonthdays : bool (default is True) whether to display the last days of the previous month and the first of the next month. locale : str locale to use, e.g. 'en_US' zh_CN date_pattern : str date pattern used to format the date as a string. The default pattern used is babel's short date format in the Calendar's locale. A valid pattern is a combination of 'y', 'm' and 'd' separated by non letter characters to indicate how and in which order the year, month and day should be displayed. y: 'yy' for the last two digits of the year, any other number of 'y's for the full year with an extra padding of zero if it has less digits than the number of 'y's. m: 'm' for the month number without padding, 'mm' for a two-digit month d: 'd' for the day of month number without padding, 'dd' for a two-digit day Examples for datetime.date(2019, 7, 1): 'y-mm-dd' → '2019-07-01' 'm/d/yy' → '7/1/19' selectmode : "none" or "day" (default) whether the user can change the selected day with a mouse click. textvariable : StringVar connect the currently selected date to the variable.

  

text1.insert(INSERT, cal_value.get())

posted on 2023-03-10 15:43  帅胡  阅读(66)  评论(0编辑  收藏  举报

导航