Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example in tutorial raises error #492

Closed
Thot-Htp opened this issue Nov 30, 2023 · 1 comment · Fixed by #514
Closed

Example in tutorial raises error #492

Thot-Htp opened this issue Nov 30, 2023 · 1 comment · Fixed by #514
Labels

Comments

@Thot-Htp
Copy link

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()
@lawsie
Copy link
Owner

lawsie commented May 1, 2024

Thanks @Thot-Htp - have added your change on dev

lawsie added a commit that referenced this issue Jan 10, 2025
… move docs to gh-deploy (#514)

* add set box borders example

* #492 Fixed in docs-src ONLY - please regen docs

* Add pyproject.toml #495

* Docs style update

* Add `step` to Slider, + tests + docs (#511)

* Remove deprecated PIL method

* Update dev instructions and add requirements.txt

* Add missing text properties to text derived widgets and containers (weight, slant, underline & overstrike) (#506)

* feat: add weight to Text derived widgets

* test: add tests for Texts

* docs: update docs for Text

* feat: add weight to Drawing.text

* test: add weight and color tests for Drawing.text

* docs: add weight to Drawing.text

* test: move weight_text_test into text_test

* feat: add slant to Text derived widgets

* test: fix tests for weight and add slant

* docs: update for weight and slant

* feat: add underline and overstrike to Text derived widgets

* test: add tests for underline and overstrike

* refactor: cast font properties into a tuple when passing to _set_tk_config

* docs: update docs for underline and overstrike

* fix: change weight to bold booleans and slant to italic booleans

---------

Co-authored-by: Laura Sach <[email protected]>

* Bump version

* Generate docs via mkdocs gh-deploy instead

* Change docs and add changelog

* remove DS_Store files

* Change version to 1.6.0

* Change version no in pyproject.toml too

* Edit changelog

---------

Co-authored-by: Martin O'Hanlon <[email protected]>
Co-authored-by: james-pcdr <[email protected]>
Co-authored-by: Blindstars <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants