GUI/TUI linux library

2019-02-05 05:00发布

Is there any UI library that can be to build both a text user interface (ncurses) and graphical user interface (GTK? QT?) from the same source? I know that debconf can be used with various frontends, I would like to build something similar but programmable.

8条回答
我想做一个坏孩纸
2楼-- · 2019-02-05 05:40

By using a library that targets both the text-mode and GUI environments, you have a big risk of getting stuck with the worst of both worlds.

You will be better off structuring your code using the MVC pattern, and providing separate views and controllers for each platform you target. Pushing all the logic down to the model classes has several other benefits:

  • The code will be easier to test because you are forced to keep the user interface out of the actual domain logic.
  • Your program can have user interfaces that have very little in common, e.g. a web UI, or an UI driven by speech.
  • You can run the program easily with no UI at all (i.e. script it) by accessing the model classes directly in the same way that the controller classes do.
查看更多
甜甜的少女心
3楼-- · 2019-02-05 05:43

The library that powers YaST independence to do ncurses, gtk and qt with one codebase provides what you are looking for, and it is not tied to YaST itself.

Actually libyui only requires the standard C++ library and phtreads (IIRC). The UI plugins require of course the respective libraries (Qt, ncurses). YaST uses libyui via a set of YCP bindings that export a YCP like API on top of libyui.

The library is a bit lowlevel (one layer below an event loop), my colleage Klaus Kämpf wrote about using it some time ago in his blog, including binding to scripting languages it using swig.

The only part that is SUSE specific is the packaging, so you would need to package it yourself. Stackoverflow did not allow me to link more than once. The code of the library is linked from Klaus blog. Replace libyui for "qt" and "ncurses" for the plugin's code.

Also google for "YaST Independence From YCP" to find a blog entry from Andreas Jäger on the subject.

查看更多
何必那么认真
4楼-- · 2019-02-05 05:44

There's Cursed GTK, but it seems a bit dated. I found some references to a port of Qt to ncurses called Qt Console, but it seems to have disappeared.

查看更多
Deceive 欺骗
5楼-- · 2019-02-05 05:46

you could write your program to uses ncurses, and then use PDCurses to convert it to an X11 application - as the readme advertise.

I know it because I've used it as portable curses, though I've never tested its X11 capabilities

查看更多
太酷不给撩
6楼-- · 2019-02-05 05:49

Not exactly a library but you could consider writing a web app that degrades well to Lynx

查看更多
唯我独甜
7楼-- · 2019-02-05 05:51

Maybe tcl/tk would provide what you want http://www.tcl.tk/

Here's the page on interfacing with curses. There is a claim there of integration with ncurses.

http://www2.tcl.tk/2372

查看更多
登录 后发表回答