275 points · by willm · 4y ago · 85 comments
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.
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!
I use __rich_repr__ to make object representations more succinct[1].
This can also be used to make pretty custom exceptions. You can also use rich.Console.print_exception to output formatted stack traces, with options for including locals, suppressing certain errors, or limiting frames[2]. Pretty great for spark, which usually vomits a novella upon erring.
Also, %load_ext rich in a IPython shell to pretty print all output, exceptions or not.
[1]: https://rich.readthedocs.io/en/stable/pretty.html#rich-repr-...
[2]: https://rich.readthedocs.io/en/stable/reference/console.html...
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 :)
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.
I don't mean that as any kind of insult to the people who work on this project -- I'm sure writing it in python is way more pleasant than writing in C. I'm just bummed that projects I have in mind that I intend to write in a language other than python can't use this.
https://youtu.be/Gv2I7qTux7g?t=175
If it doesn't speak the C ABI, someone's gonna rewrite it in C.
I agree with you there. I wonder how it works under the hood, especially those animated panels. I'm gonna go read the source code.
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.
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.
Except...
I'm scared when I think about VC money here. One day someone is going to want a return on that investment and not sure how that will play out.
Imagine if ncurses decide to charge a license fee out of the blue...
Or perhaps more likely in this scenario, one day the framework stops getting updated, then gets rebranded as the community edition, and no longer receives important and/or timely updates.
I'm all for developers making an excellent living, just need to know my own risk factors when investing in tooling and frameworks, etc. It's hard to know here what the future will bring.
Then again, there is no really compelling alternative to this most awesome creation!
If it makes you feel better, we have a runway of years. I'm Scottish and we don't like spending money.
What's the guarantee here?
If only there was more time.
Hooking these two up would make for a neat programming experience. Best of all...if some $$ €€ were involved, it would show Python open source can be sustainable.
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.
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.
Are there any TS based TUI libraries that are mature and actively developed?
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.
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.
SSH is a great option that I hadn't thought of, and that's good to know it works well over it. I have always seen web UIs being inherently easy to share as a benefit over others, but for dev-focused stuff and SSH connection isn't much harder than web access.
I wasn't thinking about full web apps, more things like status pages and other little utilities exposed on an internal server interface. I've built these for software before, and things like Fish Shell have them too. I'm not sure they require much in the way of web skills, but pure-Python would certainly be easier.
I don't know which other terminal emulators have the same feature.
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!
I used Sphinx for years, but mkdocs produces far better docs. Especially when combined with mkdocs-material.
I view it quite differently. Like TSDoc for TypeScript or Ruby-Doc for Ruby, there's Sphinx for Python. Using a general-purpose static site generator for Python docs feels just wrong, like you wouldn't use Wix instead of rustdoc for a Rust crate... But maybe that's just me.
> I used Sphinx for years, but mkdocs produces far better docs. Especially when combined with mkdocs-material.
IMO humans write the docs, not Sphinx or mkdocs, and human approach is what ultimately determines whether the docs are good. From this perspective Textual can absolutely have good docs, and especially since they mentioned Django as the inspiration I'm reasonably sure they will.
However, the use of documentation builder can affect how easy it is to achieve certain niceties: Sphinx with autodoc, for example, offers direct links from docs to implementation and cross-package document linking. The builder can introduce useful syntax sugar and salt: Sphinx+RST, for example, subtly encourages proper "rich" linking to actual Python units rather than using dumb identifiers everywhere (see single backtick behavior in RST vs. Markdown), which in turn forces you to write better docs (you must document units you want to cross-reference or you'll see warnings during doc generation) and think about structuring API in a way that makes it easier to document and maintain that documentation.
(On that note, I haven't seen a project anything that paralleled Django documentation by all metrics, and that one is built using Sphinx.)
So while the docs can be great regardless the choice of a build system in case of Textual IMO still breaks the familiarity pattern for Python documentation readers and contributors, breaks interoperability within Python ecosystem (no links to source or to/from third-party packages), and goes with a more limited markup language than RST for no obvious (to me) reason.
There's a spectrum on this; a lot of stuff in the async ecosystem uses mkdocs (FastAPI, etc.) for example. I'd also argue that Markdown is known by waaaaay more SWEs than Sphinx--I wrote a ton of Sphinx years ago and couldn't even tell you where to start today, but I'm fluent in Markdown because I use it everywhere. That says a lot.
Looking through the Textualize docs [0], they seem pretty good to me? It reminds me of most of the web UI toolkits I've used: components on the left, specific functions of the component you're viewing on the right. I think the advantages to Sphinx you're pointing out aren't super relevant to Textualize.
My day job's in Python, and I spend a lot of time reading through various Sphinx documentation. Sure it's possible to make a great Sphinx site, but most people just add bare minimum docstrings and leave you to figure out the rest. Like you say, people generate docs, and I don't think Sphinx has extra magic that "makes you" generate better ones.
On the contrary, I think something that does help you generate better ones is liking your doc tool. If you're not into Sphinx, you're not gonna be enthused about writing excellent docs in it. If you're into mkdocs, you'll be more motivated to do so. The best exercise is the exercise you'll do, etc. etc.
Every TUI is an enormous hack, legacy piled on top of legacy, trying to twist a simple terminal into a general purpose graphics graphics library. Frankly, a terminal shouldn't support 16 Million colors.
The thing which I really want to exist is a (relatively) simple character based GUI library. Something where "draw this character at x,y in that style", does not rely upon magic chants of escape sequences. And you can lay out a simple GUI based entirely on characters, exactly as if you were creating a TUI, without any of the baggage.