Skip to content

Update containers.py #5598

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

Closed
wants to merge 1 commit into from
Closed

Conversation

friscorose
Copy link
Contributor

Using None as default for min_column_width breaks automatic horizontal flow of children into columns per the API at https://textual.textualize.io/api/containers/#textual.containers.ItemGrid

Setting to the minimum positive integer that maintains documented behavior. Though this may actually be a deeper issue in layout, I leave that decision to someone more knowledgeable. Other positive integers may also be more desirable and it has been suggested to pick a value that is a power of 2.

Please review the following checklist.

  • Docstrings on all new or modified functions / classes
  • Updated documentation
  • Updated CHANGELOG.md (where appropriate)

Using None as default for min_column_width breaks automatic horizontal flow of children into columns per the API at https://textual.textualize.io/api/containers/#textual.containers.ItemGrid

Setting to the minimum positive integer that maintains documented behavior. Though this may actually be a deeper issue in layout, I leave that decision to someone more knowledgeable. Other positive integers may also be more desirable and it has been suggested to pick a value that is a power of 2.
@willmcgugan
Copy link
Collaborator

I think you may be expecting too much from this class. It is a relatively recent addition, I added for the demo, and there is much more functionality that could (should) be added.

A min column width of 1 is likely always wrong. Most widgets would be unusable at that size.

I suspect that a default of None should automatically pick a minimum column width, possible by auto-detecting it in some way. But I'm not sure yet how that should work.

@friscorose
Copy link
Contributor Author

A min column width of 1 is likely always wrong. Most widgets would be unusable at that size.

This PR is not really me - it was a discussion in @help-wanted to help @XotEmBotZ, but I think the solution hoped for was something more along the lines of auto resizing columns based on dynamic item input.

That said, I can imagine a single character item column being useful in a few odd corner cases and since 1 is technically the minimum possible for the item to actually be present, it seemed a suitable stop gap solution until a more robust solution exists.

Please feel free to close this PR or ask me to - it was just a breadcrumb to mark a user issue.

@willmcgugan
Copy link
Collaborator

At some point there will be a more flexible ItemGrid, or something like it.

@willmcgugan willmcgugan closed this Apr 7, 2025
@friscorose friscorose deleted the horizontal_flow branch April 7, 2025 09:17
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.

2 participants