Closed guyguy2001 closed 1 month ago
Sorry for the delay, thanks for the detailed report!
Admittedly the snakification of slot names is arbitrary (the only reason it exists is so you can write layout.top_left
IIRC), and it should definitely be documented better (which I will do in a moment).
The whole system is a bit confusing all around, so it's not like you're the first person to have issues with it. I'm not sure what could be done to make it simpler to understand, but for what it's worth it is supposed to be a very static, high level system you only really interact with once per application lifetime. I'll consider these points though, and if you have any changes you feel would make it better (be it in code or documentation) I'm open!
Is your feature request related to a problem? Please describe. Tl;dr:
manager.add(..., assign="Console")
turns the slot name to lowercase, unlike theadd_slot
"constructor", which is unintuitive.I wanted to structure my app with a console at the bottom (like vscode's default), a main screen, and an inventory to the right. I couldn't find in the documentation how to structure my app's layout, but I found this example on reddit - https://www.reddit.com/r/Python/comments/uot805/detailing_pytermguis_brand_new_layout_system/, so I tried applying it to what I understood. I tried running the following code:
But it complained that there was no slot named
Console
:Only by looking at the source (Layout's
__getattr__
) did I find that I had to pass it in lowercase - and not like how I passed the slot name when creating it.In addition, it took me a while to find the
assign
argument - I didn't find it by ctrl-F ing "Layout" in the documentation, although in hindsight I could have found it by looking at the docstringDescribe the solution you'd like Assuming the features I tried to use aren't too low level:
Layout
s (I was heavily overwhelmed by the documentation)manager.add(..., assign=)
and inadd_slot
, or you should have aSlot
object you can call.add
on, or pass it instead of the name toassign=
assign
toslot
would make it clearer - of course it's breaking, and thus probably not feasable.If the layout feature is lower-level than what I needed,
manager.layout
should have a docstring warning of that.There's a very good change I'm missing a lot of the reasons why the current state is good because of how it interacts with the rest of pytermgui, or because layouts aren't supposed to be used by users - but as a TUI beginner trying to jump in by doing, I came out very confused by them.
Describe alternatives you've considered I gave whatever alternatives I thought of in the above section