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 want to write shell script file that has a GUI with multiple input boxes for user entry. I already tried zenity. Any ideas or advice would be appreciated.

share|improve this question
1  
This is a great Stack Overflow question. –  djeikyb Mar 20 '11 at 12:35
    
What was wrong with zenity? –  user unknown Mar 20 '11 at 12:58
    
@user unknown ,i cant create multiple input box for user entry –  moata_u Mar 20 '11 at 13:18
add comment

4 Answers 4

Yad may be useful in this regard, it is a fork of zenity with more features, one of them the ability to create forms.

Here is a very simple example of a form:

#!/bin/bash


frmdata=$(yad --title "Test Form" --form --field "Address" --field="Name")


frmaddr=$(echo $frmdata | awk 'BEGIN {FS="|" } { print $1 }')
frmname=$(echo $frmdata | awk 'BEGIN {FS="|" } { print $2 }')

echo $frmaddr > test.txt
echo $frmname >> test.txt

The above script will display a form like this:

Yad Form Example

After you enter your data and click ok or hit enter on the keyboard, the form data will be written to a text file called test.txt, I am using awk to separate the form data which is a string with a pipe as field separator, I believe there is a direct way to get the data without awk but I am no yad expert, please check the project home and ask questions, you may find a more elegant way.

How to get and install yad here:

http://www.webupd8.org/2010/12/yad-zenity-on-steroids-display.html

yad project home:

http://code.google.com/p/yad/

more examples here:

http://technostripe.com/yad-a-fork-of-zenity-with-more-features/

http://code.google.com/p/yad/wiki/Examples

I am late here but this may still be helpful.

share|improve this answer
add comment

xDialog is something similar, here is a search list from freshmeat. tcl/tk is another, popular tool for such jobs.

A poor solution would need the user to fill a list, and finally mark all rows:

zenity --list --text "Fill every row, and mark all rows before hitting 'OK'" --column "title" --print-column=2 --multiple --column "value" --editable "name" "(please override)" "host" "" "ip" ""

I admit, that that's not comfortable.

share|improve this answer
    
..good idea :) –  moata_u Mar 20 '11 at 14:00
add comment

My response might be late (two years late I think) but since a lot of people still searching for the answer to this same question it might be useful. I also search for a "better than zenity/yad/xdialog" solution and I found two very good programs:

  1. gtkdialog: http://code.google.com/p/gtkdialog/ you can build a complete user interface for bash that keeps running while communicating with your backendscript. It is in active developement and is also used by puppy developers. it's own glade-like language is more powerful than libglade, it can run libglade XML however.

  2. gtkserver: http://www.gtk-server.org/ This one goes even a step further and runs as a coprocess while communicating with your bash script via pipes, messages or TCP-ports. It does not work with a XML-typed description file but with GTK-commands that you invoke from the bash commandline. Very powerful indeed :-)

gtkdialog is not in the repositories anymore but you can fins the latest versions in a PPA (https://launchpad.net/~dnjl/+archive/build/+sourcepub/2986274/+listing-archive-extra)

gtkserver has no PPA or deb AFAIK so this has to be compiled from source.

share|improve this answer
    
superb gtk-server –  totti Jan 9 at 10:27
add comment

One solution would to use Zenity, but just display each prompt individually. The first prompt would be for the first field, and then when the user clicks "Ok", you could prompt for the second field.

It sounds like you might be reaching the limits of scripting, and might want to look into developing an application-like interface using something like QT or GTK.

share|improve this answer
    
@Windigo...QT or GTK that's what am thinking about..,but learning curve much more that other's like Zenity –  moata_u Mar 20 '11 at 16:37
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.