textual icon indicating copy to clipboard operation
textual copied to clipboard

Clarify docs about creating custom widgets

Open TomJGooding opened this issue 2 years ago • 7 comments

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 avatar Jan 14 '24 23:01 TomJGooding

(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 avatar Jan 18 '24 15:01 rodrigogiraoserrao

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

Do you mean in the tutorial?

https://github.com/Textualize/textual/blob/95f0c39106e0a53d028e36730a06747eeefff8c0/docs/examples/tutorial/stopwatch02.py#L10-L18

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.

TomJGooding avatar Jan 18 '24 15:01 TomJGooding

Do you mean in the tutorial?

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

rodrigogiraoserrao avatar Jan 18 '24 15:01 rodrigogiraoserrao

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

TomJGooding avatar Jan 18 '24 17:01 TomJGooding

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 😝

rodrigogiraoserrao avatar Jan 18 '24 18:01 rodrigogiraoserrao