-
I'm thinking of a design that has a top of view Menu (horizontal) that lets user select primary function. The body consists of
Is this too complex? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Wouldn't be too hard to do by dynamically updating the widgets. There are some limitations (and some bugs) with the library, and the documentation isn't that great. The complexity part comes down to what you want to put in those windows/containers, the left side sounds completely doable with buttons or check-boxes and the right side basically filters content that is displayed from the middle. The majority of the complexity will probably come with what you want to display in the middle, how you want to display it and what features you want to include in the program. If you really want to figure out how some things work in the library then just browse the library files because of the lack of documentation. Textual is another TUI library that's based off of rich but I never got things working with it. They have a list of all the features they have implemented in the library, which is pretty lacking. You can always begin with the ptg boilerplate code and build on top of it if you want. |
Beta Was this translation helpful? Give feedback.
-
I think this shouldn't be impossible, but it's definitely a bit intense :) The layout part is completely doable using the window manager's layout API: with WindowManager() as manager:
...
layout = manager.layout
layout.add_slot("Left", width=0.25)
layout.add_slot("Middle")
layout.add_slot("Right", width=0.25) The updating part shouldn't be too bad either. If you have a couple of slightly custom widget subclasses and store references between them you can implement functions that re-build the widgets. Here is a basic outline for how the left widget would work: class Selector(Container):
def __init__(self, body: BodyWidget, **attrs: Any) -> None:
super().__init__(self)
self._previous_selected: Widget | None = None
self.body = body
self.build() # Your function to build the initial state
def get_lines(self) -> list[str]:
# Currently `get_lines` is the only regularly called function, so we inject the
# child-update code here.
#
# This is likely to change in the next bigger update, but this workaround will
# remain functional.
if self._previous_selected is not self.selected:
self.body.update_state(self.selected)
return lines Then all your As noted by the comment there, the hackiness in this example is something I intend to figure out in the next update. It will introduce a whole new base "containment" widget to replace Feel free to ask if you get stuck with anything! |
Beta Was this translation helpful? Give feedback.
I think this shouldn't be impossible, but it's definitely a bit intense :)
The layout part is completely doable using the window manager's layout API:
The updating part shouldn't be too bad either. If you have a couple of slightly custom widget subclasses and store references between them you can implement functions that re-build the widgets.
Here is a basic outline for how the left widget would work: