Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In zenity forms, how can I set default values (initialize) entries?

Tags:

zenity

I've got a zenity form working, but I can't find any information on initializing the entries. The Zenity help manual webpage doesn't address the issue. For example, the example from that webpage is

#!/bin/sh

zenity --forms --title="Add Friend" \
--text="Enter information about your friend." \
--separator="," \
    --add-entry="First Name" \
    --add-entry="Family Name" \
    --add-entry="Email" \
    --add-calendar="Birthday" >> addr.csv

case $? in
    0)
        echo "Friend added.";;
    1)
        echo "No friend added."
    ;;
    -1)
        echo "An unexpected error has occurred."
    ;;
esac

How would I initialize First Name, Last Name, etc. before displaying the window?

like image 710
Leslie Turriff Avatar asked Mar 04 '14 04:03

Leslie Turriff


1 Answers

Use yad. It's a fork of zenity that I ended up using to overcome this missing functionality in zenity. The key is to use the --form option and include the initial values on the command line after the defined options and parameters. This "extra data" is assumed to be initial values for the fields.

initial_name_data='Jane Doe'; initial_email_data='[email protected]'
yad --form --title='Contact Info' --text='Edit Data' --field=Name --field=Email "$initial_name_data" "$initial_email_data"
like image 120
TonyG Avatar answered Nov 04 '22 19:11

TonyG