Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from tkinter import *
- root = Tk()
- first_row = Frame(root)
- second_row = Frame(root)
- third_row = Frame(root)
- fourth_row = Frame(root)
- fifth_row = Frame(root)
- e1 = Entry(first_row, width=34)
- b7 = Button(second_row, text="7", width=6, command=lambda s="7": addSymbol(s))
- b8 = Button(second_row, text="8", width=6, command=lambda s="8": addSymbol(s))
- b9 = Button(second_row, text="9", width=6, command=lambda s="9": addSymbol(s))
- button_plus = Button(second_row, text="+", width=6, command=lambda a="+": chooseAction(a))
- b4 = Button(third_row, text="4", width=6, command=lambda s="4": addSymbol(s))
- b5 = Button(third_row, text="5", width=6, command=lambda s="5": addSymbol(s))
- b6 = Button(third_row, text="6", width=6, command=lambda s="6": addSymbol(s))
- button_sub = Button(third_row, text="-", width=6, command=lambda a="-": chooseAction(a))
- b1 = Button(fourth_row, text="1", width=6, command=lambda s="1": addSymbol(s))
- b2 = Button(fourth_row, text="2", width=6, command=lambda s="2": addSymbol(s))
- b3 = Button(fourth_row, text="3", width=6, command=lambda s="3": addSymbol(s))
- button_mul = Button(fourth_row, text="*", width=6, command=lambda a="*": chooseAction(a))
- b0 = Button(fifth_row, text="0", width=6, command=lambda s="0": addSymbol(s))
- button_res = Button(fifth_row, text="=", width=12)
- button_div = Butt
- on(fifth_row, text="/", width=6, command=lambda a="/": chooseAction(a))
- def chooseAction(action):
- print(action)
- s1 = e1.get()
- #s2 = e2.get()
- #s3 = float(s1) + float(s2)
- #l['text'] = ''.join(str(s3))
- def addSymbol(symbol):
- e1.insert(END,symbol)
- first_row.pack()
- second_row.pack()
- third_row.pack()
- fourth_row.pack()
- fifth_row.pack()
- e1.pack(side=LEFT)
- b0.pack(side=LEFT)
- b1.pack(side=LEFT)
- b2.pack(side=LEFT)
- b3.pack(side=LEFT)
- b4.pack(side=LEFT)
- b5.pack(side=LEFT)
- b6.pack(side=LEFT)
- b7.pack(side=LEFT)
- b8.pack(side=LEFT)
- b9.pack(side=LEFT)
- button_plus.pack(side=LEFT)
- button_sub.pack(side=LEFT)
- button_mul.pack(side=LEFT)
- button_res.pack(side=LEFT)
- button_div.pack(side=LEFT)
- root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement