[HN Gopher] Show HN: A modular Python TUI framework with a fast ...
       ___________________________________________________________________
        
       Show HN: A modular Python TUI framework with a fast and pretty
       markup language
        
       PyTermGUI is a highly modular framework offering most of the
       features one would expect from a GUI library, such as a mature and
       open Widget API, animations, mouse support and other goodies, right
       inside the terminal!  The markup language is another great feature
       of the library, and is used by practically all elements of it. It
       is based on Rich's implementation, but uses a more concise and
       easier to humanly parse syntax, while being over 10 times faster at
       parsing due to a long list of optimizations.  There is a full
       Window Manager API included as well, allowing the user to move,
       resize and otherwise manipulate windows and inner contents using
       either their mouse of keyboard.  All of the "guts" of the library
       are also exposed and usable from the outside within the
       `ansi_interface` submodule.  Thank you for your time, and I hope
       the library may be of some use!
        
       Author : bczsalba
       Score  : 43 points
       Date   : 2022-03-01 17:46 UTC (5 hours ago)
        
 (HTM) web link (github.com)
 (TXT) w3m dump (github.com)
        
       | petercooper wrote:
       | I'm really impressed by the resizing and dragging. Works fine
       | with my relatively vanilla terminal when a lot of advanced things
       | don't. I've never seen an app make use of this feature so far.
        
         | bczsalba wrote:
         | Thank you! As long as the terminal supports the xterm-256
         | colors everything should work alright, and even below that the
         | colors might look a bit off but nothing should _break_ , per
         | se.
         | 
         | The resizing bit was a bit of a mess to implement properly, but
         | the current system does things like calculate the predicted
         | minimum width of a window and not letting you minimize further,
         | among other things.
        
       | eterps wrote:
       | What are good examples of well known TUI applications that would
       | be a good fit using frameworks like this?
       | 
       | Most TUI apps I use do no involve space consuming borders,
       | buttons, interactive dragging/resizing etc. That's also precisely
       | why I prefer TUIs for some apps, to not be dependent on those
       | features and navigate by shortcut keys instead.
        
         | bczsalba wrote:
         | At the moment not many, but full-screen layout support is
         | planned. The eventual "end-state" of the framework would be
         | something along the lines of MC, where there is a main,
         | fullscreen display that contains a bunch of inner elements.
         | These inner elements would then create modal windows, allows
         | user input and display data as needed. Only difference from MC
         | and the like is in this case the windows aren't just things
         | that _look like_ windows, but they actually act and behave like
         | it too.
         | 
         | Fair question though! WindowManager honestly started off as a
         | joke with my friend, and just so happened to end up being the
         | main "entry point" to the library. In the future pre-defined
         | (or even dynamic) layouts should allow the above mentioned to
         | happen when needed, but also keep all the optional mouse input
         | shenanigans working as intended.
         | 
         | Edit: One thing that I think can showcase some of the upsides
         | an architecture like this has is an ongoing project of mine
         | based on PTG, https://github.com/bczsalba/Pagoda. It is
         | primarily a frontend for a WIP messaging protocol me an my
         | friend are creating, but the main idea behind it is the chat
         | functionality is all confined within an "application", and that
         | the user can write and install their own applications to be run
         | from within Pagoda. This kind of makes the system feel like a
         | proper desktop WM, and I think is a really cool idea. As the
         | project is still very early the only available app is the
         | messaging one, but I do have high hopes for it, if nothing else
         | as a tech-demo for what PTG can do.
        
       | zvr wrote:
       | Very impressive! Congratulations, it looks great and pretty
       | complete.
       | 
       | Any idea why the getch demo does not report the Escape key?
        
         | bczsalba wrote:
         | Thank you!
         | 
         | IIRC it used to work just fine, but it hasn't for a minute.
         | There is some weird handling with ESC, as most of the time it
         | is the start of a longer sequence, so I probably just messed
         | something up in that while refactoring.
         | 
         | Will look into it when I have the time, thank you!
        
       | inshadows wrote:
       | No mneonics... All of this Python TUI stuff wastes pixels with
       | 80's technology screen rendering and yet it doesn't have the only
       | thing that still makes TUIs good: fast keyboard navigation. And I
       | don't mean Tab-ing and arrow-ing your way to the button, let
       | alone mouse clicking. I that C or Alt-C presses button with label
       | "[C]ancel". Try to play with Midnight Commander to see. Also not
       | saying that it's not possible in GUI but usually GUIs are not
       | designed with keyboard in mind, while TUIs should be.
       | 
       | EDIT: GUIs had tradition of having mnemonics in menus and
       | sometimes even on buttons. That is until smart people started
       | removing it in the name of the design.
       | 
       | EDIT: Still, will check it out, though I will try to hack my way
       | into adding mnemonics to buttons. Because arrow/tab navigation is
       | f-ing stupid.
        
         | [deleted]
        
         | bczsalba wrote:
         | There is a pretty in-depth binding system that allows for the
         | exact behaviour you are describing. This library is generally a
         | framework with a loose implementation in the name of
         | WindowManager. Most of these behaviours can and should be
         | implemented in applications using this framework.
         | 
         | About "wasting pixels"... What if I (and many others) like the
         | aesthetic and simplicity? There is a sort of magic in never
         | having to leave your terminal emulator. Most frameworks _are_
         | still keyboard-centered, as many of them don 't even have mouse
         | support to replace it with.
         | 
         | Edit: Thank you for your interest though! If you have a
         | syntactically neat way to do the things you talked about feel
         | free to raise an issue and I'll get to it as it comes up.
        
       | [deleted]
        
       ___________________________________________________________________
       (page generated 2022-03-01 23:01 UTC)