home

Quickies, by Andrea Olivato

text

Zenity dialog. Get the answer from Bash.

This shows how to create a Zenity dialog window and how to get the answer given by user into a Bash variable.

#!/bin/bash

# Creates a Zenity question dialog, 
# similar to JS confirm().
# Put the answer code on a variable.

ANSWER=$(zenity --entry --text "What's your name?" ); echo $szAnswer

# Creates a Zenity popup (information dialog)
# and put there user previous answer

zenity --info --text "Hello ${ANSWER}";

# On the questions dialog you can even set a
# text to be shown on the text field.
# This is like HTML value="" proprierty

ANSWER=$(zenity --entry --text "What's your name?" --entry-text "Type your name"); echo $szAnswer

2 years ago

July 7, 2009
Comments (View)
blog comments powered by Disqus