I have created a GUI calculator (a screen shot included) and when a button is pressed it adds text to the textctrl so that the equation is displayed to the user. when the user presses enter it takes that text and runs it usesing eval then prints using SetValue but if i run a problem in the texctrl like 5/6 it comes out as 0 how do i make that a float
def eenter(self,e):
a=self.box.GetValue()
answer=eval(a)
ans=str(answer)
self.box.SetValue(ans)
Just add on the start of your program, the following line:
from __future__ import divisionThat will make divisions behave in Python 2.x as they do in Python 3.x: with automatic casting to float if integer operators would result in a decimal number.