Zenity create a text entry dialog

by Daniel Pham
Published: Updated:
This entry is part 11 of 13 in the series GUI for bash script using Zenity

This article will guide you through create a text entry dialog. This dialog is quite simple, the number of support options of the command is not much so this will be short article and quick guide.

Create a text entry dialog

To create a text entry box, use the --entry option in zenity. The default dialog box will display as the image below.

zenity --entry
Zenity create a text entry dialog
Zenity create default text entry dialog.

The table below show support options for --entry:

OptionMeaning
--text=textSet the text is displayed in the text entry dialog. In the image above, it will replace text “Add a new entry”.
--entry-text=textSet the text is displayed in the entry field of the text entry dialog. Default the entry field is empty.
--hide-textHide the text of the entry field. You can see image below.
zenity --entry --title="WriteBash.com" --text="Demo text for dialog" --hide-text
Zenity create a text entry dialog
Zenity create text entry dialog with options.

You can try using the --entry-text option to see how it works. Text content as you enter the entry field will returned to the command window. Note that the text entry dialog box can only create a single text field.

Bash script create a text entry dialog

Here is the script to create a text entry dialog, the content of the script is quite simple. You just copy it to your computer or your program is okay.

Read moreCreate a form dialog.

#!/bin/bash
# Script author: Danie Pham
# Script site: https://devopslite.com
# Script date: 30-01-2018
# Script use to create a text  dialog by using Zenity

# Function create a scale dialog
f_create_entry () {
    if zenity --entry \
        --title="WriteBash.com Text Entry Dialog" \
        --text="Enter your demo text here:" \
        --entry-text "Demo text"
    then echo $?
        else echo "No text entered"
    fi
}

# Main function
f_main () {
    f_create_entry
}
f_main

exit

Conclusion

This article gives you a quick tutorial on how to create a text entry dialog, which is very simple but will be useful in some cases. Use your imagination to use it to try new things.

(This is an article from my old blog that has been inactive for a long time, I don’t want to throw it away so I will keep it and hope it helps someone).

0 0 votes
Article Rating
Series Navigation«« Previous part: Zenity create a list dialogNext part: Zenity display text in message dialog »»

You may also like

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments

DevOps Lite is a personal blog specializing in technology with main topics about DevOps, DevSecOps, SRE and System Administrator. Articles are shared for free and contributed to the community.

SUPPORT US

FOLLOW US

Subscribe my Newsletter for new blog posts. Stay updated from your inbox!

© 2021-2024 DevOpsLite.com – All rights reserved.

Please write sources “DevOpsLite.com” when using articles from this website.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More

0
Would love your thoughts, please comment.x
()
x

Adblock Detected

Please support us by disabling your AdBlocker extension from your browsers for our website.