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

Change 'Window' object has no attribute 'viewport' error to something more useful #1804

Closed
uwuclxdy opened this issue Mar 5, 2023 · 0 comments · Fixed by #2058
Closed

Change 'Window' object has no attribute 'viewport' error to something more useful #1804

uwuclxdy opened this issue Mar 5, 2023 · 0 comments · Fixed by #2058
Labels
enhancement New features, or improvements to existing features.

Comments

@uwuclxdy
Copy link

uwuclxdy commented Mar 5, 2023

What is the problem or limitation you are having?

When trying to add a new window to the app the error 'Window' object has no attribute 'viewport' appeared and I had no idea what it meant. Turns out I needed to add the window to self.app.windows before window.show()

e.g.:

def open_interface(self, widget):
    main_box = toga.Box()
    new_window = toga.Window(title="ttttt")
    new_window.content = main_box
    new_window.show()

A call to self.app.windows += new_window is needed before new_window is shown,

Describe the solution you'd like

A more clear error message, indicating on what I did wrong. A window can detect if it's been assigned to an app; if a window hasn't been assigned to an app, it should raise an appropriate error, rather than raising errors as a side effect when deeper problems occur.

Also - if you're on iOS or Android, you can't create additional windows at all (because it wouldn't make sense to do so); attempting to add a window should raise an error.

Describe alternatives you've considered

Asking for help in the official BeeWare discord server.

Additional context

No response

@uwuclxdy uwuclxdy added the enhancement New features, or improvements to existing features. label Mar 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New features, or improvements to existing features.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant