10 ms·
Textual is a beautiful Terminal User Interface library in Python
- z3c0 4y agoI really like Textual. I'm very much the TUI type, and upon discovering it, I decided it would be my go-to for interfaces going forward, as - ideally - I'd be able to run the same apps on my desktop as my home server as my cloud servers. Well on the latter two, I realized I had a huge uphill battle, as SSH apparently uses CRLF over LF, and I was finding myself having to rewrite half the library to accommodate that.* And on the former, it occurred to me that I hate everything about Python's asyncio. I'm sure that'll anger some, but sorry, it's terrible, and it doesn't help that every major version deprecates something in favor of something new. [*] Any advice here would be welcome. I can't find much literature on the subject.
- einpoklum 4y ago"half the library" - half of textual, you mean? Also - can you elaborate on how the CRLF vs LF broke your app? Give a code snippet as an example?
- z3c0 4y agoShould've been more clear - I've had to update significant portions of Textual and rich to enable propagating custom line-endings from the top level, but most of the code I touched was in rich. As for the CRLF/LF issue, I paired textual with AsyncSSH, and was successful in making an SSH service hosting the app. However, connecting resulted in a text soup that I initially assumed was the fault of AsyncSSH. After some time, I realized it was due to the line-endings being defaulted to LF by rich (a reasonable decision in any other scenario.) On both points, I'd be happy to share some snippets, but I'm halfway around the world from my home computer currently. If this is more than just a passing interest, I'd be happy to follow up upon my return.
- schemescape 4y agoAre the CRLFs related to Windows? I’ve never encountered them anywhere else…
- z3c0 4y agoSame, but I only run Debian-flavored Linux, so that theory was ruled out pretty quickly. It appears to be a default behavior of pseudo-terminals leftover from the days of yore, when CRLF/LF was still an open debate.
- willm 4y agoI'm not sure I understand your line endings issue. But we've had Textual working over SSH. If you want to post an issue on the repo, I think we could resolve it.
- z3c0 4y agoWill do, thanks!
- benrutter 4y agoI don't really know why this post is appearing now given textual is already at version 2 and not a new thing, but I love love looovve textual. Alongside rich (also from textualize) its one of those rare libraries that I can't find a single thing I'd change in it.
- eddyg 4y agoTextual is fantastic, and with all the recent widget additions, provides functionality on-par with Go's Bubble Tea[0] / Bubbles[1] combo. The Textual blog[2] is a great place to keep up with new features, along with interesting articles about problems encountered (and solved) during development. Incidentally, Textual[3] is also the name of a very popular open-source[4] IRC client for macOS [0] https://github.com/charmbracelet/bubbletea https://github.com/charmbracelet/bubbletea [1] https://github.com/charmbracelet/bubbles https://github.com/charmbracelet/bubbles [2] https://textual.textualize.io/blog/ https://textual.textualize.io/blog/ [3] https://www.codeux.com/textual/ https://www.codeux.com/textual/ [4] https://github.com/Codeux-Software/Textual https://github.com/Codeux-Software/Textual
- guitarbill 4y agoIt's very nice that Textual has a text input widgets. Seems like many TUI libraries have widgets, but lack one to handle text input. So you have to implement this yourself over and over, often forgetting shortcuts people expect (e.g. ctrl+a/e).
- schemescape 4y agoWhat is Ctrl+e?
- drakythe 4y agoJump to the end of the line. Ctrl+a jumps to the beginning. Both of these assume *nix cli and not windows.
- avgcorrection 4y agoEmacs/GNU readline keybinding for jumping to the end of the line.
- billyjobob 4y agoI fell for the hype that Textual always gets on HN and actually used it for a mid-sized commercial app a few months ago. I figured it was a 'safe' choice, given all the developers here who seem to like it, and it was the only TUI library I could find with corporate backing. Here are my notes. 1. Considering it has actual paid developers working on it for quite a while and VC funding, it still lacks a great many features that I took for granted in all the non-commercial TUI libraries, e.g. menus and dialog boxes. 2. The async nature of the library is unpleasant. Can never be sure when/where your code will run. 3. Lots of 'magic' Python variables and methods that you have to override, but there's no way to discover them in your IDE through the type system. 4. Using CSS for laying out a TUI app makes no sense (unless you are a web developer and have Stockholm syndrome from using it for web apps?) 5. It seems to leak memory. Eventually re-wrote the app from scratch using a different library that gets far less hype and spends no time marketing itself. The result was much better in every way.
- stratosgear 4y agoI understand you mean no disrespect to the Textual author, but i would still like to know your comparable alternative...
- pge 4y agowhat library did you end up using instead?
- drakythe 4y agoWould very much like to know about the alternatives, please.
- pmarreck 4y agoSeems like a lot of the negatives are tied to Python.
- danpalmer 4y agoI’m not sure that’s really accurate. I found the API rather unpythonic, with lots of use of magic variables and things. The only criticisms above that really apply to Python are the async nature, and that’s only because getting async right in Python frameworks and libraries is hard, it is possible though, Django being a great example.
- BaculumMeumEst 4y agoi invite you change my view: there is absolutely no reason to fetishize the terminal. it’s a shitty interactive window with needless constraints. anything you can do in a tui can be done better in an actual graphical window.
- deleted 4y ago[deleted]
- ducktective 4y agoone word: latency
- BaculumMeumEst 4y agothat seems dependent on the gui and terminal in question. on windows, a graphical emacs window has less perceptible latency then a terminal window
- ducktective 4y agoAll non-electron terminals have better latency story than cross platform GUIs. Surprised you mentioned Emacs here as it is notoriously laggish in this department.
- BaculumMeumEst 4y agoHave you tried programming in terminals on Windows? I promise you it is horrifying. And my Emacs is pretty stock with native comp.
- aumerle 4y agoYour problem is windows
- danpalmer 4y agoI’d suggest that the proliferation of software with many possible interactions adding features that let you invoke actions via a command-line like interface (see Ctrl+P command palettes etc) prove that there is a place for these sorts of interfaces. Using a mouse is inefficient, and there are only so many hot keys one can assign and learn. I agree that terminals are fetishised a bit, and I personally find a mix of GUIs and terminals to be the most effective combination, but I think there’s something valuable in the interaction pattern.
- fnordpiglet 4y agoWish it had rust bindings
- ducktective 4y agoI mean, it should be the other way around
- riceart 4y ago[flagged]
- lifeisstillgood 4y agoThe top comment is several paragraphs of reasoned comment about the features the poster tried and found lacking in the library If you have experience of the library, which I guess you do to arrive at your conclusion please share it - what was crap about the library. What context was your experience? What could be improved (even maybe the top posters decision - you can't improve it just try something else). Try Harder. Please.
- lazzlazzlazz 4y agoTextual keeps coming up — a perennial favorite on Hacker News. But I have yet to encounter high-quality TUI applications that use it. Why is that? Maybe I've messed them and people can post their favorites.
- nmstoker 4y agoThere's a gallery for Textual: https://www.textualize.io/textual/gallery https://www.textualize.io/textual/gallery And for Rich: https://www.textualize.io/rich/gallery https://www.textualize.io/rich/gallery
- asicsp 4y agoThere's a list here: https://github.com/davep/transcendent-textual https://github.com/davep/transcendent-textual
- wkat4242 4y agoJudging only by the screenshots it feels like this library is embracing the same "modern" design as mobile apps. Huge buttons, lots of whitespace everywhere. I use terminal apps precisely because I want a lot of information density and responsiveness. But perhaps the screenshots are not comprehensive enough to show what it can do.
- Renaud 4y agoI was like you and found out that you can actually remove the extra padding using CSS.
- c-smile 4y ago"Beautiful" is quite subjective... Especially in regard of terminal UI... Or rather beautiful in what sense? Source code, architecture, or what?
- coltens 4y agoAccording to its official website, Textual lets you get a dynamic layout up and running in minutes and refine the UI by tweaking a few lines. It separates the application logic from the presentation layer, making it easier to maintain and test your code. Textual supports UI elements such as buttons, text boxes, and menus.
- fatneckbeard 4y agoi think its very cool but i have to ask a potentially very rude question that is not meant to be rude was not turbo pascal circa 1993 kind of ... easier to use than the text uis we have now?