Ensure that windows always have content
- Dominant language
- Python
- Stars
- 5.4k
- Forks
- 827
- Avg merge
- 15h 39m
- Merged PRs (30d)
- 40
Description
### What is the problem or limitation you are having?
At present, `window.content` can be either a widget, or `None`. It would simplify some code paths (and avoid some bugs) if we could always guarantee that a window had *some* content, even if it is an empty box.
### Describe the solution you'd like
If a window is constructed without an explicit content object, a `toga.Box` should be created and installed as content.
### Describe alternatives you've considered
Status quo - make a policy decision that we're going to allow truly empty windows, and stick with that.
### Additional context
This originally came up in the context of #2818, which was an actual bug caused by a window not having content. #2473 also identified some edge cases that would be made more simple if windows always had content.
However, this is a case where the fix is trivial, but the impact on testing is huge. #3478 was an attempt to fix this problem - and although the "raw fix" is only 2 lines, it introduced dozens of cascading changes into the test suite, because any test case that counts widgets in the widget registry now has an additional widget. This is especially problematic when the test case has an additional window, and doesn't actually care about the content in the main window.
So - we have three options:
1. Keep the status quo, and accept that windows might not have content
2. Modify the test suite to accomodate the extra widget - essentially bumping every widget count by 1, possibly documenting where the extra widget comes from in situations where it may not be obvious
3. Modify the implementation slightly so it is *possible* (maybe even undocumented) that `None` is a valid value if it is explicit.
(3) had the least impact on the test suite, but doesn't really solve the problem because we'd still need to accomodate the `is None` case everywhere (or, at least, a lot of places).
It might be possible minimise the impact of (2) by changing some tests to actually use the main window, rather than a secondary window.
Contributor guide
Research direction
Start by reviewing the prior attempt in #3478 and the edge cases described in #2818 and #2473. Then examine the test cases that count widgets in the widget registry, especially those involving a secondary window. Done means selecting and implementing one of the three stated content policies while bringing the affected tests into agreement.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- desktop
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100