Comments (5)
Hey Pablo, thanks for opening this issue.
Would you mind providing a minimal reproducible example that mimics the issue you're describing in your context as closely as possible?
You are probably right in all of the conclusions you made but without having some concrete code to look at and run we may end up spending a bunch of time going back and forth without even knowing if we're talking about the same thing.
from textual.
@rodrigogiraoserrao Yes, no problem, will do asap 👍
from textual.
@rodrigogiraoserrao Here is the MRE: https://github.com/PabloLec/textual_4015_mre/blob/main/textual_4015_mre/__init__.py
With test runs showing the behavior difference between versions: https://github.com/PabloLec/textual_4015_mre/actions
So, since version 0.47.0, you can't access an element's children before compose. The children parameter turns up empty.
This is just a basic example, so its practicality might not be obvious at first.
In my situation, for instance, I've got this asynchronous component that's responsible for creating ListItems with a Label, which can be pretty lengthy, without any restrictions during creation. Then, there's another component that adds these ListItems to a list and chops down the Label text depending on the screen size. And all this happens before compose, before the user can see the result.
I'm focusing on the ListItem example because it's what I'm dealing with, but this is actually a behavior that's common to all components with children.
from textual.
There are two ways of adding children.
You can do this...
yield ListItem(item)
Or this...
with ListItem():
yield item
Both should work in the same way, but the second will have children added after compose. Which is why its not a good idea to rely on the children being available in the constructor.
Widgets that haven't been mounted aren't that useful, and may break if you use their methods, so we want to discourage using them until everything is mounted.
It shouldn't be much of an issue in practice. But you will need to write your tests diffrently. I assume you have seen our guide on testing Textual apps ?
from textual.
Don't forget to star the repository!
Follow @textualizeio for Textual updates.
from textual.
Related Issues (20)
- Add indicators for the TabbedContent widget HOT 6
- Scrollbars may trap the mouse if hidden while the user is scrolling HOT 6
- TextArea CTRL-k behavior request HOT 7
- Try/except on all app
- Exception not being raised in tests HOT 4
- `DataTable` scrolling issues with `max-height: 100vh` HOT 4
- Include default CSS in docs? HOT 1
- Hiding a `TextArea` while mouse-based selection is happening can trap the cursor HOT 1
- Different behaviour between CSS and CSS_PATH of Screen HOT 6
- `Placeholder` has no `disabled` `__init__` keyword parameter HOT 5
- TextArea swallows lines after the Undo event HOT 24
- Column and Row Span and Other Features in Data Table HOT 1
- Method to get selection DataTable HOT 1
- Priority binding won't display in the `Footer` HOT 2
- Multiple whitespaces shown in Markdown renders HOT 8
- Custom exception handler/pretty printer exits with code 0 HOT 5
- Button doesn't render Rich Markup correctly HOT 7
- Escape key trigger twice on Windows Terminal HOT 4
- Margin-right does not work properly when RadioSet is present on the screen. HOT 12
- Images in textual
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from textual.