lawsie/guizero

Example in tutorial raises error

Thot-Htp opened this issue · 1 comments

Describe the bug
Trying to concatenate a string with event_data.widget with the + operator, as in the example:
print("widget clicked = " + event_data.widget)

raises the error:
print("widget clicked = " + event_data.widget)
TypeError: can only concatenate str (not "App") to str

To Reproduce

  1. Go to https://lawsie.github.io/guizero/events/'
  2. Implement the following example (for example with widget = App() ) from the page:
from guizero import App

def clicked(event_data):
    print("widget clicked = " + event_data.widget)
    print("mouse position = " + event_data.x + "." + event_data.y)

app = App()
app.when_clicked = clicked

app.display()

  1. See error

Expected behavior
The output:
widget clicked = [App] object
mouse position = 26 . 35

System information:

  • OS: Windows 10]
  • guizero version: 1.4.0

Additional context
Replacing '+' with ',' ('plus' with 'comma') solves the problem, like so:

from guizero import App

def clicked(event_data):
    print("widget clicked = " , event_data.widget)
    print("mouse position = " , event_data.x , "." ,  event_data.y)

app = App()
app.when_clicked = clicked

app.display()