Overview:
This version primarily focuses on improving the included Widget subclasses and their interactions
-
New module:
pytermgui.widgets.buttonsto store all theButtonsubclassesButton(Widget): Same as beforeCheckbox(Button): A button with a checked and unchecked state, and toggles between themToggle(Button): A button that toggles between two labelsDropdown(Container): Essentially a proof of concept. Will need support for printing lines at custom locations as overlays.
-
Rewrite
Splitter:- Increase stability
- Fix various spacing issues
- Properly inherit from
Container - 2 new
auto()structures - Note: Currently
Splitter-s only really work with widgets of the same height. Check below for more info.
-
Rewrite
InputField:- Inherit from
Label, use itsget_lines() - Support keybinding (more info below)
- Rework styles, support full line styles
- Inherit from
-
Rewrite
pytermgui.cmd:- Use
WindowManagerwith a customApplicationframework - Implement old utilities as
Applicationsubclasses - Support launching a specific app and dumping its output, as well as running as long as the User wants it to
- Use
-
Remove unmaintained widgets:
- Some, like
ProgressBarwill come back in the future.
- Some, like
Details:
Widget.bind(key, action, description)
Assign an action and a description to a dictionary of bindings, which is called by
Widget._execute_binding(key).
key: str- The key that activates the bindingaction: Callable[[Widget, str], Any]- The function that gets calleddescription: Optional[str]- Description of the bindingWindowManagerimplements & handles this, but otherwise the user should implement it.
Splitter()
-
The
auto()method now takes two new forms to create aSplitter(){left: right}-> What used to bePrompt, runauto()on both sides and align them to the outside(item1, item2, item3, ...)-> Shorthand forSplitter(item1, item2, item3, ...)
-
For now, you should use line lists of equal length to display multi-length
Widget-s inSplitter. -
As such, the
itertools.zip_longestmethod is really useful for creatingSplitter-s:from itertools import zip_longest from pytermgui import Container, Splitter left = ["one", "two", "three"] right = ["one", "two", "three", "four", "five"] container = ( Container() + Splitter( *[{lhs: rhs for lhs, rhs in zip_longest(left, right, fillvalue="")] ) )
cmd.py rewrite
- A cleaner implementation, including a whole
Applicationframework - Better cli:
ptg-> openWindowManagerwith all the utilities, exit onCTRL_Cptg --app {MarkApp, Getch}-> launch either of the utilities, dump their output once input has finished
End result
Combining all of the aforementioned changes, this is how ptg looks at the moment:
ok, bye. 🚀
