Converting Unicode to integer

Nikola Plejic Nikola.Plejic at pu.CARNet.hr
Tue Aug 27 19:32:08 CEST 2002


Yeah, I realized that and corrected it:

from anygui import *

def handler(**kw):
    a = txt.text
    b = txt2.text
    a = int(a)
    b = int(b)
    lbl.text = a + b

mywin = Window()
mywin.size = 400, 200
mywin.title = "test 1.0"
mywin.layout = Placer()
app = Application()
app.add(mywin)

txt = TextField()
txt.position = 10, 10
txt.size = mywin.width - 20, 25
mywin.add(txt, top=10, left=10, right=100, hstretch=1)

txt2 = TextField()
txt.position = 10, 10
txt.size = mywin.width - 100, 25
mywin.add(txt2, top=70, left=10, right=100, hstretch=1)

btn = Button()
btn.text = "Zbroji!"
btn.width = mywin.width - 50
mywin.add(btn, top=9, left=mywin.width - 70, right=10)
link(btn, 'click', handler)

lbl = Label()
lbl.txt = "rezultat"
lbl.position = 50, 100
mywin.add(lbl)

app.run()

And I get this exception:

Traceback (most recent call last):
  File "C:\Python22\Lib\site-packages\anygui\backends\mswgui.py", line 498,
in _wndproc
    return window._WM_COMMAND(hwnd, msg, wParam, lParam)
  File "C:\Python22\Lib\site-packages\anygui\backends\mswgui.py", line 379,
in _WM_COMMAND
    child_window._WM_COMMAND(hwnd, msg, wParam, lParam)
  File "C:\Python22\Lib\site-packages\anygui\backends\mswgui.py", line 174,
in _WM_COMMAND
    send(self, 'click')
  File "C:\Python22\Lib\site-packages\anygui\Events.py", line 105, in send
    result = handler(**args)
  File "C:\Python22\Lib\site-packages\anygui\References.py", line 73, in
__call__
    return self.func(*args, **kwds)
  File "C:\Python22\test2.py", line 8, in handler
    lbl.text = a + b
  File "C:\Python22\Lib\site-packages\anygui\Mixins.py", line 137, in
__setattr__
    inhibit_refresh = setter(value)
  File "C:\Python22\Lib\site-packages\anygui\Labels.py", line 15, in
_set_text
    text = text.replace('\r\n', ' ')
AttributeError: 'int' object has no attribute 'replace'

Don't have a clue what that means :(...

"rzed" <Dick.Zantow at lexisnexis.com> wrote in message
news:akg6a8$ahe$1 at mailgate2.lexis-nexis.com...
>
> "Nikola Plejic" <Nikola.Plejic at pu.CARNet.hr> wrote in message
> news:akfvki$eot$1 at bagan.srce.hr...
> > Oh, okay, sorry (feeling embarrassed now :)).
> >
> > Here's my attempt in using int():
> >
> > from anygui import *
> >
> > def handler(**kw):
> >     a = txt.text
> >     b = txt2.text
> >     int(a)
> >     int(b)
>
> Right here. int(a) produces a result, which then ignore.
>    a = int(a)
>    b = int(b)
>     ... would fit into the next statement and work as you expect.
>
> --
> rzed
>
>





More information about the Python-list mailing list