Christmas day for 2004

现在4点多了,一场美梦完后再也无法入睡。梦见你与我是同班同学,就坐在我的后面,每次进教室都下意识的用眼睛扫描一下你的身影,用耳朵搜索你那娇滴的声音,心想:为什么你不坐在我前面,让我关注你更方便些呢? 

也许你已习惯了,男人们对你的好,也许你害怕,害怕流言蜚语,也许你已心有所属,今生不曾改变,也许你心比天高,小庙难容大菩萨.不管怎样我都要告诉你:“我喜欢你!”

我知道,我们是不可能走在一起的就我的目前而言,我想我更多需要努力的工作,勤奋的学习,为以后自己的事业打下一个坚实的基础,我会努力克制自己的情感,不让它伤害到别人与自己。好了,天快亮了,就写这么多了,去抽烟了……

                                                                                                                                   写于2004年圣诞节

python代码如下:import tkinter as tk from tkinter import messagebox import calendar from datetime import datetime class CalendarApp: def __init__(self, root): self.root = root self.root.title("万年历") # 当前日期初始化 current_date = datetime.now() self.current_year = current_date.year self.current_month = current_date.month self.today_day = current_date.day # 年份输入框 self.label_year = tk.Label(root, text="请输入年份:") self.label_year.grid(row=0, column=0, padx=10, pady=5) self.entry_year = tk.Entry(root) self.entry_year.insert(tk.END, str(self.current_year)) self.entry_year.grid(row=0, column=1, padx=10, pady=5) # 月份选择器 self.label_month = tk.Label(root, text="请选择月份:") self.label_month.grid(row=1, column=0, padx=10, pady=5) self.spin_month = tk.Spinbox(root, from_=1, to=12, width=5) self.spin_month.delete(0, "end") self.spin_month.insert(tk.END, str(self.current_month)) self.spin_month.grid(row=1, column=1, padx=10, pady=5) # 更新按钮 self.update_button = tk.Button(root, text="更新", command=self.refresh_calendar) self.update_button.grid(row=2, column=0, columnspan=2, pady=10) # 日历区域 self.calendar_frame = tk.Frame(root) self.calendar_frame.grid(row=3, column=0, columnspan=2) # 星期标签 week_days = ["日", "一", "二", "三", "四", "五", "六"] for idx, day_name in enumerate(week_days): label = tk.Label(self.calendar_frame, text=day_name, relief=tk.RIDGE, width=5) label.grid(row=0, column=idx) # 刷新初始日历 self.refresh_calendar() def refresh_calendar(self): try: input_year = int(self.entry_year.get()) input_month = int(self.spin_month.get()) if not (1 <= input_month <= 12): raise ValueError("月份必须在1到12之间") cal_data = calendar.monthcalendar(input_year, input_month) # 获取指定月份的日历数据 self.clear_calendar_grid(cal_data) row_offset = 1 today_found = False for week_idx, week in enumerate(cal_data): for day_idx, day in enumerate(week): bg_color = "white" fg_color = "black" if day != 0: # 非空白日期 if ( input_year == datetime.now().year and input_month == datetime.now().month and day == self.today_day ): bg_color = "yellow" # 高亮今天 today_found = True label_text = str(day) else: label_text = "" # 空白日期不显示文字 label = tk.Label( self.calendar_frame, text=label_text, borderwidth=1, relief=tk.RIDGE, width=5, height=2, bg=bg_color, fg=fg_color, ) label.grid(row=row_offset + week_idx, column=day_idx) if not today_found: for widget in self.calendar_frame.winfo_children(): widget.configure(bg="white", fg="black") except Exception as e: messagebox.showerror("错误", f"发生错误:{str(e)}") def clear_calendar_grid(self, cal_data): """清除旧的日历格子""" all_widgets = list(self.calendar_frame.children.values())[len(calendar.weekheader(1).split()):] for widget in all_widgets: widget.destroy() if __name__ == "__main__": root = tk.Tk() app = CalendarApp(root) root.mainloop() 请在此基础上增加节假日功能
最新发布
05-27
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值