程式目的:輸入年份和月份,查詢當月的日曆。弄著玩。程式界面:代碼如下:# coding:utf8from tkinter import *from calendar import *from time import *class APP: def __init__(self, master): fr... ...
程式目的:輸入年份和月份,查詢當月的日曆。
弄著玩。
程式界面:
代碼如下:
# coding:utf8 from tkinter import * from calendar import * from time import * class APP: def __init__(self, master): frame = Frame(master) frame.pack() l1 = Label(frame, text="日曆查詢器,請輸入查詢的年份和月份") l1.grid(row=0, column=0, columnspan=4) l2 = Label(frame, text="年份") l2.grid(row=1, column=0) e1 = Entry(frame, bg="green") e1.grid(row=1, column=1) l2 = Label(frame, text="月份") l2.grid(row=1, column=3) e2 = Entry(frame, bg="green") e2.grid(row=1, column=4) b1 = Button(frame, text="點擊查詢", command=lambda: self.calsearch(frame, e1.get(), e2.get())) b1.grid(row=2, column=0, columnspan=4) # l3 = Label(frame, text="這裡顯示日曆", height=10, relief=SUNKEN, width=30) # l3.grid(row=3, column=0, columnspan=30) default_value = StringVar() default_value.set('這裡將會顯示日曆') l3 = Label(frame, textvariable=default_value, height=8, relief=SUNKEN, width=19) l3.grid(row=3, column=0, columnspan=4) @staticmethod def calsearch(frame, a, b): # search = month() # u = search # return u a = int(a) b = int(b) ny = month(a, b) l3 = Label(frame, text=ny, height=8, relief=SUNKEN, width=19) l3.grid(row=3, column=0, columnspan=4) root = Tk() localtime = asctime() root.title("當前時間:" + localtime) win = APP(root) root.mainloop()
這個註釋比較少,程式也比較簡陋。
現在還沒能掌握標簽的textvariable跨方法傳值。
今天先這樣了。
讀書和健身總有一個在路上