from tkinter import * import tkinter as tk from tkinter import ttk import calendar root=Tk() #生成主窗口 root.title('日历查询')#窗体名称 root.geometry('300x300') #指定窗体大小 root. resizable(False, False) m=ttk.Label(root,text='年份') m.pack() combobox1=ttk.Combobox(root)#可自行输入年份或从下拉 combobox1['values'] =[i for i in range(2005, 2025, 1)] combobox1.pack() n=ttk.Label(root,text='月份') n.pack() combobox2= ttk.Combobox(root) combobox2['values']= [i for i in range(1, 13, 1)] combobox2.pack() var = StringVar() q= ttk.Label(root, textvariable=var) var.set('请选择年份和月份') q. pack() def search(): num1= combobox1.get() num2=combobox2.get() var.set(calendar. month(int(num1), int(num2))) button=ttk.Button(root,text='查询', command=search) button.pack() root.mainloop()
日历查询 python代码
最新推荐文章于 2024-06-08 17:38:03 发布