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

Add Row and Column subclasses of Box #3010

Open
mhsmith opened this issue Dec 2, 2024 · 2 comments
Open

Add Row and Column subclasses of Box #3010

mhsmith opened this issue Dec 2, 2024 · 2 comments
Labels
enhancement New features, or improvements to existing features.

Comments

@mhsmith
Copy link
Member

mhsmith commented Dec 2, 2024

Rows and columns are used more than any other component, and often don't have any style properties other than direction, so this would save a lot of typing.

I think it would also make the structure of the UI easier to visualise from the code if the direction was a bit more prominent rather than buried in a property. Compare:

toga.Box(style=Pack(direction="column"), children=[...])

with:

toga.Column(children=[...])
@mhsmith mhsmith added the enhancement New features, or improvements to existing features. label Dec 2, 2024
@freakboy3742
Copy link
Member

The one notable argument against Row/Column classes is that it merges style with content - in principle, with a full CSS engine, it should be possible to take a single composition of boxes, and turn it into a near arbitrary layout.

There's also the question of what happens when someone writes toga.Column(style=Pack(direction="row"), children=...).

However, pragmatically, we don't have a full CSS engine yet; and most users aren't thinking about their app from a "full separation" lens, so I guess including Row/Column as a feature, and documenting the "problems for advanced users" is a reasonable compromise.

@mhsmith
Copy link
Member Author

mhsmith commented Dec 4, 2024

Merging style with content is indeed what I was proposing in #3011. In that model, Column and Row would override the direction property to make it read-only, so toga.Column(style=Pack(direction="row")) would cause an immediate exception.

Alternatively, I guess Column and Row could just be shorthand for "Box with a default direction" rather than full subclasses.

Let's first decide how to proceed in #3011, and then come back to this.

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

No branches or pull requests

2 participants