beeware / toga

A Python native, OS native GUI toolkit.
https://toga.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
4.3k stars 668 forks source link

dialogs example is broken(?) 'MainWindow' object has no attribute 'dialog'" #2681

Closed shula closed 3 months ago

shula commented 3 months ago

Describe the bug

trying to run the dialog example , almost all of the events there throw this exception (even Close, File > close)

Error in async handler: 'MainWindow' object has no attribute 'dialog'
Traceback (most recent call last):
  File "C:\programs\python\Lib\site-packages\toga\handlers.py", line 78, in handler_with_cleanup
    result = await handler(interface, *args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Steps to reproduce

  1. download latest snapshot from github
  2. cd toga-main\examples\dialogs
  3. python -m dialogs

main window is showing, so far.

  1. click any button, or try to close the window: throws the exception above; nothing else happens

Expected behavior

run without exceptions :)

Screenshots

No response

Environment

Logs

Additional context

No response

rmartin16 commented 3 months ago

Thanks for reporting this; looks like some recent changes introduced issues in this example app.

For the time being, if you run git checkout v0.4.5, the example apps should run without error.

freakboy3742 commented 3 months ago

To be clear - are you using Toga 0.4.5, or the current main branch? We've recently made some fairly major changes to dialogs, and the example code on main has been updated to use the new APIs; but the new API won't work with the current 0.4.5 release. The .dialog attribute is the new API.

You need to install the version of Toga that matches the example code you're running. If you select the 0.4.5 branch in GitHub, you can see the older dialog example code; or, you can follow the instructions in the developer guide for how to install the development version.

rmartin16 commented 3 months ago

ah, of course...in my case, anyway, I thought I had editable versions of Toga installed....but I did not; so, -r strikes again :)

shula commented 3 months ago

ah, of course...in my case, anyway, I thought I had editable versions of Toga installed....but I did not; so, -r strikes again :)

i don't understand your reply (it's sounds interesting, but i guess it's off topic).

@freakboy3742 you're right: my bug report wasn't accurate;
apparently i got the examples out of the main branch, but I installed via pip (which got me v0.4.5)