# 更新表达式功能 def press(num): # point out the global expression variable global expression # concatenation of string expression = expression + str(num) # update the expression by using set method equation.set(expression) ...... ...... ......
2、导出日历
这个小工具可以根据你输入的年份显示当年的完整日历,不过五十行代码。
查询窗口:
显示的日历效果:
示例代码(篇幅原因,不显示全部)
# 导入tkinter的所有方法 from tkinter import * # 导入日历模块 import calendar
# 给定年份显示日历 def showCal(): # 创建GUI窗口 new_gui = Tk() # 设定GUI窗口背景颜色 new_gui.config(background="white") # 设定GUI窗口名称 new_gui.title("日历") # 设定GUI窗口尺寸 new_gui.geometry("550x600") # get method returns current text as string fetch_year = int(year_field.get()) ...... ...... ......