peterbrittain / asciimatics

A cross platform package to do curses-like operations, plus higher level APIs and widgets to create text UIs and ASCII art animations
Apache License 2.0
3.62k stars 237 forks source link

asciimatics VS python-prompt-toolkit #325

Closed hongyi-zhao closed 3 years ago

hongyi-zhao commented 3 years ago

I want to reimplement the percol based project ariadne. It seems that both python-prompt-toolkit and asciimatics are reasonable candidates, but the former looks like more powerful and popular. Experience in using and comparing the two tools would be greatly appreciated.

Regards, HY

peterbrittain commented 3 years ago

PPT has been around for a very long time and is great for REPL applications. It hasn't been as strong on full screen applications, which is why the community advice for years was to use urwid for that case. It has done more to fill that gap in recent years, though.

Personally, I didn't like the APIs they provided for a full-screen app (which should be able to do more than form input), so wrote asciimatics, but YMMV.

Ultimately, I think the best thing to do is play around with each for a while and see what works best for you.

hongyi-zhao commented 3 years ago

So, the more suitable for my case is urwid or asciimatics. And it seems that the former has a longer history and more feature set than the latter. Am I right?

peterbrittain commented 3 years ago

Just because it has been around longer doesn't mean it's better (think google vs yahoo)...

Obviously, I am biased as the author of asciimatics, but I would use it for any full screen application. :-) To give you some idea of asciimatics' flexibility, look at the examples:

I think you'd struggle to cover that range in urwid.

hongyi-zhao commented 3 years ago

Obviously, I am biased as the author of asciimatics, but I would use it for any full screen application.

By saying full screen application, do you mean it can only work with full screen mode? IMO, most TUI libraries support the resizing function of the terminal window.

I think you'd struggle to cover that range in urwid.

Thank you for show me the power of asciimatics. The most wanted things for my case include but not limited to the following:

I'm not sure whether asciimatics has adequate power/capability for the above requirements.

peterbrittain commented 3 years ago

Re: fullscreen. By fullscreen, I mean an application taking full control of the terminal (like top and vim), rather than just the current line (i.e any standard CLI command like ls, grep, etc). Asciimatics is built for such fullscreen applications and will handle resizes as needed (which you can check by running the examples).

Re your requirements:

Hope that helps!

hongyi-zhao commented 3 years ago

Asciimatics is built for such fullscreen applications

Do you mean full control of the terminal (such as top and vim)?

* I would normally expect that to be handled by your application (e.g. repopulating the contents of a Listbox base on a new filter of your underlying DB).
* The handling of resulting data is down to your application.
* I suspect you need to write your own logic to tokenize and act on the text accordingly.

It seems that all your above comments mean the same thing: doing it with self-developed python code logic and interface it to the curses and TUI supplied by asciimatics.

See the following screenshot of the revised version of ariadne by me, which can give you a preliminary impression about the specific effect I want to achieve:

image

Although I am rather satisfied with ariadne, its underlying library percol has ceased maintenance and the logic used by percol is very quirky and strange to me. So it's difficult for me to further customize and enhance ariadne. This is the motivation I want to reimplement it with a more advanced, modern, and actively maintained curses-supporting TUI framework library.

peterbrittain commented 3 years ago

Do you mean full control of the terminal (such as top and vim)?

Yes.

It seems that all your above comments mean the same thing: doing it with self-developed python code logic and interface it to the curses and TUI supplied by asciimatics.

Yes. TUI frameworks will provide you with ways to simplify common UI features, but don't typically provide integration with other services (e.g. databases).

peterbrittain commented 3 years ago

Looking at percol, it is not just a TUI library; it is a custom coded curses application that provides contextual suggestions of what you might want to type based on what you've already entered. Whichever framework you pick, you will have to extract all the curses code, then integrate the remaining program logic (to build suitable suggestions and act on your selected option) with the framework of your choice.

Some frameworks have autocompletion features, which might give you a leg up, but I doubt they support the types of search percol supports. I'm afraid that Asciimatics can only give you a very basic version with the DropdownList right now. It will need several enhancements to provide a systemic suggestion system.

hongyi-zhao commented 3 years ago

Based on your above comment, as far as the question under discussion is concerned, there seems to be no other python library that suits me better than percol. See here for relevant discussion.

peterbrittain commented 3 years ago

Sadly. Yes. Anything else will require significant reworking of your existing code.

At thi point, I think we can close this issue...