YAD - Tips

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

#281 Post by slavvo67 »

Code: Select all

	
yad --form --field="test1:FBTN" "yad --text='test1'" \
--field="test2:FBTN" "yad --text='test2'" \
--field="test3:FBTN" "yad --text='test3'"
Strangely, the above code just gives me the first box. Maybe it's my version of YAD? I'm using 37, which is I guess a bit dated now.....

Anyone?

User avatar
LazY Puppy
Posts: 1934
Joined: Fri 21 Nov 2014, 18:14
Location: Germany

#282 Post by LazY Puppy »

Image
Attachments
Screenshot-2017-02-09-01-00-09.jpg
(41.67 KiB) Downloaded 641 times
RSH

"you only wanted to work your Puppies in German", "you are a separatist in that you want Germany to secede from Europe" (musher0) :lol:

No, but I gave my old drum kit away for free to a music store collecting instruments for refugees! :wink:

slavvo67
Posts: 1610
Joined: Sat 13 Oct 2012, 02:07
Location: The other Mr. 305

#283 Post by slavvo67 »

Works in terminal but not as a script written via Geany and saved as an executable file. Anyone? Very strange to me...

More strange, it works now but this way:

yad --form --field="test1:FBTN" "yad --text='test1'" --field="test2:FBTN" "yad --text='test2'" --field="test3:FBTN" "yad --text='test3'"

Why does yad have to be typed over and over? I don't get it...

For some strange reason, when it's all one line; it works. When lines are separated with the \ and continued on the next line.... she doesn't work for me....

User avatar
Geoffrey
Posts: 2355
Joined: Sun 30 May 2010, 08:42
Location: Queensland

#284 Post by Geoffrey »

slavvo67 wrote:Works in terminal but not as a script written via Geany and saved as an executable file. Anyone? Very strange to me...

More strange, it works now but this way:

yad --form --field="test1:FBTN" "yad --text='test1'" --field="test2:FBTN" "yad --text='test2'" --field="test3:FBTN" "yad --text='test3'"

Why does yad have to be typed over and over? I don't get it...

For some strange reason, when it's all one line; it works. When lines are separated with the \ and continued on the next line.... she doesn't work for me....
yad --text='test1' is the sample function of yad --form --field="test1:FBTN", it displays a yad window with the text "test1" for the buttons field that's all, it can be any function you like

LazY Puppy try a more recent yad version.

Code: Select all

#! /bin/bash
yad --form --field="test1:FBTN" "yad --text='test1'" \
--field="test2:FBTN" "yad --text='test2'" \
--field="test3:FBTN" "yad --text='test3'"
This in a bash script works for me
Attachments
yad-field-buttons.jpg
(36.72 KiB) Downloaded 619 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]

gyro
Posts: 1798
Joined: Tue 28 Oct 2008, 21:35
Location: Brisbane, Australia

#285 Post by gyro »

From my memory of reading the changelog, the FBTN feature was introduced at version 0.26.0

Yad tip: To use the FBTN feature, use yad >= 0.26.0

Real example:
The main screen of "dircrypt", http://www.murga-linux.com/puppy/viewtopic.php?t=109598.

gyro

slavvo67
Posts: 1610
Joined: Sat 13 Oct 2012, 02:07
Location: The other Mr. 305

#286 Post by slavvo67 »

I'm running 37.0 but sometimes Victor breaks a version when implementing new things.... Maybe I'll upgrade again ....


Thanks

slavvo67
Posts: 1610
Joined: Sat 13 Oct 2012, 02:07
Location: The other Mr. 305

#287 Post by slavvo67 »

Is there any way to pass the drag and drop to the next part of the script without requiring the ok box to be clicked? The no buttons option does not advance unless you close the actual window....

Thank you

User avatar
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

#288 Post by MochiMoppel »

slavvo67 wrote:Is there any way to pass the drag and drop to the next part of the script without requiring the ok box to be clicked?
Which "ok box"? You should place the "next part" before the yad statement as a function:

Code: Select all

function myfunction {
	Xdialog --msgbox "You dropped\n$0" x
}
export -f myfunction

yad --width=200 --height=200 --dnd --command="bash -c 'myfunction'"

stemsee

#289 Post by stemsee »

solved!

step
Posts: 1349
Joined: Fri 04 May 2012, 11:20

#290 Post by step »

Hi all, the conversation that we started, near page 16, about a drag-and-drop script has grown into yet-another script here --> screenshot.
[url=http://murga-linux.com/puppy/viewtopic.php?t=117546]Fatdog64-810[/url]|[url=http://goo.gl/hqZtiB]+Packages[/url]|[url=http://goo.gl/6dbEzT]Kodi[/url]|[url=http://goo.gl/JQC4Vz]gtkmenuplus[/url]

User avatar
misko_2083
Posts: 114
Joined: Tue 08 Nov 2016, 13:42

Iconbox

#291 Post by misko_2083 »

I have this folder /home/user/Desktop/yad_iconbox
in that folder, there is a script switch.sh and a deskop file

Code: Select all

#!/bin/bash
#switch.sh

PARAM="$@"
case $PARAM in
   test)
      if [[ -f "/home/user/Desktop/yad_iconbox/icon-on.desktop" ]]; then
         sed -i 's/gtk\-yes/gtk\-no/g' /home/user/Desktop/yad_iconbox/icon-on.desktop
         mv /home/user/Desktop/yad_iconbox/icons-on.desktop /home/user/Desktop/yad_iconbox/icon-off.desktop
         #more commands here
       else
         sed -i 's/gtk\-no/gtk\-yes/g' /home/misko/Desktop/yad_iconbox/audacious-off.desktop
         mv /home/user/Desktop/yad_iconbox/icon-off.desktop /home/user/Desktop/yad_iconbox/icon-on.desktop
          #commands...
       fi
       ;;
   *) exit
   ;;     
esac
icon-off.desktop

Code: Select all

[Desktop Entry]
Version=1.0
Type=Application
Name=Icon
GenericName=Icon
Comment=Test
Icon=gtk-no
Categories=GTK;
Exec=/home/user/Desktop/yad_iconbox/switch.sh test
TryExec=/home/user/Desktop/yad_iconbox/switch.sh test
Terminal=false
I launch the Iconbox with next

Code: Select all

#!/bin/bash
yad --icons --single-click --monitor --height=300 \
    --width=500 --read-dir="/home/user/Desktop/yad_iconbox"
If I click on this icon, it will change.

I would like to know is there a way to do this using the stdin, since --icons dialog can read from stdin.
--listen
Read data from stdin. Data must be in order - Name, Tooltip,
Icon, Command, InTerm separated by newline. InTerm is a case
insensitive boolean constant (TRUE or FALSE).

Is there a way to force the dialog to reset the icons with something being sent to the pipe?
Example:

Code: Select all

(echo -e "Name\nTooltip\ngtk-ok\necho \"\"\nFALSE"; sleep 1; echo "Reset the icons") | yad --icons --single-click --listen --monitor --height=300 --width=500

User avatar
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

Re: Iconbox

#292 Post by MochiMoppel »

misko_2083 wrote:If I click on this icon, it will change.
Really? First I needed to fix the switch.sh script:
- Change one instance of icons-on.desktop to icon-on.desktop and
- /home/misko/Desktop/yad_iconbox/audacious-off.desktop to /home/user/Desktop/yad_iconbox/icon-off.desktop
Is there a way to force the dialog to reset the icons with something being sent to the pipe?
I don't think that this is possible. AFAIK you can only add icons this way but not change existing ones:

Code: Select all

#!/bin/bash
export PIPE_03=/tmp/yadpipe03 
mkfifo $PIPE_03 
exec 3<> $PIPE_03 

yad --icons --single-click --height=300 --width=500 --listen < $PIPE_03 &
echo -e "Name\nTooltip\ngtk-ok\nbeep\nFALSE" > $PIPE_03
sleep 1
echo -e "Yes\nTooltip\ngtk-yes\nbeep\nFALSE" > $PIPE_03
sleep 1
echo -e "No\nTooltip\ngtk-no\nbeep\nFALSE"   > $PIPE_03
I found no way to clear the icons box. Your original method, using --monitor and --read-dir, seems to be a .better approach.

User avatar
misko_2083
Posts: 114
Joined: Tue 08 Nov 2016, 13:42

Re: Iconbox

#293 Post by misko_2083 »

Thank you for the reply MochiMoppel
Sorry about the errors. :)
I've seen the Yad source and there is only one way as you say.

achim
Posts: 48
Joined: Thu 13 Apr 2017, 19:36
Location: Germany

birthday

#294 Post by achim »

Hi,
6 months ago I switched to Ubuntu 4.16 and have now a lot of fun to yad. Now, however, I have a problem for days. I want you to read and display the result from the "Birthday" on yad. Since the result of more than one word, I get with the attached code, the result only with each displayed (word for word). Can somebody help me with it?

#! / bin / bash

yad --title = 'special events' \
--text = 'birthday' \
--text-align = center --geometry = 950x400 \
--list \
--scroll \
--column = " event "\
--buttons-layout = "center" \
--button =" <b> <span color = 'blue'> Close </ span> </ b> "\
--image-on-top \
- image = / home / hachims / .icons / drive-3-cb-system-dos-icon.png \
$ (birthday -f /home/hachims/Dokumente/b2.txt)

PS. I loaded a professional script with yad to download from youtube down from the net. Can I publish this?

Sorry, I just see that is the wrong forum. Please by YAD tips move. Thank you!

User avatar
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

Re: birthday

#295 Post by MochiMoppel »

achim wrote:Since the result of more than one word, I get with the attached code, the result only with each displayed (word for word)
You are not supposed you get any result at all with this code. Lots of spaces where there shouldn't be any, starting with the shebang '#! / bin / bash', followed by spaces around = and lastly by the space after $ in '$ (birthday -f /home/hachims/Dokumente/b2.txt)'

If this is fixed you need to send the result of your birthday command to yad, presumably with something like
<<< "$(birthday -f /home/hachims/Dokumente/b2.txt)". Mind the double quotation marks around your statement.

If this doesn't help we need to know the output of the birthday -f /home/hachims/Dokumente/b2.txt command.

achim
Posts: 48
Joined: Thu 13 Apr 2017, 19:36
Location: Germany

Re: birthday

#296 Post by achim »

Hi MochiMoppel

thank you for your help, with your suggestion does the YAD script now properly. Still my question remains whether interest in a very functional YAD script "Youtube downloader" is. It is not written by me, but recently downloaded from the Internet. I ask for a short answer.

achim
Posts: 48
Joined: Thu 13 Apr 2017, 19:36
Location: Germany

execute order

#297 Post by achim »

Hello,
I use the following script under Ubuntu as an alternative to the command known under Windows "Run". It works so far, but there is no message if the string is not found. This situation should be caught with a "not found" message and restart the script. Does somebody has any idea?

Code: Select all

#! /bin/bash

XTERM="xterm"

# create history file 
mkdir -p ${XDG_CACHE_HOME:-$HOME/.cache}/ 
HISTFILE=${XDG_CACHE_HOME:-$HOME/.cache}/ix-run.history 
touch $HISTFILE

# create and run dialog 
TITLE="Befehl ausführen" 
TEXT="\nBefehl eingeben und Enter drücken:\n" 
rcmd=$(yad --width=500 --center --window-icon="gtk-execute" --name="${0##/}" --title="$TITLE" --text="$TEXT" --image="gtk-execute" --editable --entry --rest $HISTFILE)

echo "tooltip:Beispielmenü" 

[-z "$rcmd" ] && exit 0

# run command 
case $rcmd in
    http://*|https://*|ftp://*)
        xdg-open $rcmd & 
        ;;
    mailto://*)
        xdg-email $rcmd & 
        ;;
    man://*)
        eval $XTERM -e "man ${rcmd#man://}" & 
        ;;
    telnet*|ssh*)
        eval $XTERM -e "$rcmd" & 
        ;;
    *)
        eval $rcmd & 
        ;;
esac

# add command to history 
head $HISTFILE | grep -qF "$rcmd" || echo -e "$rcmd\n$(<$HISTFILE)" > $HISTFILE

exit 0
Thanks in advance

User avatar
Geoffrey
Posts: 2355
Joined: Sun 30 May 2010, 08:42
Location: Queensland

Re: execute order

#298 Post by Geoffrey »

achim wrote:Hello,
I use the following script under Ubuntu as an alternative to the command known under Windows "Run". It works so far, but there is no message if the string is not found. This situation should be caught with a "not found" message and restart the script. Does somebody has any idea?
Some time back I used this script also, I modified it to give a error message if the command didn't exist and the option to clear the history, this uses exo-open not xdg-open hope this is of help.

Code: Select all

#! /bin/bash
HISTFILE=${XDG_CACHE_HOME:-$HOME/.cache}/ix-run.history
# delete history file
Clear_History(){
	rm $HISTFILE
	yad --fixed --title="History" --window-icon="applications-system" --text="\n        History Cleared        \n" --timeout="2" --no-buttons
	`basename "$0"`
}
export -f  Clear_History
XTERM="xterm"
# create history file
if [ ! -f $HISTFILE ]; then
mkdir -p ${XDG_CACHE_HOME:-$HOME/.cache}/
echo 'Clear_History' > $HISTFILE
fi
# create and run dialog
TITLE="Run command"
TEXT="\nEnter command to execute:\n"
CMD='yad --fixed --width=400 --center --window-icon="applications-system" --buttons-layout=center --title="$TITLE" --text="$TEXT" --button="gtk-ok:0" --image="applications-system" --entry --editable'
ARGS=$(perl -pe 's/(^.*$)/"\1"/;s/\n/ /' $HISTFILE)
rcmd=$(eval $CMD $ARGS)

# run command
case $rcmd in
    www.*|http://*|https://*|ftp://*|mailto:*)
        exo-open $rcmd &
        ;;
    man://*)
        eval $XTERM -e "man ${rcmd#man://}" &
        ;;
    telnet*|ssh*)
        eval $XTERM -e "$rcmd" &
        ;;
    *)
        eval $rcmd 2> /tmp/run-command-error &
        ;;
esac
sleep .1
if grep -c 'command not found' /tmp/run-command-error; then
yad --fixed --title="Error" --window-icon="applications-system" --text="\n Command not found \n" --timeout="2" --no-buttons 
sed 's/ $CMD// $HISTFILE'
rm /tmp/run-command-error
`basename "$0"`
else
# add command to history
grep -qF "$rcmd" $HISTFILE || echo $rcmd >> $HISTFILE
fi
exit 0
Edit: removed error in code.
Last edited by Geoffrey on Mon 17 Apr 2017, 04:29, 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]

achim
Posts: 48
Joined: Thu 13 Apr 2017, 19:36
Location: Germany

Re: execute order

#299 Post by achim »

Hi Geoffrey,
Thank you for your help. However, your modified variant does not report any errors, but terminates the script without comment. Basically, it runs with me just as the original. I use the YAD version 0.38.2 (GTK + 3.20.8). If you have something else to think about, then please contact me.

User avatar
Geoffrey
Posts: 2355
Joined: Sun 30 May 2010, 08:42
Location: Queensland

Re: execute order

#300 Post by Geoffrey »

@achim, you are using your run script in puppy?

I'm unaware of any Puppy flavor that uses yad compiled with GTK + 3.20.

I've modified your script, works for me ok

The code outputs the error to file, then grep checks for the 'command not found', if true then displays the message.

`basename "$0"` runs a new instance of your script, provided that it's in the PATH.

Code: Select all

#! /bin/bash

XTERM="xterm"

# create history file
mkdir -p ${XDG_CACHE_HOME:-$HOME/.cache}/
HISTFILE=${XDG_CACHE_HOME:-$HOME/.cache}/ix-run.history
touch $HISTFILE

# create and run dialog
TITLE="Befehl ausführen"
TEXT="\nBefehl eingeben und Enter drücken:\n"
rcmd=$(yad --width=500 --center --window-icon="gtk-execute" --name="${0##/}" --title="$TITLE" --text="$TEXT" --image="gtk-execute" --editable --entry --rest $HISTFILE)

echo "tooltip:Beispielmenü"

# run command
case $rcmd in
    http://*|https://*|ftp://*)
        xdg-open $rcmd &
        ;;
    mailto://*)
        xdg-email $rcmd &
        ;;
    man://*)
        eval $XTERM -e "man ${rcmd#man://}" &
        ;;
    telnet*|ssh*)
        eval $XTERM -e "$rcmd" &
        ;; *)
        eval $rcmd 2> /tmp/run-command-error &
        ;;
esac
sleep .1
if grep -c 'command not found' /tmp/run-command-error; then
yad --fixed --title="Error" --window-icon="applications-system" --text="\n Command $rcmd not found \n" --timeout="3" --no-buttons
rm /tmp/run-command-error
`basename "$0"`
else
# add command to history
head $HISTFILE | grep -qF "$rcmd" || echo -e "$rcmd\n$(<$HISTFILE)" > $HISTFILE
fi
exit 0
[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]

Post Reply