Python ncurses, CDK, urwid difference
Solution 1
What I get after looking at some references is:
- ncurses: It's a free software version of curses, so you have to deal with all kind low-level details.
- pyCDK: It's a higher level library that provides some widgets. I haven't used this one, but according to the sourceforge project page it's been unmaintained for a long time (at least the python binding), so I wouldn't go with this one.
-
urwid: I've used this one and I've to say it's still a little bit low level (it's more a framework than a widget library), but still quite useful and much user-friendlier than curses. As a UI framework it has all the stuff you'd typically expect like widgets, events and a way to control the layout of the widgets. Some things that I'd say are hard with
curses
, but are easy withurwid
are: redraw your widgets when the terminal is resized and gather mouse input (clicking on a button, for example).
So my recommendation would be to use urwid
and if it doesn't meet your needs look for other alternatives.
Solution 2
I haven't used any of the libraries, but I'm assuming that you're referring to:
They're just different libraries with the same goal: provide an API for a console-based UI. From a previous question, it seems that curses
requires more low-level boilerplate. One thing to note is that Python's curses
module is only available under Unix; if you're on Windows, you may want to look at the Console
module written by Fredrik Lundh.
Both of the other choices seem promising as well, although urwid
looks to be more organized as far as development goes, and is still being actively developed somewhat.
Related videos on Youtube
s5s
Updated on June 20, 2022Comments
-
s5s about 2 years
What's the difference between these 3? As far as I understand it they both provide binding to curses which is the C library for terminal text-based UI.
I currently have no knowledge of any of the 3 and I've never used curses. Which one would you recommend? I've heard of ncurses many times but only once or twice about CDK (through research) and never heard of urwid (I think).
-
Vucar Timnärakrul over 9 yearsAlso, Urwid handles Unicode input gracefully, which many other console APIs don’t.
-
Trevor Boyd Smith about 8 yearsI've used a couple of widget-toolkits like C++ Qt4, Java Swing/AWT, C# .Net, python tk... all of these have in common: a library of widgets, containers to hold other widgets, layouts, event loop/async mechanism. The python included
curses
does not have what I would call the basics that I want/need (library of widgets, containers, layouts, event loop mechanism). |||urwid
on the other hand does have the basics (library of widgets, layouts, event loop mechanism). And has very good examples, tutorial, documentation so that you get going quickly.