Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Fri 20 Oct 2017, 07:15
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
YAD - Tips
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 22 [321 Posts]   Goto page: 1, 2, 3, ..., 20, 21, 22 Next
Author Message
smokey01


Joined: 30 Dec 2006
Posts: 2649
Location: South Australia

PostPosted: Sun 25 Jan 2015, 03:51    Post subject:  YAD - Tips
Subject description: Disscusion on the usage of Yet Another Dialog
 

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.

_________________
Software <-> Distros <-> Tips <-> Newsletters
Back to top
View user's profile Send private message Visit poster's website 
rg66


Joined: 23 Jul 2012
Posts: 1125
Location: Vancouver, BC Canada / Entebbe, Uganda Africa!?!

PostPosted: Sun 25 Jan 2015, 04:59    Post subject:  

This page has a little better explanation of help and has a notebook example as well. http://rpm.pbone.net/index.php3/stat/45/idpl/20231177/numer/1/nazwa/yad
_________________
X-slacko-5b1 - X-tahr-2.0 - X-precise-2.4
X-series repo
Back to top
View user's profile Send private message 
smokey01


Joined: 30 Dec 2006
Posts: 2649
Location: South Australia

PostPosted: Sun 25 Jan 2015, 06:55    Post subject:  

Thanks, added.
_________________
Software <-> Distros <-> Tips <-> Newsletters
Back to top
View user's profile Send private message Visit poster's website 
rg66


Joined: 23 Jul 2012
Posts: 1125
Location: Vancouver, BC Canada / Entebbe, Uganda Africa!?!

PostPosted: Sun 25 Jan 2015, 10:15    Post subject:  

Here's a tip for drag and drop

Code:
# yad --dnd
file:///root/Desktop/tmp


pipe it to sed 's/^.......//' to get a proper path

Code:
yad --dnd | sed 's/^.......//'
/root/Desktop/tmp

_________________
X-slacko-5b1 - X-tahr-2.0 - X-precise-2.4
X-series repo
Back to top
View user's profile Send private message 
smokey01


Joined: 30 Dec 2006
Posts: 2649
Location: South Australia

PostPosted: Sat 31 Jan 2015, 01:15    Post subject:  

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.

Code:
#!/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


How do I assign variables so the last echo statement at the bottom of the script works?

Thanks

_________________
Software <-> Distros <-> Tips <-> Newsletters
Back to top
View user's profile Send private message Visit poster's website 
rg66


Joined: 23 Jul 2012
Posts: 1125
Location: Vancouver, BC Canada / Entebbe, Uganda Africa!?!

PostPosted: Sat 31 Jan 2015, 05:32    Post subject:  

Not quite sure what you're after but maybe you can use something from these scripts to get what you want.

Code:
#!/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


Or

Code:
#!/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


Or

Code:
#!/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:
# 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
X-series repo
Back to top
View user's profile Send private message 
smokey01


Joined: 30 Dec 2006
Posts: 2649
Location: South Australia

PostPosted: Sat 31 Jan 2015, 07:19    Post subject:  

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.

_________________
Software <-> Distros <-> Tips <-> Newsletters
Back to top
View user's profile Send private message Visit poster's website 
rg66


Joined: 23 Jul 2012
Posts: 1125
Location: Vancouver, BC Canada / Entebbe, Uganda Africa!?!

PostPosted: Sat 31 Jan 2015, 08:13    Post subject:  

A few more tips:

When using --form and variables, you need a variable for each field

Code:
VAR1="test1"
VAR2="test2"

yad --form --field=":CBE"  --field=":CB" $VAR1 --field="Test:CBE" $VAR2


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

Code:
VAR1="test1"
VAR2="test2"

yad --form --field=":CBE" ""  --field=":CB" $VAR1 --field="Test:CBE" $VAR2


If you want an just an entrybox with no dropdown arrow just use a blank field

Code:
yad --form --field=""

or with text
Code:
yad --form --field="Test"

_________________
X-slacko-5b1 - X-tahr-2.0 - X-precise-2.4
X-series repo
Back to top
View user's profile Send private message 
smokey01


Joined: 30 Dec 2006
Posts: 2649
Location: South Australia

PostPosted: Tue 03 Feb 2015, 04:07    Post subject:  

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?

Code:
yad --title="Golf Club" --text="Please enter your details:" \
--form \
--field="Golflink Number" \
--field="Score" \

_________________
Software <-> Distros <-> Tips <-> Newsletters
Back to top
View user's profile Send private message Visit poster's website 
Geoffrey


Joined: 30 May 2010
Posts: 2301
Location: Queensland

PostPosted: Tue 03 Feb 2015, 08:26    Post subject:  

smokey01 wrote:
Also is it possible to make the gui and text larger with this gui?


The text accepts markup the GUI height and width

Code:
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>" \
Screenshot.png
 Description   
 Filesize   15.01 KB
 Viewed   3106 Time(s)

Screenshot.png


_________________
Carolina: Recent Repository Additions


Last edited by Geoffrey on Tue 03 Feb 2015, 09:00; edited 1 time in total
Back to top
View user's profile Send private message 
Geoffrey


Joined: 30 May 2010
Posts: 2301
Location: Queensland

PostPosted: Tue 03 Feb 2015, 08:58    Post subject:  

A few more pango markup options for font size to make text larger,

Code:
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>" \
Screenshot2.png
 Description   
 Filesize   27.2 KB
 Viewed   3117 Time(s)

Screenshot2.png


_________________
Carolina: Recent Repository Additions

Back to top
View user's profile Send private message 
L18L

Joined: 19 Jun 2010
Posts: 3425
Location: www.eussenheim.de/

PostPosted: Tue 03 Feb 2015, 12:30    Post subject:  

smokey01 wrote:
The tab key works fine but many people will automatically press enter which will mess up the data, creating multiple entries.

Usually I would set score to -1 and loop untile greater than -1.
But - is buggy in yad.

You might like this, second dialog if score =0
Code:
#!/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}"

Adjust ranges for linknumber and scores Wink
Back to top
View user's profile Send private message 
kjdixo

Joined: 13 Sep 2009
Posts: 159

PostPosted: Sat 21 Mar 2015, 16:28    Post subject:  

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.

Code:

#!/bin/bash

dialog=$(yad --title "You Tube Download" --form --field="Paste address")

address=$(echo $dialog)

youtube-dl "$address"  | yad --title "Download" --progress --pulsate


I was 'inspired' by this blog post:
http://www.linux-magazine.com/Online/Blogs/Productivity-Sauce/Dress-Up-Bash-Scripts-with-YAD
I added a simple progress indicator that indicates whether the program is running or has completed,
ytd-yad.jpg
 Description   
 Filesize   21.25 KB
 Viewed   3015 Time(s)

ytd-yad.jpg

Back to top
View user's profile Send private message 
slavvo67

Joined: 12 Oct 2012
Posts: 1424
Location: The other Mr. 305

PostPosted: Sat 21 Mar 2015, 19:48    Post subject:  

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.
Back to top
View user's profile Send private message 
B.K. Johnson

Joined: 12 Oct 2009
Posts: 631

PostPosted: Sat 21 Mar 2015, 22:18    Post subject:  

kjdixo wrote:

Quote:
#!/bin/bash

dialog=$(yad --title "You Tube Download" --form --field="Paste address")

address=$(echo $dialog)

youtube-dl "$address" | yad --title "Download" --progress --pulsate

1. What is the default download directory?
2. Can it be changed/ If yes, how?
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 22 [321 Posts]   Goto page: 1, 2, 3, ..., 20, 21, 22 Next
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Off-Topic Area » Programming
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0890s ][ Queries: 14 (0.0088s) ][ GZIP on ]