[wxPython-users] Get a valur for make some calculates

Hugues JEAN-BAPTISTE hjb at agorinfo.fr
Tue Apr 3 10:57:56 PDT 2007


Andrea a écrit :
> Hi all,
>
> I have a little gui that provide 4 textctrl for insert some data.
> After that the user insert the data I would like to do some operation
> with this data like a * b = c but I receive some type error because I
> don't have a int variables.
>
> How can I get the value from GetValue() function and use thus like
> integer or float number for do the calculates?
>
> ---Code---
> ...
> ...
> self.local = wx.TextCtrl(self.panel, -1, '', pos = (200, 45))
> self.scontolocal = wx.TextCtrl(self.panel, -1, '', pos = (200, 75))
> ...
> ...
>  def OnCalculate(self, event):
>     	tot_local = self.local.GetValue()
>     	scontolocal_mr = self.scontolocal.GetValue()
>     	sconto = (tot_local * scontolocal_mr)/100
>     	res = tot_local - sconto
>     	self.totscontato = wx.TextCtrl(self.panel, -1, res, pos = (200,
> 105))
> ...
> ...
>
> Thanks
> Andrea
>   
Hi Andrea,

I use something as :

a = round(float(self.local.GetValue()) * x / 100, 2)

float or int

Friendly.

-- 

Hugues JEAN-BAPTISTE (hjb at agorinfo.fr)
AGORINFO S.A.S. (http://www.agorinfo.fr)






More information about the wxpython-users mailing list