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()
下面是我为tkinter日历找到的示例代码:
相关问题 更多 >
编程相关推荐