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?


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" \

Zenity form

Here is a tutorial that might help you out.

  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes.
    – HalosGhost
    Jan 14 '15 at 20:19
  • 1
    Is that better @HalosGhost and if so then can you up vote
    – Jhondoe
    Jan 14 '15 at 20:31
  • This looks much better. However, if you got the idea from the page you linked to originally, you should still include the link as a source reference.
    – HalosGhost
    Jan 14 '15 at 21:04
  • What? <filler text>
    – HalosGhost
    Jan 14 '15 at 21:06
  • I no longer have the link@HalosGhost
    – Jhondoe
    Jan 14 '15 at 21:06

I do not believe you can do this using Zenity. It's meant for simple GUI's and isn't really a full fledged GUI environment. You'll either have to change the flow of your tool or use GTK+ directly to get your desired results.

  • 1
    do you believe the extra functionalities of yad could suffice? as the questioner stated, it is for command line programs, and so, that extra complexity is certainly not required. Nov 29 '15 at 5:35

Try this:

yad --form \
    --field User "" \
    --field Password:H "" \
    --field "Sign Automatically?":CHK FALSE
  • the question have "using zenity"
    – Sérgio
    May 30 at 2:50
  • YAD is a superb zenity fork. Can you solve this question using zenity? Is there a way to put a checkbox on the zenity form? Of course not, but how you can see is very simple to do it using YAD. And that’s why YAD is called zenity on steroids
    – julioneves
    May 31 at 12:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.