import tkinter #导入tkinter模块
root = tkinter.Tk()
root.minsize(280500)
root.title(‘数字计算器‘)
#1.界面布局
#显示面板
result = tkinter.StringVar()
result.set(0) #显示面板显示结果1,用于显示默认数字0
result2 = tkinter.StringVar() #显示面板显示结果2,用于显示计算过程
result2.set(‘‘)
#显示版
label = tkinter.Label(rootfont = (‘微软雅黑‘20)bg = ‘#EEE9E9‘bd =‘9‘fg = ‘#828282‘anchor = ‘se‘textvariable = result2)#设置运算结果的显示界面的长,宽距离
label.place(width = 280height = 170)
label2 = tkinter.Label(rootfont = (‘微软雅黑‘30)bg = ‘#EEE9E9‘bd =‘9‘fg = ‘black‘anchor = ‘se‘textvariable = result)#设置输入界面的长,宽距离
label2.place(y = 170width = 280height = 60)
#数字键按钮
btn7 = tkinter.Button(roottext = ‘7‘font = (‘微软雅黑‘20)fg = (‘#4F4F4F‘)bd = 0.5command = lambda : pressNum(‘7‘))#对于键位7的位置,宽,高的距离设置
btn7.place(x = 0y = 285width = 70height = 55)
btn8 = tkinter.Button(roottext = ‘8‘font = (‘微软雅黑‘20)fg = (‘#4F4F4F‘)bd = 0.5command = lambda : pressNum(‘8‘))#对于键位8的位置,宽,高的距离设置
btn8.
评论
共有 条评论