I am trying to make a simple calculator that gives square and square root with using Python 2.7.10 with GUI but it doesn't work I can't figure out what is the problem. I receive this error:
> Exception in Tkinter callback Traceback (most recent call last): File > "C:\Python27\lib\lib-tk\Tkinter.py", line 1536, in call return > self.func(*args) File "C:/Users/Ali/Desktop/simplecalc.py", line 5, in > do_sqrt root = x**0.5 TypeError: unsupported operand type(s) for ** or > pow(): 'str' and 'float'
import Tkinter
import tkMessageBox
def do_sqrt():
root = x**0.5
tkMessageBox.showinfo("Square Root = ", x)
def do_square():
square = x**2
tkMessageBox.showinfo("Square = ", x)
main_window = Tkinter.Tk()
main_window.title("Simple Calc")
number_input = (Tkinter.Entry(main_window))
x = number_input.get()
button_sqrt = Tkinter.Button(main_window, text = "Square Root", command = do_sqrt)
button_sqrt.pack()
button_square = Tkinter.Button(main_window, text = "Square", command = do_square)
button_square.pack()
number_input.pack()
main_window.mainloop()