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

Set Content When Initializing Window [Cont.] #2586

Merged
merged 26 commits into from
May 28, 2024
Merged

Set Content When Initializing Window [Cont.] #2586

merged 26 commits into from
May 28, 2024

Conversation

Cameronsplaze
Copy link
Contributor

@Cameronsplaze Cameronsplaze commented May 20, 2024

(A continuation from #2314)

PR Checklist:

  • All new features have been tested
  • All new features have been documented
  • I have read the CONTRIBUTING.md file
  • I will abide by the code of conduct

@Cameronsplaze Cameronsplaze marked this pull request as draft May 20, 2024 20:26
@Cameronsplaze
Copy link
Contributor Author

Will the doc string context changes update the ReadTheDocs? I haven't checked that on the list juuust in case.

@Cameronsplaze Cameronsplaze changed the title Set Content When Initializing Window Cont. Set Content When Initializing Window [Cont.] May 20, 2024
@Cameronsplaze Cameronsplaze marked this pull request as ready for review May 20, 2024 21:40
@mhsmith
Copy link
Member

mhsmith commented May 20, 2024

Will the doc string context changes update the ReadTheDocs? I haven't checked that on the list juuust in case.

Yes: there's a readthedocs preview link at the bottom of the "checks" section below. And after the PR is merged, the changes will be made public under https://toga.readthedocs.io/en/latest/ . Note the URL says "latest" as opposed to "stable" – you can switch between them using the link at the bottom left on RTD.

@Cameronsplaze
Copy link
Contributor Author

Cool, thanks! I didn't realize docs can be created on PR's, I really like that feature!

Is there anything else you'd like changed with this PR while I'm here?

Copy link
Member

@freakboy3742 freakboy3742 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR!

I've flagged a few issues inline - the biggest is around setting the _content property directly, rather than using the setter. I've pushed an update that addresses these issues.

@@ -198,6 +199,8 @@ def __init__(

self.on_close = on_close

self._content = content
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to use the setter, not just set the internal property, as there is other housekeeping that needs to be performed.

assert window_with_content.content.children[0] == label1
finally:
window_with_content.close()
window_with_content = None
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no need to do cleanup like this in the dummy backend - it doesn't leave any artefacts that could be a problem.

assert window_no_content.content is None
finally:
window_no_content.close()
window_no_content = None
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no need to test the "no content" option here - this is tested extensively by existing tests.

assert window_with_content.content == content
# Make sure it still has that internal content:
assert len(window_with_content.content.children) == 1
assert window_with_content.content.children[0] == label1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The important thing to test here isn't the parenting of content - it's the app and window assignments on the content.

assert window_no_content.content is None
finally:
window_no_content.close()
window_no_content = None
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As with the core APIs test - there's no need to test the "no content" case; that's tested elsewhere.

assert window_with_content.content == content
# Make sure it still has that internal content:
assert len(window_with_content.content.children) == 1
assert window_with_content.content.children[0] == label1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To verify this is working, the window needs to be shown, and a probe needs to wait for the window to be displayed so that a --slow invocation can visually verify the result.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure where this changenote came from (or where 5753 comes from); this can be deleted.

@freakboy3742 freakboy3742 merged commit 9005cc2 into beeware:main May 28, 2024
31 of 34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add content argument to MainWindow instantiation
4 participants