Page 1 of 1

What dialog is recommended for writing shell scripts?

Posted: Fri Dec 17, 2021 2:19 am
by wizard

Writing some shell scripts in fossa64 9.5 I find I could use xdialog, gtkdialog or yad. Are there reasons to use one vs another?

wizard


Re: What dialog is recommended

Posted: Fri Dec 17, 2021 3:49 am
by MochiMoppel

Sure, there are reasons because they are all different. Depends on your objectives.
You may also consider gxmessage.

For simple centered entry dialogs I once wrote me a comparison table:

Code: Select all

                 Xdialog       gtkdialog      yad            gxmessage
------------------------------------------------------------------------------
 ENTER=OK      | no           programmable   yes            yes 1)
 ESC=CANCEL    | yes          programmable   default        yes
 centered      | default      optional       optional       optional
 manual resize | yes          yes 6)         no 2)          yes
 auto resize   | no 3)        no 5)          no 4)          no 3)

 1) Only when buttonless
 2) Impossible with -center option. Using -geometry instead of -center may be used as work around.
 3) Work around: Padded label. Window expands to size of label
 4) Work around: same as 3) Manual expand OK, shrink not possible
 5) Work around: same as 3) or using width-chars attribute. Manual expand OK, shrink not possible
 6) Using window-position=1, impossible with -center option

Re: What dialog is recommended

Posted: Fri Dec 17, 2021 5:48 am
by wiak

If the likes of Python not available and just want a simple gui bash utility I'd recommend yad if it provides sufficient functionality for you. It is actively maintained code and well written too.

Personally, nowadays for new app/utilities, I would avoid gtkdialog, which became overly complex at source code level once it was extended from its early versions, and also uses old less secure popen to call commands via /bin/sh (which brings other problems if your underlying shell is not bash but your shell script driving the gtkdialog section is written using bash functions, as it often will be - such code will simply not work if system shell is ash or dash for example). Some other distros (Slitaz I believe once also relied on gtkdialog, but abandoned it since no longer very actively maintained (Puppy tries...). Some Puppy enthusiasts continue to develop bash/gtkdialog apps, however, but I doubt the longterm value in such effort.

The problem is that yad does not provide such functionality as gtkdialog and it is hard to find something as an alternative aside from more complex dev frameworks such as iup/Lua or Python with some GUI-creating mechanism.

So, not a 'dialog' type solution, but depends what you are trying to do. So if you want more than that yad/gtkdialog/dialog/gxmessage kind of mechanism (which it seems you don't):

Depends if your system has Python available without having to sfs-load it I suppose. A good Python 3 installation certainly provides all the functionality (if GUI widget handling mechanism included) and I wrote about a couple of interesting options using that here:

viewtopic.php?p=32244#p32244
which enthuses about PySimpleGUI and thereafter Kivy. My nine year old son played with both of these and the final winner is Kivy, which is a really sophisticated GUI app writer (via Python scripts) - not particularly tiny to install, and not on most Pups by default unfortunately - should be IMO though. My son has proved to me that it is easy to learn and use even for a novice like him. PySimpleGUI is much more limited, a small install, but pretty good too within its limitations - both better than gtkdialog anyway... but, yes, requires Python. Learning Python is useful, in terms of becoming a more experienced programmer, anyway though; wish I had more time to do that kind of work, but nowadays I don't.


Re: What dialog is recommended

Posted: Fri Dec 17, 2021 11:02 am
by snoring_cat

Lately, I see a lot more yad development versus gtkdialog. To me, yad is easier to produce an app, and can do about 90% of UI layout as gtkdialog, Glade, etc. For example, you cannot put notebook widgets inside notebook widgets. Also, a top pull-down menu widget doesn't exist.


Re: What dialog is recommended

Posted: Fri Dec 17, 2021 11:14 am
by dimkr

yad has GTK+ 2 and GTK+ 3 versions, which are slightly different, and it's very easy to use.

gtkdialog (https://github.com/puppylinux-woof-CE/gtkdialog) has supports GTK+2 and GTK+ 3 (with good backward compatibility) and even has support for things like overlay or background layer windows under Wayland, so it's more future-proof than the other options. Also, it has the biggest number of examples, because it's the most widely used solution in Puppy.

xdialog is GTK+ 2 only, and unmaintained. I think it should be avoided.

If you need something simple like a single widget or a question with yes/no buttons - yad is good enough, otherwise I'd recommend gtkdialog.


Re: What dialog is recommended

Posted: Fri Dec 17, 2021 11:59 am
by MochiMoppel
dimkr wrote: Fri Dec 17, 2021 11:14 am

xdialog is GTK+ 2 only, and unmaintained. I think it should be avoided.

Xdialog is installed in all Puppies - unlike yad.
This and the fact that it hasn't been maintained since 1999 makes it a good choice when backward compatibility is crucial.
It's simple to use, and if it works for you, you can be pretty sure that it works everywhere ... as long as GTK+2 support continues.


Re: What dialog is recommended

Posted: Fri Dec 17, 2021 12:07 pm
by snoring_cat
MochiMoppel wrote: Fri Dec 17, 2021 11:59 am
dimkr wrote: Fri Dec 17, 2021 11:14 am

xdialog is GTK+ 2 only, and unmaintained. I think it should be avoided.

Xdialog is installed in all Puppies - unlike yad.
This and the fact that it hasn't been maintained since 1999 makes it a good choice when backward compatibility is crucial.
It's simple to use, and if it works for you, you can be pretty sure that it works everywhere ... as long as GTK+2 support continues.

Please clarify. Yad is currently being developed and supported.


Re: What dialog is recommended

Posted: Fri Dec 17, 2021 12:18 pm
by MochiMoppel
snoring_cat wrote: Fri Dec 17, 2021 12:07 pm

Please clarify. Yad is currently being developed and supported.

The topic was Xdialog.


Re: What dialog is recommended

Posted: Fri Dec 17, 2021 12:33 pm
by dimkr
MochiMoppel wrote: Fri Dec 17, 2021 11:59 am

It's simple to use, and if it works for you, you can be pretty sure that it works everywhere ... as long as GTK+2 support continues.

GTK+ 2 is out of support, and applications that don't support GTK+ 3 or later are on the way out of Puppy (https://github.com/puppylinux-woof-CE/w ... ssues/2617). I think it will take at least a year until there's a Puppy release with zero traces of GTK+ 2.

If Xdialog gets the job done, you can use it, but if you can achieve the same effect with something more future-proof, I think it's a good idea.


Re: What dialog is recommended

Posted: Fri Dec 17, 2021 5:14 pm
by fredx181
dimkr wrote:

If you need something simple like a single widget or a question with yes/no buttons - yad is good enough, otherwise I'd recommend gtkdialog.

With yad you do a lot more than "single widget or a question with yes/no buttons", think of --form --notebook --icons --list etc...
But yes, gtkdialog is much more advanced for creating a complex GUI, personally I find it more difficult though (but that depends on how much experience).


Re: What dialog is recommended

Posted: Sat Dec 18, 2021 1:01 pm
by MochiMoppel
dimkr wrote: Fri Dec 17, 2021 11:14 am

gtkdialog (https://github.com/puppylinux-woof-CE/gtkdialog) has supports GTK+2 and GTK+ 3 (with good backward compatibility) and even has support for things like overlay or background layer windows under Wayland, so it's more future-proof than the other options.

Is gtkdialog really still maintained? By whom? Though Thunor added GTK3 support 8 hears ago before he apparently left the project this doesn't mean that everything works fine under GTK3. I'm a bit worried about the fate of gtkdialog. It's an ugly beast only a mother could love but yad is just too limited to fill the gap.


Re: What dialog is recommended for writing shell scripts?

Posted: Sat Dec 18, 2021 2:48 pm
by rockedge

gtkdialog is not maintained I think. Void Linux has completely removed it from their repos and I have been adding it to Kennel Linux and WeeDogLinux using the SFS file @wiak created that supplies it and loading it at boot. This way I can use mm_viewme still on all of my WDL-Void and KLV-Airedale distro builds.


Re: What dialog is recommended

Posted: Sat Dec 18, 2021 3:17 pm
by dimkr
MochiMoppel wrote: Sat Dec 18, 2021 1:01 pm
dimkr wrote: Fri Dec 17, 2021 11:14 am

gtkdialog (https://github.com/puppylinux-woof-CE/gtkdialog) has supports GTK+2 and GTK+ 3 (with good backward compatibility) and even has support for things like overlay or background layer windows under Wayland, so it's more future-proof than the other options.

Is gtkdialog really still maintained? By whom? Though Thunor added GTK3 support 8 hears ago before he apparently left the project this doesn't mean that everything works fine under GTK3. I'm a bit worried about the fate of gtkdialog. It's an ugly beast only a mother could love but yad is just too limited to fill the gap.

GTK+ 3 support works well, and backward compatibility is good thanks to https://github.com/puppylinux-woof-CE/gtkdialog/pull/92. The most commonly used widgets dropped in GTK+ 3 have a very close equivalent, and gtkdialog now does this replacement at runtime. 90%+ of old gtkdialog based tools work just fine, with zero changes.

It's a pretty big codebase, that's true, but I don't think it's a huge problem for two reasons. First, most gtkdialog users use a subset of its features. Second, under the puppylinux-woof-CE umbrella, gtkdialog gained a new build system, fixes for build failures, and some Wayland-specific features, so it's already in much better shape compared to 8 years ago (GTK+ 2 was deprecated even then).

https://github.com/puppylinux-woof-CE/gtkdialog/pull/90
https://github.com/puppylinux-woof-CE/g ... g/pull/102
https://github.com/puppylinux-woof-CE/g ... g/pull/104

An unmaintained project is a problem only if there's something that you want to change about it, and can't. I don't think this is the case here.

EDIT: forgot to say - personally, I don't like gtkdialog and prefer yad. But sometimes yad's command-line becomes super long and the ugly XML (and I hate XML) you need to write with gtkdialog is easier to work with. yad can be pretty powerful, but sometimes it's harder to work with and there's not enough documentation with examples.


Re: What dialog is recommended for writing shell scripts?

Posted: Sun Dec 19, 2021 2:48 am
by MochiMoppel
rockedge wrote: Sat Dec 18, 2021 2:48 pm

gtkdialog is not maintained I think.

The answer by @dimkr seems to confirm this. On the other hand I see that he and other members still apply palliative care for this patient. A glimpse of hope.

I can use mm_viewme still on all of my WDL-Void and KLV-Airedale distro builds.

Using GTK 3? If so you would experience that it does not work as it used to work under GTK 2. Expanding the window would expand also the left chooser widget, not just the right viewer pane. GTK 3 may ignore dimension settings. Very annoying.


Re: What dialog is recommended for writing shell scripts?

Posted: Sun Dec 19, 2021 3:23 am
by wiak

As will happen, as it did with GTK1, the time will come when we don't want GTK2 on our systems. So to keep old gtkdialog apps running, best we could have is GTK3 version. What I don't like, moreover, with palliative care is that it may not go on forever - GTK4 will sooner or later replace GTK3 and so on - the danger therefore is that gtkdialog will end up not supported in any shape or form and issue with that is the time that developers of utility apps put into their works. That's why I'd recommend trying to use alternatives like yad and so on - and if yad not enough move to something bigger that is well-supported by large developer teams (like Python Kivy) - at least then work will not be wasted; some app/utils may not be easy to convert from gtkdialog form so better to not use it for new work in my opinion.


Re: What dialog is recommended for writing shell scripts?

Posted: Sun Dec 19, 2021 6:19 am
by dimkr
wiak wrote: Sun Dec 19, 2021 3:23 am

GTK4 will sooner or later replace GTK3 and so on

This is misleading.

I think GTK+ 2 should be avoided because it's unmaintained, because GTK+ 2 applications look out of place today, when almost everything else uses GTK+ 3, and because it doesn't support Wayland. You can use it, but be prepared for visual inconsistency (themes that don't support GTK+ 2, different font rendering settings, etc'), and accept the fate of being stuck with Xwayland forever. A year or two from now, when you switch to Wayland after the rest of the world, you'll get a horrible user experience.

GTK+ 3 still receives bug fix releases, many applications (including the major browsers) still use it and it supports Wayland (so there's no immediate reason to change to GTK+ 4).

I don't think GTK+ 3 is going to reach its end-of-life anytime soon.


Re: What dialog is recommended for writing shell scripts?

Posted: Wed Dec 22, 2021 1:13 pm
by step
wizard wrote: Fri Dec 17, 2021 2:19 am

Writing some shell scripts in fossa64 9.5 I find I could use xdialog, gtkdialog or yad. Are there reasons to use one vs another?

wizard

In my scripts I use both gtkdialog and yad. If you have enough time to try both programs you will understand where one excels vs the other. I prefer gtkdialog when I know my UI needs to be custom, dynamic and reactive to events other than keyboard and mouse. I prefer yad when I know that my UI is more "standardized", meaning, it's one of the dialog types 90% of applications is made of: an OK/cancel message box; a simple text entry (including by-row and by-column forms, a print dialog, a file open dialog, etc.) With gtkdialog you can build most standardized dialogs as well, but with yad it's easier and faster. Lastly, in some scripts I use gtkdialog _and_ yad, the right tool for the job. In that case I use gtkdialog for the main UI, and yad just for some sub-functions.