Issue #54 resolved

gui.py with python3: TypeError: Can't convert 'bytes' object to str implicitly

Kevin Stock
created an issue

In the gui.py example after clicking the white box and typing any letter I get:

$ python gui.py 
Using software rendering
Traceback (most recent call last):
  File "gui.py", line 155, in <module>
    sys.exit(run())
  File "gui.py", line 145, in run
    uiprocessor.dispatch([button, checkbutton, entry], event)
  File ".../lib/python3.3/site-packages/sdl2/ext/gui.py", line 337, in dispatch
    handler(v, e)
  File ".../lib/python3.3/site-packages/sdl2/ext/gui.py", line 230, in textinput
    component.text += event.text.text
TypeError: Can't convert 'bytes' object to str implicitly

Changing line 230 of ext/gui.py to

    component.text += event.text.text.decode('utf-8')

fixed it for python3, but I don't know what other issues this might cause.

Comments (1)

  1. Log in to comment