YAD - Tips
YAD - Tips
As there is not a lot of information/documentation about YAD I thought this might be a good place to help create some.
Zigbert started a thread called gtkdialog - tips on Thu Feb 12, 2009 3:32 am.
This has been a great resource to many and the contributions have been outstanding. I personally have visited that thread many times.
I know there are many people using YAD as it's quite easy to use albeit the lack of documentation.
I have been working on a YAD document for quite some time so I thought I would share it here and maybe some of you may be able and willing to help me complete it. I have used Notecase to capture the information.
You can obtain a copy of my efforts here:
http://smokey01.com/help/yad-tips-0.0.1.ncd.tar.xz
I hope you find it useful.
Enjoy.
Zigbert started a thread called gtkdialog - tips on Thu Feb 12, 2009 3:32 am.
This has been a great resource to many and the contributions have been outstanding. I personally have visited that thread many times.
I know there are many people using YAD as it's quite easy to use albeit the lack of documentation.
I have been working on a YAD document for quite some time so I thought I would share it here and maybe some of you may be able and willing to help me complete it. I have used Notecase to capture the information.
You can obtain a copy of my efforts here:
http://smokey01.com/help/yad-tips-0.0.1.ncd.tar.xz
I hope you find it useful.
Enjoy.
- rg66
- Posts: 1158
- Joined: Mon 23 Jul 2012, 05:53
- Location: Vancouver, BC Canada / Entebbe, Uganda Africa!?!
This page has a little better explanation of help and has a notebook example as well. http://rpm.pbone.net/index.php3/stat/45 ... /nazwa/yad
X-slacko-5b1 - X-tahr-2.0 - X-precise-2.4
[url=http://smokey01.com/rg66/]X-series repo[/url]
[url=http://smokey01.com/rg66/]X-series repo[/url]
- rg66
- Posts: 1158
- Joined: Mon 23 Jul 2012, 05:53
- Location: Vancouver, BC Canada / Entebbe, Uganda Africa!?!
Here's a tip for drag and drop
pipe it to sed 's/^.......//' to get a proper path
Code: Select all
# yad --dnd
file:///root/Desktop/tmp
Code: Select all
yad --dnd | sed 's/^.......//'
/root/Desktop/tmp
X-slacko-5b1 - X-tahr-2.0 - X-precise-2.4
[url=http://smokey01.com/rg66/]X-series repo[/url]
[url=http://smokey01.com/rg66/]X-series repo[/url]
rg66, are you able to solve this puzzle for me.
I want to be able to use the value of the selected items in the following script and use the variables with an external application.
How do I assign variables so the last echo statement at the bottom of the script works?
Thanks
I want to be able to use the value of the selected items in the following script and use the variables with an external application.
Code: Select all
#!/bin/sh
names=$(echo "Bill,George,Jack,Joe")
occupation=$(echo "Doctor,Dentist,Butcher,Baker,Candlestick Maker,Other")
yad --title="Names" \
--form --separator="," --item-separator="," \
--field="Names:":CB \
--field="Occupation:":CBE \
--field="Comments:":TXT \
"$names" "$occupation" "Type your comments here"
echo
echo "(The selected name) (Selected occupation) (Comments)"
echo
echo
echo $name,$occupation,$comments
Thanks
- rg66
- Posts: 1158
- Joined: Mon 23 Jul 2012, 05:53
- Location: Vancouver, BC Canada / Entebbe, Uganda Africa!?!
Not quite sure what you're after but maybe you can use something from these scripts to get what you want.
Or
Or
Code: Select all
#!/bin/sh
names=$(echo "Bill,George,Jack,Joe")
occupation=$(echo "Doctor,Dentist,Butcher,Baker,Candlestick Maker,Other")
yad --title="Names" \
--form --separator="," --item-separator="," \
--field="Names:CB" \
--field="Occupation:CBE" \
--field="Comments:TXT" \
"$names" "$occupation" "Type your comments here" | while read line; do
NAME=`echo $line | awk -F',' '{print $1}'`
OCCUPATION=`echo $line | awk -F',' '{print $2}'`
COMMENT=`echo $line | awk -F',' '{print $3}'`
echo "(The selected name) (Selected occupation) (Comments)"
echo
echo
echo $NAME $OCCUPATION $COMMENT
done
Code: Select all
#!/bin/sh
names=$(echo "Bill,George,Jack,Joe")
occupation=$(echo "Doctor,Dentist,Butcher,Baker,Candlestick Maker,Other")
yad --title="Names" \
--form --separator="," --item-separator="," \
--field="Names:CB" \
--field="Occupation:CBE" \
--field="Comments:TXT" \
"$names" "$occupation" "Type your comments here" > /tmp/config
NAME=`cat /tmp/config | awk -F',' '{print $1}'`
OCCUPATION=`cat /tmp/config | awk -F',' '{print $2}'`
COMMENT=`cat /tmp/config | awk -F',' '{print $3}'`
#echo $NAME $OCCUPATION $COMMENT #this would have to be run first to work properly with copy/paste into term, in a script it works ok
echo "(The selected name) (Selected occupation) (Comments)"
echo
echo
echo $NAME $OCCUPATION $COMMENT
Code: Select all
#!/bin/sh
names=$(echo "Bill,George,Jack,Joe")
occupation=$(echo "Doctor,Dentist,Butcher,Baker,Candlestick Maker,Other")
yad --title="Names" \
--form --separator="," --item-separator="," \
--field="Names:CB" \
--field="Occupation:CBE" \
--field="Comments:TXT" \
"$names" "$occupation" "Type your comments here" | while read line; do
echo "NAME='`echo $line | awk -F',' '{print $1}'`'" > /tmp/config
echo "OCCUPATION='`echo $line | awk -F',' '{print $2}'`'" >> /tmp/config
echo "COMMENT='`echo $line | awk -F',' '{print $3}'`'" >> /tmp/config
done
Code: Select all
# other script
#!/bin/sh
. /tmp/config
echo "(The selected name) (Selected occupation) (Comments)"
echo
echo
echo $NAME $OCCUPATION $COMMENT
X-slacko-5b1 - X-tahr-2.0 - X-precise-2.4
[url=http://smokey01.com/rg66/]X-series repo[/url]
[url=http://smokey01.com/rg66/]X-series repo[/url]
Thanks rg66.
Your first example does exactly what I want.
I will include all of your examples in my tutorial as they are all very useful.
I have already included the other tips you suggested earlier.
After a bit more editing I will release the next version.
It sure has been a challenge locating information on the usage of YAD.
I'm surprised more people haven't chimed in.
Thanks again.
Your first example does exactly what I want.
I will include all of your examples in my tutorial as they are all very useful.
I have already included the other tips you suggested earlier.
After a bit more editing I will release the next version.
It sure has been a challenge locating information on the usage of YAD.
I'm surprised more people haven't chimed in.
Thanks again.
- rg66
- Posts: 1158
- Joined: Mon 23 Jul 2012, 05:53
- Location: Vancouver, BC Canada / Entebbe, Uganda Africa!?!
A few more tips:
When using --form and variables, you need a variable for each field
This will make the variables out of order, VAR1 will show up in the first box instead of the second.
Using double quotes "" will keep them in the right order if there is no variable for the first box
If you want an just an entrybox with no dropdown arrow just use a blank field
or with text
When using --form and variables, you need a variable for each field
Code: Select all
VAR1="test1"
VAR2="test2"
yad --form --field=":CBE" --field=":CB" $VAR1 --field="Test:CBE" $VAR2
Using double quotes "" will keep them in the right order if there is no variable for the first box
Code: Select all
VAR1="test1"
VAR2="test2"
yad --form --field=":CBE" "" --field=":CB" $VAR1 --field="Test:CBE" $VAR2
Code: Select all
yad --form --field=""
Code: Select all
yad --form --field="Test"
X-slacko-5b1 - X-tahr-2.0 - X-precise-2.4
[url=http://smokey01.com/rg66/]X-series repo[/url]
[url=http://smokey01.com/rg66/]X-series repo[/url]
I have an interesting situation. The following gui with two --entry fields is what I want. The problem is, when data is entered into the Golflink field and the enter button is pressed, the gui closed before data can be entered into the Score/second field.
The tab key works fine but many people will automatically press enter which will mess up the data, creating multiple entries.
Is there a way to make the [enter] key behave like the [tab] key?
Also is it possible to make the gui and text larger with this gui?
The tab key works fine but many people will automatically press enter which will mess up the data, creating multiple entries.
Is there a way to make the [enter] key behave like the [tab] key?
Also is it possible to make the gui and text larger with this gui?
Code: Select all
yad --title="Golf Club" --text="Please enter your details:" \
--form \
--field="Golflink Number" \
--field="Score" \
The text accepts markup the GUI height and widthsmokey01 wrote:Also is it possible to make the gui and text larger with this gui?
Code: Select all
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>" \
- Attachments
-
- Screenshot.png
- (15.01 KiB) Downloaded 6781 times
Last edited by Geoffrey on Tue 03 Feb 2015, 13:00, edited 1 time in total.
[b]Carolina:[/b] [url=http://smokey01.com/carolina/pages/recent-repo.html]Recent Repository Additions[/url]
[img]https://dl.dropboxusercontent.com/s/ahfade8q4def1lq/signbot.gif[/img]
[img]https://dl.dropboxusercontent.com/s/ahfade8q4def1lq/signbot.gif[/img]
A few more pango markup options for font size to make text larger,
Code: Select all
yad --title="Golf Club" --height=200 --width=400 \
--text="<span foreground='blue' font='48' font_style='italic' underline='single'><b>Please enter your details:</b></span>" \
--form \
--field="<b><big><big><big><big>Golflink Number</big></big></big></big></b>" \
--field="<b><big><big>Score</big></big></b>" \
- Attachments
-
- Screenshot2.png
- (27.2 KiB) Downloaded 6817 times
[b]Carolina:[/b] [url=http://smokey01.com/carolina/pages/recent-repo.html]Recent Repository Additions[/url]
[img]https://dl.dropboxusercontent.com/s/ahfade8q4def1lq/signbot.gif[/img]
[img]https://dl.dropboxusercontent.com/s/ahfade8q4def1lq/signbot.gif[/img]
- L18L
- Posts: 3479
- Joined: Sat 19 Jun 2010, 18:56
- Location: www.eussenheim.de/
Usually I would set score to -1 and loop untile greater than -1.smokey01 wrote:The tab key works fine but many people will automatically press enter which will mess up the data, creating multiple entries.
But - is buggy in yad.
You might like this, second dialog if score =0
Code: Select all
#!/bin/sh
data="$(yad --title="Golf Club" --text="Please enter your details:" \
--form --field="Golflink Number":NUM !1..23 \
--field="score":NUM !0..99 )"
link_number="`echo $data | cut -d'|' -f1`"
link_number="`echo $link_number | cut -d'.' -f1`"
link_number="`echo $link_number | cut -d',' -f1`"
score="`echo $data | cut -d'|' -f2`"
score="`echo $score | cut -d'.' -f1`"
score="`echo $score | cut -d',' -f1`"
if [ $score -eq 0 ]; then
score="$(yad --title="Golf Club" --text="Please enter your score for Number ${link_number}:" \
--button=OK --form --field="score":NUM !0..99 )"
score="`echo $score | cut -d'.' -f1`"
score="`echo $score | cut -d',' -f1`"
fi
echo data="link_number=${link_number}|score=${score}"
Use YAD to implement an easy gui interface for 'Youtube Download'
http://rg3.github.io/youtube-dl/
youtube-dl is a small command-line program to download videos from YouTube.com and a few more sites
I installed the following in Quirky Puppy Tahr 6.05
1. youtube-dl
2. yad
The following code will trigger the youtube-dl program.
I was 'inspired' by this blog post:
http://www.linux-magazine.com/Online/Bl ... s-with-YAD
I added a simple progress indicator that indicates whether the program is running or has completed,
http://rg3.github.io/youtube-dl/
youtube-dl is a small command-line program to download videos from YouTube.com and a few more sites
I installed the following in Quirky Puppy Tahr 6.05
1. youtube-dl
2. yad
The following code will trigger the youtube-dl program.
Code: Select all
#!/bin/bash
dialog=$(yad --title "You Tube Download" --form --field="Paste address")
address=$(echo $dialog)
youtube-dl "$address" | yad --title "Download" --progress --pulsate
http://www.linux-magazine.com/Online/Bl ... s-with-YAD
I added a simple progress indicator that indicates whether the program is running or has completed,
- Attachments
-
- ytd-yad.jpg
- (21.25 KiB) Downloaded 6665 times
-
- Posts: 807
- Joined: Mon 12 Oct 2009, 17:11
Hi
B.K.Johnsohn wrote
To find out how to change that, we need to delve into the youtube-dl documentation
https://github.com/rg3/youtube-dl/blob/ ... fic-folder
FAQ
How do I put downloads into a specific folder?
Use the -o to specify an output template, for example -o "/home/user/videos/%(title)s-%(id)s.%(ext)s".
If you want this for all of your downloads, put the option into your configuration file.
https://github.com/rg3/youtube-dl/blob/ ... figuration
For our example:
Make sure you first create a Videos folder (that you can write to) in root
You can easily write extra YAD dialogs to control the parameters and download location.
B.K.Johnsohn wrote
As it stands my code downloads videos to the root folder.1. What is the default download directory?
2. Can it be changed/ If yes, how?
To find out how to change that, we need to delve into the youtube-dl documentation
https://github.com/rg3/youtube-dl/blob/ ... fic-folder
FAQ
How do I put downloads into a specific folder?
Use the -o to specify an output template, for example -o "/home/user/videos/%(title)s-%(id)s.%(ext)s".
If you want this for all of your downloads, put the option into your configuration file.
https://github.com/rg3/youtube-dl/blob/ ... figuration
For our example:
Make sure you first create a Videos folder (that you can write to) in root
Code: Select all
#!/bin/bash
dialog=$(yad --title "You Tube Download" --form --field="Paste address")
address=$(echo $dialog)
youtube-dl "$address" -o "/root/Videos/%(title)s-%(id)s.%(ext)s" | yad --title "Download" --progress --pulsate
@ slavvo67
http://rpm.pbone.net/index.php3/stat/45 ... /nazwa/yad
This method works
If you run in console mode it will echo the directory path.
see YAD manual 'form options'Does anyone have a simple script to choose a directory via pop-up box?
I've been using Zenity but Slacko doesn't have that built in.
http://rpm.pbone.net/index.php3/stat/45 ... /nazwa/yad
This method works
Code: Select all
#!/bin/bash
dialog=$(yad --title "Select Directory" --form --field=Choose:DIR)
echo $dialog
- Attachments
-
- dir1.jpg
- (18.57 KiB) Downloaded 2653 times
Thank you. I think all recent Puppies have YAD but not all have Zenity (i.e. Slacko), so it's time for me to switch my scripts that use Zenity over to YAD. However, your example adds "|" at the end of the directory, so if I try to cd to $directory1 or whatever variable I choose, it will not work as it will create $directory1 as /mnt/sda2/directoryname|
Instead, $directory1 should reflect: /mnt/sda2/directoryname
You still put me on the right track, with the following example from Smokey01 working:
cd /
directory1=$(yad --file --directory --width=600 --height=400)
cd $directory1
Thanks,
Slavvo67
Instead, $directory1 should reflect: /mnt/sda2/directoryname
You still put me on the right track, with the following example from Smokey01 working:
cd /
directory1=$(yad --file --directory --width=600 --height=400)
cd $directory1
Thanks,
Slavvo67
Thanks for your solution inspired by Smokey01
http://smokey01.com/help/yad-tips-0.0.1.ncd.tar.xz
I missed the "|" because I was in too much hurry to post an answer and did not see it..
Remove the "|" easily with this code.
Inspired by
http://www.linux-magazine.com/Online/Bl ... s-with-YAD
I recommend your dialog example slavvo67.
It is quicker and easier to use.
http://smokey01.com/help/yad-tips-0.0.1.ncd.tar.xz
I missed the "|" because I was in too much hurry to post an answer and did not see it..
Remove the "|" easily with this code.
Code: Select all
#!/bin/bash
dialog=$(yad --title "Select Directory" --form --field=Choose:DIR)
echo $dialog | awk 'BEGIN {FS="|" } { print $1 }'
http://www.linux-magazine.com/Online/Bl ... s-with-YAD
I recommend your dialog example slavvo67.
It is quicker and easier to use.