dankamongmen / notcurses

blingful character graphics/TUI library. definitely not curses.
https://nick-black.com/dankwiki/index.php/Notcurses
Other
3.61k stars 114 forks source link

extend new python wrappers to cover widgets #1417

Open comotion opened 3 years ago

comotion commented 3 years ago

I don't want to sound too negative, but while notcurses itself seems very promising, the existing python bindings are not very useful. You can draw a character at any part of the screen, but that's about it.

The bindings don't cover any aspects of the library actually useful for creating a user-interface, like menus or lists. Also, there is an inconsistency between the (ppa)-installable bindings and the examples in the repo. It actually looks like the source repository is out of date.

In comparison, rust bindings are complete.

The python bindings should be marked work in progress so people don't get disappointed while attempting to use them.

dankamongmen commented 3 years ago

Fair feedback, and appreciated. Have you tried @igo95862 's alternative Python bindings in notcurses/python as opposed to notcurses/cffi (if you just pulled them from PyPi, you got my old crappy ones).

dankamongmen commented 3 years ago

It's probably time to put some serious effort into #1154, and get @igo95862 's much better wrappers out to the public. I just know very little about Python, and have had difficulties attempting to address the last few issues keeping them from becoming the default (mainly need to reproduce some testing tools and man pages).

igo95862 commented 3 years ago

Sorry, I was not paying much attention. (was focused on my own projects) @dankamongmen do you want to sit down and come up with plan to bring the binds up to speed.

dankamongmen commented 3 years ago

@comotion i'm pretty sure @igo95862 's are waaaaaaaaaaay better than mine, despite mine still being the ones available in e.g. Debian, Redhat, and PyPi. can you give them a spin? if they meet your needs, i'll amp up the effort to make them the defautt.

comotion commented 3 years ago

That explains my confusion as to why python/examples directory did not work on the system installed python3-notcurses package.. they have different function names despite being the same package name! And camelcase looks "newer" than c-style names, so I thought the old one was the new one.

However,

the new bindings still can only get input, move and draw the cursor. In particular, it is missing the simple widgets - lists and menus - that notcurses provides.

dankamongmen commented 3 years ago

alright, i hear you, and am sorry to have let you and the Python community down.

i think @igo95862 's wrappers are a much better place to pick up from than mine. really, the only reason mine are still there is to keep the fedora and debian packages alive until we move to @igo95862 's. i wasn't aware that his were missing widget support.

i think what needs to happen here is twofold:

i can't give you any promises as to when this will get done. as i've said, i'm no python expert, and my focus is much more on expanding and improving the Notcurses core. with that said, i know the Python community is huge, and the source of a lot of TUI application work, and i want to win that community. right now i'm up to my ass in pixel graphics work, but i'll make sure this is attended to sometime in the coming months. in the meantime, patches are always welcome!

igo95862 commented 3 years ago

I think I have a plan.

@comotion Would you prefer dumb binds that copy C API or smart Pythonic ones?

comotion commented 3 years ago

@igo95862 I wouldn't mind either way because I'm just Getting Shit Done™ but I think the Python community would prefer Pythonic APIs, since they wouldn't need/want to learn the C API, and that would make the least number of code statements to create something useful.

We're talking about lists, menus and textboxes, and the easiest way to interact with these from Python is to throw python lists, hashes and strings at them.

dankamongmen commented 3 years ago

so the way my old wrappers (the ones you were initially working) work is that there's a very lowl-level, pretty much automatically-generated set of wrappers, _notcurses, from which lib, ffi can be imported. they actually cover most of the widgets, AFAIK. what you're presumably talking about is the higher-level Notcurses wrappers, written atop these. they're indeed minimal.

i'd always figured it was of some value to have these lowest wrappers, because they were effectively no effort, and that way there was a way to call new features before they got brought into the higher-level Python module. but if i'm hearing you correctly, there's no real value there?

comotion commented 3 years ago

I have limited experience with ffi, and the experience I have is that accessing the library requires so much typing and delving into header files I might as well be writing in C, or putting that effort into creating the wrapper. I am sure there is value there, just not in the "just-wanted-to-easily-write-a-nice-TUI-in-Python" use case I represent here.

igo95862 commented 3 years ago

The issue was I was spending too much time thinking which functions to actually port. There is like 20 ways to put characters on the screen and I had to select one. If I simply copy API 1:1 I would finish much faster.

I think the Rust already does that.

comotion commented 3 years ago

either way would be an improvement :-)

igo95862 commented 3 years ago

Ok. I will work on it this weekend. I have a few ideas.

dankamongmen commented 3 years ago

so the old cffi/ wrappers are now auto-generated, thanks to work by @scauligi , so that ought be available. @igo95862 , did anything come out of this on your end?

igo95862 commented 3 years ago

so the old cffi/ wrappers are now auto-generated, thanks to work by @scauligi , so that ought be available. @igo95862 , did anything come out of this on your end?

Yes, its going to happen soon...

I mostly finished with basic stuff like planes and will do widgets next.