YAD - Tips

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Post Reply
Message
Author
slavvo67
Posts: 1610
Joined: Sat 13 Oct 2012, 02:07
Location: The other Mr. 305

#121 Post by slavvo67 »

Did that work at all? I use code like this:

charlis=$(yad --center --title='Website Search' --form --columns=2 --form --field='Google Search' --form --field='Gigablast Search' --form --field='Bing Search' --form --field='Tumbler Search' 'Football' 'Horse Racing' 'Camping' 'Investing' )

Note: The columns=2 only works with newer versions of YAD.

User avatar
Argolance
Posts: 3767
Joined: Sun 06 Jan 2008, 22:57
Location: PORT-BRILLET (Mayenne - France)
Contact:

About yad Font selector

#122 Post by Argolance »

Bonjour,
Latest releases of YAD let the font selector return an output of this form:
name|style|size
# yad --help-font
Usage:
yad [OPTION...] - Yet another dialoging program

Font selection options
--font Display font selection dialog
--font-selection Alias for --font
--preview=TEXT Set text string for preview
--separate-output Separate output of font description
Example:

Code: Select all

yad --font --separate-output
Sans|Bold Italic|10
But, in some cases:

Code: Select all

# yad --font --separate-output
Brush Script MT|Italique|10
Italique instead of Italic for French speaking users. The problem is that when running this command:

Code: Select all

yad --font --separate-output --fontname="Brush Script MT Italique 10"
the selector does not recognize the input font and displays the default "Sans" font instead of the expected "Brush Script MT".
As a test and workaround I tried to run YAD this way:

Code: Select all

# LC_MESSAGES=C yad --window-icon gtk-select-font --font --separate-output
Brush Script MT|Italique|10
# LC_CTYPE=C yad --window-icon gtk-select-font --font --separate-output
 Brush Script MT|kursiv|10
kursiv... :shock:

Code: Select all

LANG=en_US.UTF-8 yad --window-icon gtk-select-font --font --separate-output
This time I get the real English name of the font and obviously

Code: Select all

LANG=en_US.UTF-8 yad --window-icon gtk-select-font --font --separate-output="Brush Script MT Italic 10"
works...
Now, my question is what could be the effects of this variable LANG on the rest of my script if I only use it running my font function? Is it something to avoid?
Thank you.

Cordialement.

User avatar
L18L
Posts: 3479
Joined: Sat 19 Jun 2010, 18:56
Location: www.eussenheim.de/

Re: About yad Font selector

#123 Post by L18L »

Argolance wrote:...the selector does not recognize the input font and displays the default "Sans" font instead of the expected "Brush Script MT".
You should post this to Yad's bug tracker.
Argolance wrote:kursiv... :shock:
Don't be shocked. It is German language.
Argolance wrote:Now, my question is what could be the effects of this variable LANG on the rest of my script if I only use it running my font function? Is it something to avoid?
No. Effect is in that single line only.
I think LANG=C better than LANG=en_US.UTF-8 because it is defined in every system.

Cordialement

User avatar
Argolance
Posts: 3767
Joined: Sun 06 Jan 2008, 22:57
Location: PORT-BRILLET (Mayenne - France)
Contact:

#124 Post by Argolance »

Bonjour,
Thanks.
L18L wrote:You should post this to Yad's bug tracker.
I reported this "issue" to Victor Ananjevsky who replied:
Victor wrote:so bug (if this is a bug) must be digged somewhere under yad
...
Don't be shocked. It is German language.
Not "shocked" strictly speaking but just surprised! :wink: (I thought it was russian!)
L18L wrote:No. Effect is in that single line only.
Good thing to know.
I think LANG=C better than LANG=en_US.UTF-8 because it is defined in every system.
This unfortunately (as well as LC_MESSAGES=C or LC_CTYPE=C, as reported above) doesn't work.
Only

Code: Select all

LANG=en_US.UTF-8
works properly.
It only concerns some fonts and it is not very important, though (from my layman's point of view), I find it rather strange that it seems to be so complicated to get the same style result as got without the option "--separate-output".

Code: Select all

# yad --font
Brush Script MT Italic 10

Code: Select all

# yad --font --separate-output
Brush Script MT|Italique|10
Cordialement.

stemsee

#125 Post by stemsee »

So to hide password text without using --hide-text is to use :H

Code: Select all

yad --title "Eduroam University WiFi Connection Tool:" \ 
--form --field="Your University id:" -text "abc123" -entry \ 
--field=Password:H -text "aBcD3210" -entry --field="Interface:" -text "wlan0" -entry

stemsee

#126 Post by stemsee »

I am working on a yad gui for a simpler wifi connection tool
Attachments
capture25227.png
(26.15 KiB) Downloaded 1305 times
capture5335.png
(39.11 KiB) Downloaded 1308 times
capture18480.png
(19.87 KiB) Downloaded 1349 times
Last edited by stemsee on Sat 26 Mar 2016, 16:16, edited 2 times in total.

stemsee

#127 Post by stemsee »

Here's an example of using tabs. The yad key gives permission to use shared memory.

Code: Select all

#!/bin/sh

yad --plug=123456 --tabnum=1 --text="first tab with text" &> res1 &
yad --plug=123456 --tabnum=2 --text="second tab" --entry &> res2 &
yad --plug=123456 --tabnum=3 --text="second tab" --entry &> res3 &
yad --plug=123456 --tabnum=4 --text="second tab" --entry &> res4 &

yad --notebook --key=123456 --tab="Tab 1" --tab="Tab 2" --tab="Tab 3" --tab="Tab 4
Attachments
capture26884.png
(9.1 KiB) Downloaded 1371 times

stemsee

#128 Post by stemsee »

adding combobox and entry to tabs and image!
Attachments
capture32294.png
(43.33 KiB) Downloaded 1293 times
capture731.png
(34.65 KiB) Downloaded 1288 times

stemsee

#129 Post by stemsee »

yad notification

Code: Select all

# run yad and tell it to read its stdin from the file descriptor
yad --notification --kill-parent --listen --image=/usr/share/pixmaps/wifi.png --text="$netsel `ifconfig | grep "inet addr" | tail -1`" --command="yaf-splash -text '`ifconfig $int`'" <&3 &
Make fifo pipe first

Code: Select all

PIPE=$(mktemp -u )
mkfifo -m MODE $PIPE

# attach a filedescriptor to this pipe
exec 3<> $PIPE
Menu is '|' separated items. text '!' command.

Code: Select all

# (d) write stuff to the file descriptor

scanres=`iwlist $int scan | grep 'ESSID' | rev | cut -f1 -d ':' | rev | tr '\n' '|'`

MENU="$scanres! wifi-connectn|Disconnect! ifconfig '$int' down|Reconnect! ifconfig '$int' up|Ethernet 1! ifconfig eth0 up|Ethernet 1 disconnect! ifconfig eth0 down"

echo "menu:$MENU" >&3
Attachments
capture28494.png
(14.43 KiB) Downloaded 1271 times
capture137.png
(227.73 KiB) Downloaded 1277 times

stemsee

#130 Post by stemsee »

But how to show icons/images in the yad -notification MENU?

User avatar
Bert
Posts: 1103
Joined: Fri 30 Jun 2006, 20:09

#131 Post by Bert »

stemsee wrote:But how to show icons/images in the yad -notification MENU?
Hi stemsee,

Here's how I did it for pWget's tray icon:

Code: Select all

yad --notification --image="$WORKDIR/header.png" --command="$WORKDIR/pWget" --text=" pWget $(gettext 'download manager') "  --menu="$(gettext 'About')!$WORKDIR/about-pwget!$WORKDIR/star.png|$(gettext 'Forum')!xdg-open http://www.murga-linux.com/puppy/viewtopic.php?t=90541!$WORKDIR/group.png|$(gettext 'webpage')!xdg-open http://bert2.be/pWget-0.9.4.html!$WORKDIR/house.png|wget-$(gettext 'help')!urxvt --geometry 80x20+2+0 -hold -e wget -h!$WORKDIR/help.png|wget manual!xdg-open http://www.gnu.org/software/wget/manual/wget.html!$WORKDIR/book_open.png"  
Attachments
scrot.png
(12.31 KiB) Downloaded 1239 times
[url=http://pupsearch.weebly.com/][img]http://pupsearch.weebly.com/uploads/7/4/6/4/7464374/125791.gif[/img][/url]
[url=https://startpage.com/do/search?q=host%3Awww.murga-linux.com%2F][img]http://i.imgur.com/XJ9Tqc7.png[/img][/url]

stemsee

#132 Post by stemsee »

@Bert.

So you there can be several '!' separated items. Now I know.

Thanks

stemsee

#133 Post by stemsee »

@Bert

I can only get a jad.png to display. Is there a size for the icon? Where is your Workdir?

User avatar
Bert
Posts: 1103
Joined: Fri 30 Jun 2006, 20:09

#134 Post by Bert »

stemsee wrote:@Bert

I can only get a jad.png to display. Is there a size for the icon? Where is your Workdir?
Stemsee, yes, I should have given some more explanation.
It's simple: My "WORKDIR" here is part of my little pWget script. So, those icons are not available to you.
Just choose your own icons and enter their path.
The yad.png you see is just because your system cannot find my examples.
The icons in my menu are typically around 500 to 600 bytes (and roughly 4KB on disk).
I tried to minimize the "weight" of the icons, but I don't think bigger icons would pose a problem.
If you need more details, please ask.
[url=http://pupsearch.weebly.com/][img]http://pupsearch.weebly.com/uploads/7/4/6/4/7464374/125791.gif[/img][/url]
[url=https://startpage.com/do/search?q=host%3Awww.murga-linux.com%2F][img]http://i.imgur.com/XJ9Tqc7.png[/img][/url]

User avatar
Bert
Posts: 1103
Joined: Fri 30 Jun 2006, 20:09

#135 Post by Bert »

Stemsee, I think I now better understand your question. Just checked with a 48x48 icon. It works. But for a menu a 12x12 (or maybe 24x24) is better, depending on the length of the menu. The top icon is the 48x48: (see what happens..?)
Attachments
2016-03-30-220106_2_scrot.png
(15.2 KiB) Downloaded 1163 times
[url=http://pupsearch.weebly.com/][img]http://pupsearch.weebly.com/uploads/7/4/6/4/7464374/125791.gif[/img][/url]
[url=https://startpage.com/do/search?q=host%3Awww.murga-linux.com%2F][img]http://i.imgur.com/XJ9Tqc7.png[/img][/url]

stemsee

#136 Post by stemsee »

here is the format I am using, but nothing I have tried shows any other icon than standard yad green bottle! And when it does show it disables the following command!!

Code: Select all

yad --notification --kill-parent --listen \
    --image=/usr/share/pixmaps/wifi.png --text="`iwconfig $int`"\
    --command="yad --undecorated --center --no-buttons --image /usr/share/pixmaps/wifi.png --text '$mytext31'" <&3 &
pid=$!

pics=/usr/share/icons/hicolor/16x16/wifi.png
scanres2=`iwlist $int scan | grep 'ESSID' | rev | cut -f1 -d ':' | rev | tr '\n' '|'`
scanres=`iwconfig $int | tr '\n' '|'`
MENU="$scanres2 $mytext4! wifi-connect2|$mytext30! defaultbrowser|$mytext10! ifconfig '$int' down|$mytext11! ifconfig '$int' up|Wlan1! ifconfig wlan1 up| wlan1 $mytext10! ifconfig wlan1 down|Ethernet 1! ifconfig eth0 up|Ethernet 1 $mytext10! ifconfig eth0 down|Ethernet 2! ifconfig eth1 up|Ethernet 2 $mytext10! ifconfig eth1 down|$mytext12! ifconfig usb0 up|$mytext13! ifconfig usb0 down|$mytext19! hotspot|$mytext9! kill $pid"
echo "menu:$MENU" >&3 &
Which version of yad do you use Bert?

User avatar
Bert
Posts: 1103
Joined: Fri 30 Jun 2006, 20:09

#137 Post by Bert »

Hi stemsee,

I'm using yad-version 0.35.0

For the menu thingie,Yad has a strict logic:

Code: Select all

|text!command!image|
You cannot deviate from that.

Just try it at your leisure with a very simple example.
Also, you have a space after every "!". Not sure if that is possible.

Good luck and keep us posted,
Bert
[url=http://pupsearch.weebly.com/][img]http://pupsearch.weebly.com/uploads/7/4/6/4/7464374/125791.gif[/img][/url]
[url=https://startpage.com/do/search?q=host%3Awww.murga-linux.com%2F][img]http://i.imgur.com/XJ9Tqc7.png[/img][/url]

stemsee

#138 Post by stemsee »

image last no spaces = working!
Thanks again Bert

Stemsee

User avatar
smokey01
Posts: 2813
Joined: Sat 30 Dec 2006, 23:15
Location: South Australia :-(
Contact:

#139 Post by smokey01 »

I have what should be an easy problem to solve but I've had no luck so far.

I want to be able to set the spin box with a min of 0.0 and the max of 1.0 with steps of 0.1 or maybe even 0.001.

Does anyone know how to do this with the code below?

#!/bin/sh
yad --form \
--field="Number:NUM" \
"5" | while read line; do
NUMBER=`echo $line | awk -F',' '{print $1}'`
echo $NUMBER
done

TIA

User avatar
rg66
Posts: 1158
Joined: Mon 23 Jul 2012, 05:53
Location: Vancouver, BC Canada / Entebbe, Uganda Africa!?!

#140 Post by rg66 »

smokey01 wrote:I have what should be an easy problem to solve but I've had no luck so far.

I want to be able to set the spin box with a min of 0.0 and the max of 1.0 with steps of 0.1 or maybe even 0.001.

Does anyone know how to do this with the code below?

#!/bin/sh
yad --form \
--field="Number:NUM" \
"5" | while read line; do
NUMBER=`echo $line | awk -F',' '{print $1}'`
echo $NUMBER
done

TIA
From script:

Code: Select all

yad --form --field="Number:NUM" 0!0..1!0.1!1

yad --form --field="Number:NUM" 0!0..1!0.01!2

yad --form --field="Number:NUM" 0!0..1!0.001!3

yad --form --field="Number:NUM" 0!0..1!0.05!2 (increments of 0.05)
From cli:

Code: Select all

yad --form --field="Number:NUM" 0\!0..1\!0.1\!1

etc.....
For some reason it outputs all in 3 decimal points. :?:
Attachments
Screenshot(2).jpg
(7.42 KiB) Downloaded 1121 times
X-slacko-5b1 - X-tahr-2.0 - X-precise-2.4
[url=http://smokey01.com/rg66/]X-series repo[/url]

Post Reply