• 大小: 2.04KB
    文件类型: .py
    金币: 1
    下载: 0 次
    发布日期: 2024-05-06
  • 语言: Python
  • 标签: python  

资源简介

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 -

评论

共有 条评论