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 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?

share|improve this question
add comment

3 Answers 3

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.

share|improve this answer
    
when i'm usg editable, can i sho others thing like text, buttons, how? –  Matteo Pagliazzi Dec 21 '11 at 15:22
add comment

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.

share|improve this answer
    
wow it seems really cool but i can't find any type of docs... –  Matteo Pagliazzi Dec 21 '11 at 16:08
    
i would like to do something like that dl.dropbox.com/u/1143206/myImage.png, is possible? –  Matteo Pagliazzi Dec 21 '11 at 16:17
    
The developer site at the project home link has a lot of examples, and the developer himself is easy to talk to. –  Sabacon Dec 21 '11 at 16:17
    
Based on the examples and what I have read about Zenity and Yad I believe you can do similar, –  Sabacon Dec 21 '11 at 16:22
    
there are a lot of examples but hey aren't very useful at least for me, anyway now i'm emailing the developer... –  Matteo Pagliazzi Dec 21 '11 at 16:33
show 4 more comments

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
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.