国产精品天干天干,亚洲毛片在线,日韩gay小鲜肉啪啪18禁,女同Gay自慰喷水

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

今天把好丑的計(jì)算器源碼給你了!

2020-04-27 16:05 作者:1048576_  | 我要投稿

from tkinter import *
from easygui import msgbox
w = Tk()
num1, num2 = IntVar(), IntVar()
flag, equation = StringVar(),StringVar()
def num(n):
? ?global num1,num2
? ?if flag != '':
? ? ? ?num1.set(num1.get()*10+n)
? ?else:
? ? ? ?num2.set(num2.get()*10+n)
? ?equation.set(equation.get() + str(n))
def set_flag(fl):
? ?flag.set(fl)
? ?equation.set(equation.get() + str(fl))
def calculate():
? ?try:
? ? ? ?msgbox(eval(equation.get().replace('×','*').replace('÷','/').replace('^','**')))
? ?except Exception as e:
? ? ? ?msgbox('出現(xiàn)錯誤:'+str(e))
? ?equation.set('')
w.geometry('1000x1000+200+200')
Button(w, text=0, command=lambda: num(0), width=7, height=3, font=('Arial',20)).grid(row=1,column=0)
Button(w, text=1, command=lambda: num(1), width=7, height=3, font=('Arial',20)).grid(row=1,column=1)
Button(w, text=2, command=lambda: num(2), width=7, height=3, font=('Arial',20)).grid(row=1,column=2)
Button(w, text=3, command=lambda: num(3), width=7, height=3, font=('Arial',20)).grid(row=2,column=0)
Button(w, text=4, command=lambda: num(4), width=7, height=3, font=('Arial',20)).grid(row=2,column=1)
Button(w, text=5, command=lambda: num(5), width=7, height=3, font=('Arial',20)).grid(row=2,column=2)
Button(w, text=6, command=lambda: num(6), width=7, height=3, font=('Arial',20)).grid(row=3,column=0)
Button(w, text=7, command=lambda: num(7), width=7, height=3, font=('Arial',20)).grid(row=3,column=1)
Button(w, text=8, command=lambda: num(8), width=7, height=3, font=('Arial',20)).grid(row=3,column=2)
Button(w, text=9, command=lambda: num(9), width=7, height=3, font=('Arial',20)).grid(row=4,column=1)
Button(w, text='+', command=lambda: set_flag('+'), width=7, height=3, font=('Arial',20)).grid(row=1, column=3)
Button(w, text='-', command=lambda: set_flag('-'), width=7, height=3, font=('Arial',20)).grid(row=2, column=3)
Button(w, text='×', command=lambda: set_flag('×'), width=7, height=3, font=('Arial',20)).grid(row=3, column=3)
Button(w, text='÷', command=lambda: set_flag('÷'), width=7, height=3, font=('Arial',20)).grid(row=4, column=3)
Button(w, text='^', command=lambda: set_flag('^'), width=7, height=3, font=('Arial',20)).grid(row=4, column=2)
Button(w, text='=', command=calculate, width=7, height=3, font=('Arial',20)).grid(row=4,column=0)
Label(w, textvar=equation, font=('Arial',30)).grid(row=0,column=1)
w.title('計(jì)算器')
w.mainloop()

今天把好丑的計(jì)算器源碼給你了!的評論 (共 條)

分享到微博請遵守國家法律
永春县| 商南县| 漠河县| 鱼台县| 大姚县| 齐河县| 普安县| 长岭县| 驻马店市| 琼中| 上杭县| 东丽区| 石门县| 宁晋县| 邵东县| 英吉沙县| 乐业县| 阳西县| 阜康市| 兰溪市| 乐陵市| 贺兰县| 平乡县| 灌阳县| 墨玉县| 尖扎县| 海兴县| 巴彦县| 印江| 井冈山市| 南通市| 永靖县| 保亭| 双鸭山市| 藁城市| 广德县| 博客| 英吉沙县| 灵丘县| 措美县| 云阳县|