[HN Gopher] Textual TUI framework for Python adds CSS renderer
       ___________________________________________________________________
        
       Textual TUI framework for Python adds CSS renderer
        
       Author : willm
       Score  : 173 points
       Date   : 2022-10-23 13:35 UTC (9 hours ago)
        
 (HTM) web link (www.textualize.io)
 (TXT) w3m dump (www.textualize.io)
        
       | willm wrote:
       | Textual is a project I started in 2021 to build a TUI framework
       | on top of Rich.
       | 
       | I did a Show HN back in August 21:
       | https://news.ycombinator.com/item?id=28106389
       | 
       | At the time, it was purely a hobby project, but a _lot_ has
       | happened since then. I was VC funded (nobody was more surprised
       | than me) and since January, Textual has been my full-time gig.
       | 
       | This version adds a CSS renderer and more powerful layout engine,
       | which enables some really interesting features such as live
       | editing.
       | 
       | We've also added a websockets based console app for logging,
       | which restores print style debugging when testing your TUI.
       | 
       | This release has documentation. Which you can find here:
       | 
       | https://textual.textualize.io/
       | 
       | Github repository:
       | 
       | https://github.com/Textualize/textual
       | 
       | Textual is still very much a work in progress, but it is way more
       | stable now.
       | 
       | Textualize (the company) is currently 3 developers based in
       | Edinburgh, Scotland. We recently hired dev no.3 and we have a
       | fourth starting this year.
        
         | srcreigh wrote:
         | How will you get money to pay the developers?
        
           | willm wrote:
           | The company was funded with Venture Capital.
        
           | lozenge wrote:
           | I just listened to Will on a podcast, and apparently, they're
           | going to package Python apps with a terminal such as xterm.js
           | to solve the Python distribution problem (either as Electron
           | apps or in the web browser), then have customers host their
           | "TUI" apps on proprietary Textual infra- basically a PaaS. He
           | mentioned charging for features like SSO. The library itself
           | would stay free for offline use and you could "pip install"
           | any Python apps that use it.
        
         | fbdab103 wrote:
         | Really enjoyed the file browser demo.
         | 
         | Ever since I discovered the project, I have been wondering if I
         | could wire it up with something like Pyodide to have a Python
         | based interface that could work on the terminal or the browser.
        
           | pbronez wrote:
           | I think that's their commercialization plan - a hosting
           | service for Textual-based webapps.
        
         | agumonkey wrote:
         | This is a mean upgrade. Bravo.
         | 
         | ps: I didn't follow the latest changes, how is the keybinding
         | aspect ? do you have single keypresses ? or key-sequences ? or
         | even chords ? As an emacs-er I like to have semi-complicated
         | custom keybindings. Anyway just asking, not a ticket :)
        
           | willm wrote:
           | We have a binding system that maps keys to "actions". The
           | idea is that they will eventually be read from a conf file,
           | so you can remap keys.
        
         | quasarj wrote:
         | Man it looks great these days! Only issue is... it turns out I
         | like using the terminal because I _don 't_ have to worry about
         | building a UI, haha.
        
           | [deleted]
        
           | codethief wrote:
           | I would argue all command line tools have a UI, even if it's
           | just a textual one (consisting of command line parameters,
           | maybe a text prompt, or in rare cases even an ncurses
           | interface). When I develop command line tools I _always_
           | think about the UX the user will have.
        
         | z3c0 wrote:
         | Hello Will,
         | 
         | I just wanted to say that rich is a great tool that I'm very
         | appreciative of, and __rich_repr__ is a godsend for debugging
         | datasets without vomiting an overload of text into my terminal.
         | Or consolidating spark's awful, multi-language stack traces.
         | Excellent work. Textual is a lot of fun too, and I've been
         | looking forward to this update. Thank you!
        
           | willm wrote:
           | Cheers. Rich repr has become essential in my workflow as
           | well. It's one of those small quality of life things that
           | makes for one less thing to think about.
        
           | newrotik wrote:
           | Could you elaborate on how you use the tool for the two
           | purposes you mentioned?
        
         | a_t48 wrote:
         | Ah dang, that websockets thing would have been useful a month
         | ago for me. I was trying to forward stdout to a scrollable pane
         | - I initially tried textual but the performance was kinda poor
         | when scrolling. Ended up going with prompt toolkit instead
         | because I could get it to work.
        
           | mixmastamyk wrote:
           | Print log to file, then tail -f in another tab/pane.
        
         | 0xabe wrote:
         | Looks neat. Is there a way for this to be used with C++? Seems
         | like a nice improvement on ncurses.
        
       | viraptor wrote:
       | There's something I can't figure out from the docs/examples. Does
       | textual rely on taking over the terminal, or can I also render
       | static output? I'm thinking of an app that has both batch and
       | interactive mode with only minor differences in the display.
        
       | jacobtomlinson wrote:
       | I've been so excited about this since I tried an early version
       | last year!
       | 
       | I've been playing with the beta and I can't wait to build more
       | things with it.
       | 
       | Thanks for all the hard work folks!
        
       | brianzelip wrote:
       | Recent and informing Changelog podcast with OP and Textual
       | author, https://changelog.com/podcast/511.
        
         | krzysztow wrote:
         | Was looking for this exact comment, or to add it otherwise.
         | Props to the Ship It show from The Changelog!
        
       | [deleted]
        
       | infamousclyde wrote:
       | Looks great. My first reaction to the title was.... "Textual
       | TUI..... As opposed to...?"
        
       | simonw wrote:
       | The new tutorial is fantastic:
       | https://textual.textualize.io/tutorial/
       | 
       | It's worth working through it even if you're not planning to
       | build a TUI app, just to appreciate how well designed the
       | tutorial itself is.
        
       | emj wrote:
       | Have any one seen accessible TUIs for blind users?
        
       | deanc wrote:
       | Textualize (Python) and BubbleTea (GoLang) are really great
       | options for building TUIs. But it seems that the defacto option
       | in the nodejs space has not been updated since 2016 [1].
       | 
       | Are there any TS based TUI libraries that are mature and actively
       | developed?
       | 
       | [1] https://github.com/chjj/blessed
        
       | constantcrying wrote:
        
       | nisegami wrote:
       | I've previously tried using Textual and felt that it wasn't quite
       | ready. From everything I've seen, I think that changes with this
       | release, but I'll have to use it to confirm. Really happy to see
       | it launch! Looking forward to seeing what this inspires.
        
       | tambourine_man wrote:
       | There's something about eking out features that were never
       | intended from a protocol that's fascinating to me. I've seen the
       | smooth scrolling a couple of times by now and it's still hard to
       | believe.
       | 
       | Do you guys have a link showing how you managed to pull those
       | tricks? Smooth redraw and bevels around buttons for instance.
       | 
       | As someone who has drawn my share of simple boxes with scape
       | sequences in the past decades, I'd love to know what you guys
       | figured out that we missed.
       | 
       | Thanks and congratulations.
        
         | willm wrote:
         | Cheers. The boxes use this technique, which I think I may have
         | invented, because I've never see it used elsewhere.
         | 
         | https://www.willmcgugan.com/blog/tech/post/ceo-just-wants-to...
         | 
         | For smooth scrolling, see the first item in this post:
         | 
         | https://www.textualize.io/blog/posts/7-things-about-terminal...
         | 
         | I'm also fascinated that you can _discover_ new things from a
         | protocol, decades old.
        
           | tambourine_man wrote:
           | That's very clever. Thanks for the links!
        
       | pauleveritt wrote:
       | I did a little "unboxing" video: https://youtu.be/WLwVnYb5Adw
        
       | danpalmer wrote:
       | Lots of praise here, well deserved from what I can see.
       | 
       | For those loving Textual, can I ask why you'd use this over, say,
       | a web UI?
       | 
       | There's a joy to using well made libraries and frameworks like
       | this, but apart from that I'm having a hard time justifying this
       | to myself for projects and keen to hear what others are using it
       | for where it's a better fit than other types of UI.
        
         | willm wrote:
         | Works over SSH, low requirements, and cross platform are some
         | good reasons.
         | 
         | Ultimately though, I would like Textual to simply be the
         | easiest way of creating a useful UI. Something that you could
         | quickly become productive in with just Python skills. There are
         | a lot of new Python developers that didn't come from a web
         | background, but still need a custom UI.
         | 
         | I don't see it as replacing web apps. If you have the skills
         | and you think you need a web app, then you probably should make
         | a web app. I see it more as allowing UIs to be built that
         | simply weren't being built before due to a lack of skills or
         | resources.
         | 
         | This may become moot, because we have plans for the same API to
         | also serve web applications.
        
       | samwillis wrote:
       | I think Textual would be amazing tool for building advanced dev
       | tools. As a Python web developer I would love an interactive
       | development server / debugger. Imagine a ui showing all requests
       | to your dev server (normal, Websockets, or long poling / SSE) and
       | being able to expand the details and drill down the stack frames.
       | See the context to your templates. Or being able to pause a
       | request at a break point and step through. Add in the ability to
       | see background tasks in the task queue and have the same level of
       | insight. All interactive from the terminal with a beautiful
       | textual UI.
       | 
       | If only there was more time.
        
       | solresol wrote:
       | I can sort-of see a business model where they host SSH-based
       | applications -- ideally with a Mosh option. As a user, I log in
       | and get a menu of the different applications I am subscribed to
       | that they host, or I can ssh-exec a particular application,
       | perhaps with the option to reconnect to an application that I had
       | open a moment ago. Perhaps being able to text-screen-share so
       | that I can train someone else up would be good (for customer
       | support).
       | 
       | I would expect that this kind of infrastructure would be cheap to
       | support and cheap to run. All the infrastructure is already there
       | in the Linux kernel (or any other Unix-like): just charge me
       | based on my customer's pacct (process accounting) records.
       | 
       | There are a lot of CRUD apps that would be just as good in a TUI
       | as a GUI, and there are a lot of businesses built on CRUD apps.
        
       | xuhu wrote:
       | Can you select multi-line text from a box in a console
       | application, without selecting entire lines ?
        
         | jlokier wrote:
         | iTerm2 (a popular open source terminal emulator for Mac)
         | supports this automatically for all TUI programs, by
         | recognising the box characters. You select multi-line text
         | inside the box and it behaves as if the box is a mini terminal.
         | 
         | I don't know which other terminal emulators have the same
         | feature.
        
         | willm wrote:
         | It's possible. In application mode you don't rely on the
         | terminal's select capability.
        
       | tybirk wrote:
       | Congratulations on the major (minor) release! The docs look
       | absolutely awesome, looking forward to digging into them.
        
       | jmt_ wrote:
       | Every time I look at an update to this library my jaw drops to
       | the floor. Once I find some spare time, I've been meaning to dive
       | into the source code to get a feel for how you're pulling of the
       | marvels that are rich and textualize. I've been "terminal-
       | oriented" for at least a decade now and these frameworks feel
       | like something out of a future I could have never imagined.
       | Seriously impressive work Will, closely following your projects.
        
         | willm wrote:
         | Gracias. Hope you continue to enjoy my stuff. Hope you check
         | out the Textual code. I've tried to make it as readable as
         | possible.
        
       | mr337 wrote:
       | I just wrapped up an internal TUI utility for interfacing with
       | physical hardware. I was really happy with the output until I saw
       | this... Now I got to rework it with the new UI. Very nice work!
        
       ___________________________________________________________________
       (page generated 2022-10-23 23:00 UTC)