tkinter日历选择
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | 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. |
1 | text1.insert(INSERT, cal_value.get()) |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· winform 绘制太阳,地球,月球 运作规律
· AI与.NET技术实操系列(五):向量存储与相似性搜索在 .NET 中的实现
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 上周热点回顾(3.3-3.9)
2016-03-10 sqlite3 sqlite3_prepare、sqlite3_step使用
2016-03-10 C/C++获取当前系统时间
2016-03-10 C++ 字符串转化成浮点型
2016-03-10 两种将字符串转换成浮点数的方法
2015-03-10 jstat命令(Java Virtual Machine Statistics Monitoring Tool)