Comments (6)
Out of interest, why are you inheriting from Widget rather than Static?
Well, There's no particular reason but Static
is stated as a widget that holds static content that can be updated.
Widget
is a general name that hints that it's a base class which you can build upon
Plus, the other widgets provided by textual such as Placeholder
, Input
, Button
etc all inherit the base Widget
class. These, I think (inbuilt compound widgets), serve as a great starting point when building complicated widgets
I hope that makes sense.
Also, It's been quite a while since I started building with textual before the documentation was even released so I guess it is also a habit to inherit from Widget
haha
from textual.
If you take a look at the source code for Static
, you'll see there's a shrink
attribute which is set to False.
This shrink
attribute is True by default in the base Widget
class, meaning the renderable will shrink to fill the container. Since your container doesn't have a explicit size, it won't be visible as it will shrink to nothing.
from textual.
I see now, that works! :D
But I was lucky enough to discover that it works with the Static
Widget. Maybe this should be added as a note or warning in the docs?
from textual.
Out of interest, why are you inheriting from Widget rather than Static? Obviously this code is just a MRE which is much appreciated, but it might be useful to understand the context.
The documentation about creating custom widgets does suggest using Static
as a better starting point, although not because of this auto size issue. I think the guide for creating custom widgets could definitely could be improved, so your feedback would be helpful.
from textual.
Like Tom points out, it was the fact that shrink
was set to True
that did this (Widget.shrink
docs: https://textual.textualize.io/api/widget/#textual.widget.Widget.shrink).
None of the other widgets that inherit from Widget
set width: auto
, which is why this one looked different from the others.
Given that the issue of the disappearing content was solved by Tom's comment, I'll close this issue!
from textual.
Don't forget to star the repository!
Follow @textualizeio for Textual updates.
from textual.
Related Issues (20)
- Add tooltips to all input widgets HOT 1
- How to change text background on button click HOT 2
- CancelledError stack trace in terminal after quitting app with Ctrl+C HOT 2
- `on_leave` event being fired by widget in inactive screen HOT 1
- pageup and pagedown bindings not firing on `main` branch HOT 6
- Memray's test suite deadlocks with Textual 0.65.2 HOT 3
- New default key bindings for DataTable override app-defined bindings HOT 3
- priority binding order is not respected in the Footer HOT 3
- Method to add content to Content Switcher HOT 5
- Memray's test suite fails due to a deadlock with Textual 0.67.1 HOT 7
- Possible deadlock with the ToastRack and Tooltip that appeared out of nowhere HOT 3
- Clicking off the Select dropdown causes a crash in `update_focus` HOT 8
- v0.68.0 test_deadlock is failing HOT 12
- Some minor documentation additions HOT 3
- Add Image support using imgcat HOT 6
- Callback is not called when Screen is dismissed HOT 13
- `Tree.select_node` doesn't select the node, it highlights it
- Using standard python logger HOT 1
- Documentation is not up-to-date HOT 3
- Travel back in time to 1900 HOT 1
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.