无码av一区二区三区无码,在线观看老湿视频福利,日韩经典三级片,成 人色 网 站 欧美大片在线观看

歡迎光臨散文網(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ì)算器源碼給你了!的評論 (共 條)

分享到微博請遵守國家法律
浠水县| 钟祥市| 丹江口市| 霍林郭勒市| 温泉县| 界首市| 鱼台县| 东乡| 文化| 额敏县| 西乡县| 杭锦后旗| 朝阳市| 涿鹿县| 固安县| 焉耆| 内丘县| 探索| 甘洛县| 广河县| 乐至县| 丹巴县| 定日县| 广河县| 乌拉特后旗| 旅游| 巫山县| 绵竹市| 色达县| 峨眉山市| 新晃| 柳江县| 大安市| 安顺市| 新龙县| 西和县| 胶南市| 红河县| 田林县| 宝坻区| 咸宁市|