1. Yad Entry
Show an entry dialog.
yad --entry
1.1. --entry-label=TEXT
Set the entry label.
yad --entry --entry-label="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.
yad --entry --entry-label="Label" --entry-text="Type here"
You can also add the --text
option to the dialog and center it.
yad --text-align=center --text="Hello" --entry --entry-label=Label --entry-text="Type here"
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:
#!/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.
#!/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>"
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.
yad --text-align=center --text="Hello" --entry --entry-label=Label --hide-text
If you omit the --entry-text="Type here"
the entry box will be blank.
yad --text-align=center --text="Hello" --entry --entry-label=Label --hide-text
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.
#!/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
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.
yad --entry --numeric
Entering data can be manually typed in.
1.6. --licon=IMAGE
Set the left entry icon.
yad --entry --licon=user-home
Notice the icon justified to the left of the entry box.
If the icon cannot be found the yad icon will be used.
1.7. --licon-action=CMD
Set the left entry icon action.
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.
yad --entry --ricon=user-home
Notice the icon justified to the right of the entry box.
If the icon cannot be found the yad icon will be used.
1.9. --ricon-action=CMD
Set the right entry icon action.
yad --entry --ricon=user-home --ricon-action=thunar
Click on the user-home icon in the entry field to launch thunar.
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
yad --entry --ricon=gtk-clear
Enter Hello World in the entry.
Click on the icon in the entry and the entry is cleared.