Giter Club home page Giter Club logo

Comments (6)

kraanzu avatar kraanzu commented on June 22, 2024 1

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.

TomJGooding avatar TomJGooding commented on June 22, 2024

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.

kraanzu avatar kraanzu commented on June 22, 2024

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.

TomJGooding avatar TomJGooding commented on June 22, 2024

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.

rodrigogiraoserrao avatar rodrigogiraoserrao commented on June 22, 2024

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.

github-actions avatar github-actions commented on June 22, 2024

Don't forget to star the repository!

Follow @textualizeio for Textual updates.

from textual.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.