计算器(丑陋版 and 加法专用版)

from tkinter import *

win = Tk()
win.geometry('500x300+400+300')
win['bg'] = '#0099ff'
win.title('魔方小子')

e = Entry(win)
e.pack()

j = Label(win,text='+')
j.pack()

d = Entry(win)
d.pack()

i = Label(win,text='||')
i.pack()

s = Entry(win)
s.pack()

def fun():
    ej = int(e.get())
    de = int(d.get())
    t = ej + de
    t = str(t)
    s.insert(0,t)

def run():
    e.delete(0,END)
    d.delete(0,END)
    s.delete(0,END)
k = Button(win,text='计算',command=fun)
k.pack()
kb = Button(win,text='清除',command=run)
kb.pack()


win.mainloop()

 

posted @ 2016-08-23 19:01  疯陈演义  阅读(452)  评论(0编辑  收藏  举报