7

I need to present some text along with the items(about 15 values) for each of two Bash list(file) records. On the same screen I need to present a three way selection, (buttons, scrolled selection window, etc.).

I'm an Ubuntu(11.04) scripting noob just beginning to use Zenity in scripts. My friends suggested YAD.

Can I do all of that in YAD or use some other easy GUI tool unknown to us?

.

4 Answers 4

2

Here's a very minimal implementation in Yad.

A textfile named 'mylist' in the same directory as the script contains "1 2 3 4 5 6 7 8 9 10". A space character is the default delimeter for input into lists.

The example script is:

#/bin/bash
thelist=$(<mylist)
thechoice=$(yad --title="Choose a value" --width=200 --height=200 --list --column="Values" --separator="" $thelist)
exit $(yad --title="You chose..." --text=$thechoice)

That's it. Scrolling the list is handled automatically. The --separator="" is to supress Yad's default of appending a pipe character ("|") to the output.

When you read the man page, you will see that you have a large array of possibilites. You can add buttons, icons, radio buttons, etc. You can create tabbed dialogs by using Yad's Notebook feature to embed dialogs within other dialogs as plugins.

There's a long example at PCLinusOS mag and some interesting shorter examples at the Yad site.

2

for simple dialogs Yad or kdialog are indeed the most featureful. A complete GUI for bash, however, can only be done by two programs I know of:

gtkdialog (https://code.google.com/p/gtkdialog) will give you a full fledged frontend for single programs and is probably what you are looking for in the first place if yad turns out to be not enough for your needs.

The other one is gtkserver (http://www.gtk-server.org) which is a seperate running GUI-server. Your bash application can communicate with it by means of pipes, messages or TCP-sockets which is quite convenient if you are planning a complex setup of scripts/applications with a single central interface. I think that it will be a bit over the top for your current project :-)

1

Some Zenity examples, just in case someone wants to stick with it.

This will create a "Hello world" message box:

zenity --info --text "Saluton mondo"

This will create a list populated with the output of ls:

ls /var/log | zenity --list --column="Files and directories"
1

Here is a very nice example, how to create a zenity dialog with multiple inputs.

enter image description here

Different UI types (Checkbox, Date, Colorpicker, etc) are documented here.

and as far as I can tell: zenity is installed out of the Box in Ubuntu 20.04 and larger.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .