Bash – How to create a dialog with multiple text fields using zenity

bashcommand lineguizenity

I want to crate a GUI for some command line programs and I need to get info from multiple text fields e.g. 'Username', 'Password' and a checkbox 'Sign automatically?'.

I need to set particular variables in my script equal to the respective text fields' input by the user e.g. user, pass, login. Also it would have an OK button and a Quit button.

How can I realise this this? I searched online and I was able to find only examples with one text field?

Best Answer

Basically, you can use multi-entry forms using Zenity. A form can be built using text fields, password fields, and calendars. Text fields can be added with the --add-entry flag. Password fields are added with the --add-password flag, and calandars are added with the --add-calendar flag.

 $ zenity --forms --title="Create user" --text="Add new user" \
   --add-entry="First Name" \
   --add-entry="Last Name" \
   --add-entry="Username" \
   --add-password="Password" \
   --add-password="Confirm Password" \
   --add-calendar="Expires"

Zenity form

Here is a tutorial that might help you out.

Related Question