用python写一个简易的日历

编程入门 行业动态 更新时间:2024-10-09 23:17:35

用python写一个<a href=https://www.elefans.com/category/jswz/34/1769136.html style=简易的日历"/>

用python写一个简易的日历

用python写一个简易的日历

直接上代码

from tkinter import *
import calendarroot = Tk()
# root.geometry("400x300")
root.title("calendar")def text():month_int = int(month.get())year_int = int(year.get())cal = calendar.month(year_int, month_int)textfield.delete(0.0, END)textfield.insert(INSERT, cal)# Creating Labels
label1 = Label(root, text="Month:")
label1.grid(row=0, column=0)label2 = Label(root, text="Year:")
label2.grid(row=0, column=1)# Creating spinbox
month = Spinbox(root, from_=1, to=12, width=8)
month.grid(row=1, column=0, padx=5)year = Spinbox(root, from_=1900, to=2100, width=10)
year.grid(row=1, column=1, padx=10)# Creating Button
button = Button(root, text="Go", command=text)
button.grid(row=1, column=2, padx=10)# Creating Textfield
textfield = Text(root, width=25, height=10, fg="red")
textfield.grid(row=2, columnspan=2)root.mainloop()

运行结果图

更多推荐

用python写一个简易的日历

本文发布于:2024-03-15 08:41:59,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1738502.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:简易   日历   python

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!