7

I want to build a simple GUI for an app that use bash so for example clicking on a button would execute some bash commands and so one.

There's a GUI creator also simple, i need only buttons and textareas that doesn't require to learn a new programming launguage?

4 Answers4

10

I posted an answer here, that may be useful, for convenience I will just put it here again.

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:

enter image description here

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

There is no form designer for it yet but since the syntax is so simple and so close to zenity, that is not usually a problem.

Sabacon
  • 40,058
7

For simple user-input you can use zenity (lives in the zenity package). A simple example might be something like this:

VARIABLE=$(zenity --entry --title="Give me inputz" --text="Write some stuff")
echo $VARIABLE

For a textarea (as we'd say in the HTML world), you'd change the syntax to something like this:

zenity --text-info --title="Give me inputz" --editable

You can find out a lot more from its manual. It's a very flexible little library user input in simple scripts.

Edit: You can also find some good examples over at Linuxaria.

Oli
  • 293,335
3

Take a look at this: http://sites.google.com/site/easybashgui

You use:

source easybashgui
input 2 "Address" "?" "Name" "?"
cp "$dir_tmp/$file_tmp" "test.txt"
clean_temp
Yi Jiang
  • 1,206
0

Try tkbash.

You can specify elements like this

tkbash 1 button b1 -x 0 -y 0 -w 100 -h 30 -t "click me" --command "notify-send hi"
phil294
  • 589