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

Clarify docs about creating custom widgets #4018

Open
TomJGooding opened this issue Jan 14, 2024 · 5 comments
Open

Clarify docs about creating custom widgets #4018

TomJGooding opened this issue Jan 14, 2024 · 5 comments
Labels
documentation Improvements or additions to documentation

Comments

@TomJGooding
Copy link
Contributor

TomJGooding commented Jan 14, 2024

The guide to widgets in the docs starts with how to create custom widgets, but compound widgets aren't explained until much later.

I think custom widgets are far more likely to be compound widgets rather than basic renderables. so the order these concepts are introduced is confusing. I wonder if this is partly explains the questions about the difference between render and compose, and also why we see so many compound widgets inherited from Static!

The tutorial also uses Static for a compound widget, which confounds this confusion.

@TomJGooding TomJGooding changed the title Clarify confusing custom widgets docs Clarify docs about creating custom widgets Jan 14, 2024
@Textualize Textualize deleted a comment from github-actions bot Jan 15, 2024
@rodrigogiraoserrao
Copy link
Contributor

(Hey Tom, where's the compound widget that inherits from Static? I can't find it!)

I do wonder if we should extract parts of this guide into a new guide that should be named something like “Custom widgets” or “Creating a widget”.
This page could/should open with a description of the two/three main ways of creating custom widgets, and providing some rules of thumb for the reader to determine whether they'll need to use

  1. compound widgets;
  2. the method render; or
  3. the line API.

Then the guide could explain these three methods.

The other sections like the tooltips, border title and subtitle, content size, text links, etc, could be left in this guide.

@rodrigogiraoserrao rodrigogiraoserrao added the documentation Improvements or additions to documentation label Jan 18, 2024
@TomJGooding
Copy link
Contributor Author

(Hey Tom, where's the compound widget that inherits from Static? I can't find it!)

Do you mean in the tutorial?

class Stopwatch(Static):
"""A stopwatch widget."""
def compose(self) -> ComposeResult:
"""Create child widgets of a stopwatch."""
yield Button("Start", id="start", variant="success")
yield Button("Stop", id="stop", variant="error")
yield Button("Reset", id="reset")
yield TimeDisplay("00:00:00.00")

I think what might be confusing some people is that Static has a section in the Custom WIdgets guide, but that's about creating a basic renderable rather than a compound widget. Hope that makes sense.

@rodrigogiraoserrao
Copy link
Contributor

Do you mean in the tutorial?

I thought you were talking about the guide itself. Yeah, there's plenty of Statics in the tutorial.

@TomJGooding
Copy link
Contributor Author

Ah no, sorry to "confound this confusion" (clearly my brain wasn't fully engaged when I wrote that!)

@rodrigogiraoserrao
Copy link
Contributor

I misinterpreted that part, sorry.

Well, the guide could probably be broken up and cleaned up because it has been edited and grown over the past releases and it hasn't grown to be the most usable guide ever.
This task is in our backlog so we'll eventually get there 😝

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants