gtkdialog – variables

Nils Kassube kassube at
Wed Apr 17 19:13:20 UTC 2013

Johnny Rosenberg wrote:
> I'm experimenting a bit (at level ”beginner”) with gtkdialog and there
> is one thing that I can't figure out.
> I can use variables in dialogues, but I can't use those variables
> ”outside” the dialogue in my script.
> Here's an example, in which the user pick a car and a colour. Of
> course I want to set two variables with the user's choice.

> Now the script:
> #!/bin/bash
> export MainDialog='
>     </vbox>'
> gtkdialog --program=MainDialog

> Running this, selecting ”Citroën” and ”Black” and hitting OK gives the
> following output (at standard out):
> SelectedCar="Citroën"
> SelectedColour="Black"
> However, when trying to use those variables in the Bash part of the
> script, they do no longer exist:

That's how it should be. gtkdialog is an external program that has no 
influence on the variables of your bash script. You could parse the 
output of the gtkdialog - maybe like this untested snippet:

... insert first part of your script here ...
output=$(gtkdialog --program=MainDialog)


More information about the ubuntu-users mailing list