1. Yad Entry

Show an entry dialog.

Command
yad --entry
yad entry
Figure 1. A standard entry dialog

1.1. --entry-label=TEXT

Set the entry label.

Command
yad --entry --entry-label="Label"
yad entry label
Figure 2. A entry dialog with a label

You need to use both the --entry and --entry-label=TEXT options.

1.2. --entry-text=TEXT

Set the entry text.

Now we will change the previous example and add --entry-text.

Command
yad --entry --entry-label="Label" --entry-text="Type here"
yad entry text
Figure 3. Dialog with a label and initial text

You can also add the --text option to the dialog and center it.

Command
yad --text-align=center --text="Hello" --entry --entry-label=Label --entry-text="Type here"
yad entry text text
Figure 4. Dialog with a centered text above the entry

When you press enter the "Type here" or whatever text you entered will be parsed. To capture the parsed input you can set the entire dialog to a variable like this:

Code
#!/bin/sh
INPUTTEXT=$(yad --text-align=center --text="Hello" --entry --entry-label=Label --entry-text="Type here")
yad --text="You entered: $INPUTTEXT"

The text accepts markup.

Code
#!/bin/sh
yad --title="Golf Club" --height=200 --width=400 \
    --text="<span foreground='blue'><b><big><big>Please enter your details:</big></big></b></span>" \
    --form \
    --field="<b><big><big>Golflink Number</big></big></b>" \
    --field="<b><big><big>Score</big></big></b>"
yad entry markup
Figure 5. Dialog with markup to change how the text is precented

As you can see the text is now bigger.

1.3. --hide-text

Hide the entry text.

This command allows you to hide the text when you type. EG: Passwords or similar.

Command
yad --text-align=center --text="Hello" --entry --entry-label=Label --hide-text
yad entry hide text
Figure 6. Dialog with hidden text in the entry

If you omit the --entry-text="Type here" the entry box will be blank.

Command
yad --text-align=center --text="Hello" --entry --entry-label=Label --hide-text
yad entry hide text 2
Figure 7. Dialog with hidden text in the entry

You will also notice that you don’t need to add any text to the --hide-text options.

1.4. --completion

Use completion instead of combo-box.

The --completion option searches the data in the script and matches it against your input. Run the script and type b into the entry box. You will be given a choice of three words beginning with b.

Code
#!/bin/sh
yad --title="--completion" --completion \
    --entry="Name:" "" \
    "Abba" "Bark" "Bungy Boy" "Billy" "Charlie" "Delta" "Echo" | \
while read line; do
  ENTRY=`echo $line | awk -F',' '{print $1}'`
  echo $ENTRY
done
yad entry completion
yad entry completion 2

Whatever you choose will become the output.

1.5. --numeric

Use spin button instead of text entry.
Additional parameters in command line treats as minimum and maximum values, step value and precisions (in that order). All this values are optional.
Default range is from 0 to 65535 with step 1.

Command
yad --entry --numeric
yad entry numeric
Figure 8. Numeric dialog

Entering data can be manually typed in.

1.6. --licon=IMAGE

Set the left entry icon.

Command
yad --entry --licon=user-home
yad entry licon
Figure 9. Dialog with a icon on the left

Notice the icon justified to the left of the entry box.

If the icon cannot be found the yad icon will be used.

yad entry licon 2
Figure 10. The icon could not be found so default icon is used

1.7. --licon-action=CMD

Set the left entry icon action.

Command
yad --entry --licon=user-home --licon-action=thunar

Click on the user-home icon in the entry field to launch thunar.

1.8. --ricon=IMAGE

Set the right entry icon.

Command
yad --entry --ricon=user-home
yad entry ricon
Figure 11. Dialog with a icon on the right

Notice the icon justified to the right of the entry box.

If the icon cannot be found the yad icon will be used.

yad entry ricon 2
Figure 12. The icon could not be found so default icon is used

1.9. --ricon-action=CMD

Set the right entry icon action.

Command
yad --entry --ricon=user-home --ricon-action=thunar
yad entry ricon
Figure 13. Dialog with a icon on the right

Click on the user-home icon in the entry field to launch thunar.

Note If icon specified and icon action is not given, click on icon just clear the entry. Numeric fields will ignore the icons.

2. Examples

Here are some more examples of YAD Entry dialog.

2.1. Add a clear icon

Add a icon at right in the entry to clear the entry

Command
yad --entry --ricon=gtk-clear

Enter Hello World in the entry.

yad example 2.1 1
Figure 14. This is how it looks

Click on the icon in the entry and the entry is cleared.

yad example 2.1 2
Figure 15. Result after click on the icon

Back to YAD Guide