Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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?

.

share|improve this question
add comment

3 Answers 3

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.

share|improve this answer
add comment

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 :-)

share|improve this answer
add comment

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"
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.