Belated happy New Year 2022! In my previous blog post, I wrote about ways to make a text user interface in Linux / Mac / BSD. That's all good and well, but comes with various disadvantages, depending on the method chosen. And if you're running locally, on a machine with a graphical desktop, you might want to have a nice GUI after all.
Now, if your programming language of choice has access to a toolkit such as Tk, then you're all set, in principle. In practice, it can be a lot of work, and arguably overkill for simple scripts. But what else to do? Obviously, there isn't an equivalent of
tput or ANSI escape codes for the desktop -- it's nowhere near so simple. Luckily, other options exist.
As the name suggests, Xdialog is a graphical clone of its text-based counterpart, that tries hard to be compatible (and the other way around). Sadly, its latest version is so old it uses Gtk 1.2! Good luck finding either packaged for a modern Linux distribution.
A more reliable option is Zenity, that's part of Gtk3 and usually preinstalled along with it. It has simplified command line options compared to (X)dialog, but in return features modern controls like a tabular list and desktop notifications. It also makes it much easier to use forms, for example. Plus, certain controls can receive their data on standard input and thus handle a lot more than if it came from the command line. See the official manual and this year-old blog post for how to use it (the manual page is simply insufficient).
Last but not least, there's yad, a fork of Zenity with more controls, more field types and so on. Its last release was more than four years ago, but that's not a problem just yet.
Either of these should be easier to use from more languages than the text-based
dialog, seeing how you don't need to fiddle with temporary files or capturing standard error. And choice is a good thing. Have fun making more software!