I'm trying to create a basic calculator and have a small problem I cant quite get. When you press the number buttons the input box will add the numbers until you then press a math key where the numbers will reset. What I cant work out is, say you put a number in like 8 then hit the inverse key, the output will show 0.125, then when you start typing again it will delete all things in the output window. Here is what I have but isn't working.
def button_click(number):
if Flag == True:
e.delete(0,END)
e.insert(0, str(number))
else:
Current = e.get()
e.delete(0,END)
e.insert(0, str(Current) + str(number))
global Flag
Flag = False
and for the inv function
def button_inv():
Current = float(e.get())
e.delete(0, END)
e.insert(0, 1/Current)
global Flag
Flag = True
Anyone have any ideas? Thanks.