如何使用tktin制作日历

2024-03-29 14:58:09 发布

您现在位置:Python中文网/ 问答频道 /正文

告诉我怎么用tkinter做日历。日历应该是可定制的,您可以添加或安排您的活动,如日历安装在我们的手机。我真的不知道下一步该怎么办


Tags: tkinter手机
1条回答
网友
1楼 · 发布于 2024-03-29 14:58:09

下面是我为tkinter日历找到的示例代码:

import calendar as cd
import tkinter as tk

# supply year and month
year = 2007
month = 2    # jan=1

# assign the month's calendar to a multiline string
str1 = cd.month(year, month)

# create the window form and call it root (typical)
root = tk.Tk()
root.title("Monthly Calendar")

# pick a fixed font like courier so spaces behave right 
label1 = tk.Label(root, text=str1, font=('courier', 14, 'bold'), bg='yellow')
label1.pack(padx=3, pady=5)

# run the event loop (needed)
root.mainloop()

相关问题 更多 >