資源簡介
python實現的日歷
代碼片段和文件信息
#?-*-?coding:UTF-8?-*-
from?Tkinter?import?*
class?Calendar(frame):
????def?__init__(self?master):
????????frame.__init__(self?master)
????????self.day_button?=?[]
????????self.day_control?=?[]
????????for?weeks?in?range(len([‘周一‘?‘周二‘?‘周三‘?‘周四‘?‘周五‘?‘周六‘?‘周日‘])):
????????????Label(self?text=[‘周一‘?‘周二‘?‘周三‘?‘周四‘?‘周五‘?‘周六‘?‘周日‘][weeks]).grid(row=0?column=weeks)
????????for?i?in?range(42):
????????????self.day_control.append(StringVar())
????????????self.day_button.append(Button(self?textvariable=self.day_control[i]))
????def?display(self?time):
????????for?every_control?in?self.day_control:
????????????every_control.set(‘‘)
????????day_tuple?=?[31?28?31?30?31?30?31?31?30?31?30?31]
????????year?=?int(time[:4])
????????month?=?int(time[5:7])
????????if?(year?%?4?==?0?and?year?%?100?!=?0)?or?year?%?400?==?0:
????????????day_tuple[1]?+=?1
????????co?=?first_day(time)?-?1
????????ro?=?1
????????order?=?co
????????for?j?in?range(1?day_tuple[month?-
- 上一篇:Python源代碼:以web方式管理自己的常用鏈接
- 下一篇:微信防撤回.py
評論
共有 條評論