[Linux-aus] GUI programming

Adam Nielsen a.nielsen at shikadi.net
Mon May 22 00:29:27 AEST 2023


> What's the easiest way of doing GUI programming on Linux?  When I Google this 
> I get lots of results about Python programming, Python isn't a language I like 
> or want to learn but I wouldn't rule out using it for simple things if it is 
> much easier than other options.  I would prefer C/C++.

For C/C++ you have to pick a toolkit like Qt, GTK, wxWidgets, etc.  All
of them have their positives and negatives, and all of them require
this toolkit to be installed on the system you want to run the program
on.  If you want to run your final program on a phone, make sure you
can install the toolkit on it before deciding on which one to use.

> What I would ideally like is a system like IBM's VisualAge for C++ on Linux.  
> When using VisualAge C++ on OS/2 I could write a program that had all the 
> basic controls and basic operations on them (EG enter text into an entry field 
> and click a button to have it added to a listbox) without writing any code.

Most of these toolkits now have designers available that let you drag
and drop to develop the UI.  Some are better than others, I suspect
because doing GUIs in traditional languages like C++ is very tedious so
most developers would rather be doing something else.

> For writing a GUI front-end to a server I could design all the screens 
> graphically and then just write C code to copy data between entry fields and 
> API calls.  But I have the impression that no such thing exists for Linux.

If you are talking about API calls then HTML and Javascript starts to be
a viable option, especially based on your next point.

> What I want to do is move many of the things I do on my laptop to a phone and 
> that requires less use of the command-line.  So shell scripts need to be 
> replaced with GUI operations and ssh to run commands on a server needs to be 
> replaced by API use or parsing ssh output for GUI display.

If you're going to run on a phone then it probably has a web browser,
so making a web page in Javascript is likely going to give you the
least painful result.

A web app means you can run on pretty much any mobile device, tablet,
computer, etc.  If you use C++ and a toolkit, it will be difficult to
run on iOS or Android devices as these have different toolkits to a
normal Linux PC - you have to actually write an iOS or Android app,
using whatever lanuages and toolkits the vendor supports.

However if you go the web route, you can write a "progressive web app"
which is basically static HTML and some Javascript, which thanks to a
few extra config files, gets run on your phone as if it's an app you
installed through the app store.  This means you get an icon on the
phone's home screen to launch the app, it runs full screen like a
native app, and with some additional code it can even run offline.

Then you just need to handle the backend (actioning API requests coming
from the GUI elements on the web page) which you could do in C++ if you
wanted, but most people stick with Javascript so the language is the
same in both halves of the system.  On a normal Linux machine you'd use
NodeJS to run the server code.  You may be able to run this on a phone,
or it may be more practical to run it on another machine on your
network.

I spent many years writing GUI code with C++ (on Windows and Linux) and
experimented with Python a bit, but once I realised how much quicker
GUIs are to develop as web sites, I never went back.

There is a lot to learn if you've never done it before, especially to
make a really polished dynamic app using React or similar, but one good
thing about this is that it doesn't take too much to get basic code up
and running and you can expand from there.  There are also many orders
of magnitude more people working on web sites than C++ GUIs, so there's
a lot more information out there and people who can help if you get
stuck.

Cheers,
Adam.


More information about the linux-aus mailing list