YAD - Tips

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Message
Author
step
Posts: 1349
Joined: Fri 04 May 2012, 11:20

#221 Post by step »

stemsee wrote:Here is my double dnd/list gui. Only problem is closing the first parent gui, I don't know how to get the pid, even when it is the last backgrounded process.
There's a --kill-parent option. See if that helps. There's also a YAD_PID environment variable that holds the dialog pid. Perhaps you could run ps and reconstruct the chain of parents of $YAD_PID (but it seems complicated). By the way, your code uses 'tail' in a way that WILL leave hanging processes. Instead, read and adapt the last few posts, which show cleaner alternatives to 'tail'.
[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]

stemsee

#222 Post by stemsee »

Sorted the tail command to 'tail -f'; changed dostuff to your code to remove trailing '\n's; and after observing the pids created for rfdnd using pprocess, I saw the parent used a pid that varied in range from 10 to 20 more than the $$ value, so I made it create a routine to kill pids in that range ... not ideal but it works.

Code: Select all

#!/bin/sh 
# refdnd reference or what-have-you list builder/editor 
#by stemsee, step and MochiMoppel 2016 
lf=$HOME/refs1.txt 
lf2=$HOME/refs2.txt 

function editor () { 
mv /tmp/xyp /tmp/pyx 
lf=$HOME/refs1.txt 
lf2=$HOME/refs2.txt 
[[ "$lf2" ]] && mv "$lf2" "$lf" 
refdnd & 
sleep 1 
/tmp/pyx 
} 
export -f editor 

function dostuff { 
   lf2=$HOME/refs2.txt 
    STUFF="${0//file:\/\//}" 
   printf %s\\\n "$STUFF" >> "$lf2" 
    printf %s\\\n "$STUFF" 
} 
export -f dostuff 

function save () { 
lf=$HOME/refs1.txt 
lf2=$HOME/refs2.txt 
fix=$(date | awk '{print $3,$2,$4}' | tr ' ' '_') 
cp "$lf" "$lf"."$fix" 
cp "$lf2" "$lf2"."$fix" 
} 
export -f save 

function blank () { 
mv /tmp/xyp /tmp/pyx 
rm -f "$lf" 
rm -f "$lf2" 
touch "$lf" 
touch "$lf2" 
refdnd & 
sleep 1 
/tmp/pyx 
} 
export -f blank 

yad --plug=$$ --tabnum=1 --text="Drag-n-drop items here\nThey will be added to\n/root/refs1.txt list\n---" --dnd --command "bash -c 'printf %s\\\\n \"\${0//file:\/\//}\"'" >> "$lf" & 
yp=`echo $$` 
echo $$ 
task='kill $pid' 
echo "#!/bin/sh 
yp=$yp 
for pid in "`seq $((yp + 10)) 1 $((yp + 30))`" 
do 
$task 
done 
" > /tmp/xyp 
chmod 755 /tmp/xyp 
tail -f "$lf" | awk '{fflush();print;fflush()}' | yad --plug=$$ --tabnum=2 --editable --listen --tail --text-info & 
yad --plug=$$ --tabnum=3 --text="Drag-n-drop edits from refs1\nOr refs2 / any source\nThey will create /root/refs2.txt\n---" --dnd --command "bash -c dostuff" > "$lf2" & 
yad --plug=$$ --tabnum=5 --form --field="Replace refs1 with refs2:fbtn" "bash -c editor" --field="'Start New' refs lists:fbtn" "bash -c blank" --field="Save Ref lists by date in /root:fbtn" "bash -c save" & 
tail -f "$lf2" | awk '{fflush();print;fflush()}' | yad --plug=$$ --tabnum=4 --editable --listen --tail --text-info & 
yad --window-icon=/usr/share/pixmaps/leafpad.png --geometry=80x80+80+80 --no-buttons --on-top --notebook --key=$$ --title="Ref Lists in /root. Just DragnDrop text/files/dirs/WebAddresses to One of Two DnD tabs" --command "kill $YAD_PID" --tab="DnD1" --tab="refs1" --tab-pos=bottom --tab="DnD2" --tab="refs2" --tab="Save" 
Last edited by stemsee on Wed 14 Sep 2016, 21:38, edited 2 times in total.

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

#223 Post by MochiMoppel »

stemsee wrote:# refdnd reference or what-have-you list builder/editor
#by stemsee, step and MochiMoppel 2016
:shock: Not by me.
step wrote:Good to have the paned option, but tabs work well for me, too.
They both work for me too. It's rather a matter of taste. Personally I find the functionality of the dnd dialog the least attractive of all yad dialogs, but I'm sure other members will disagree.
In the previous demos there is a limit of only 1 target tab per dnd. Using named pipes makes it possible to feed multiple tabs with only 1 dnd. Here an example. When files are dropped (e.g. from a ROX-Filer window), they will end up in the"Files" tab, when other text strings are dropped they will end up in the "Others" tab. Again no external utilities needed. There is practically no limit to the number of tabs that can be "linked" to the dnd dialog.

Code: Select all

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

function dostuff {
    if [[ $0 =~ ^file:// ]];then
        FILES=${0//file:\/\//}
        printf %s\\n "$FILES" >  $PIPE_03
    else
        printf %s\\n "$0" > $PIPE_04
    fi
}; export -f dostuff

yad --dnd       --plug=$$ --tabnum=1   --command "bash -c dostuff" &
yad --text-info --plug=$$ --tabnum=2   --listen < $PIPE_03 & 
yad --text-info --plug=$$ --tabnum=3   --listen < $PIPE_04 & 
yad --notebook  --key=$$  --tab=Drop --tab=Files --tab=Others

rm -f $PIPE_03 $PIPE_04

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

#224 Post by step »

@MochiMoppel, nice. It's also a good example of using --listen where it makes sense. Thanks.
[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]

stemsee

#225 Post by stemsee »

step wrote:@MochiMoppel, nice. It's also a good example of using --listen where it makes sense. Thanks.
I was experimenting with listen and left it there as it made no difference, not 'using it'.

MociMoppel, how many panes can yad with '--paned' option display? I could only get two.

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

#226 Post by MochiMoppel »

stemsee wrote:MociMoppel, how many panes can yad with '--paned' option display? I could only get two.
The YAD Manual wrote:Paned works in a same manner as a notebook with one restriction - only first and secong plug dialogs will be swallowed to panes.

stemsee

#227 Post by stemsee »

The YAD Manual wrote:Paned works in a same manner as a notebook with one restriction - only first and secong plug dialogs will be swallowed to panes.
This seems to suggest that tabs 3+ will be 'tabs' but I couldn't get that. Is there a particular position for '--paned' to be placed in?

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

#228 Post by MochiMoppel »

"works in a same manner as a notebook" suggests that "Paned" and "notebook" are two similar, but still different dialog types. --paned may sound like a property, but it's a dialog. Both dialog types swallow plug dialogs and all plug dialogs need to specify a --tabnum. When swallowed by a "Notebook" these plug dialogs will appear as a tab, when swallowed by "Paned" they will appear as a pane, and the maximum is 2 - which makes sense to me.

stemsee

#229 Post by stemsee »

Ok. My degree in linguistics, and my level 5 Cambridge professional certificate in teaching English threw me off there! ;-)

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

#230 Post by Geoffrey »

Continued from http://murga-linux.com/puppy/viewtopic. ... 488#918488
B.K. Johnson wrote:Sure Geoffery
This is a slight modification of your earlier post.

Code: Select all

#!/bin/bash
yad --title="Yad Message Box" --width=200 --height=150 --fixed --text-align="center" --skip-taskbar --window-icon="gtk-dialog-info" \
--text="<big><b>
This is a Yad message box
</b></big>" --no-buttons --timeout="3" 
The text is not displayed.
Remove the timeout and it is shown.
That works fine for me, the problem your having may be due to the version of yad your using, I'm using yad 0.36.3, to get the version, in the terminal type yad --version

Paste

Code: Select all

yad --title="Yad Message Box" --width=200 --height=150 --fixed --text-align="center" --skip-taskbar --window-icon="gtk-dialog-info" \
--text="<big><b>
This is a Yad message box
</b></big>" --no-buttons --timeout="3"
in to a terminal to see what the error is, you should get something like this

Code: Select all

Unable parse command line: Unknown option --?
[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]

B.K. Johnson
Posts: 807
Joined: Mon 12 Oct 2009, 17:11

#231 Post by B.K. Johnson »

@Geoffery
That works fine for me, the problem your having may be due to the version of yad your using, I'm using yad 0.36.3, to get the version, in the terminal type yad --version
You are likely correct for I have version 0.36.2 installed. I checked PPM, but found nothing newer. I'll have to look elsewhere. Thanks for the lead.
Paste

Code: Select all

...into a terminal to see what the error is, you should get something like this
	
[code]Unable parse command line: Unknown option --?	
Got the same box with no text - no error message.
[color=blue]B.K. Johnson
tahrpup-6.0.5 PAE (upgraded from 6.0 =>6.0.2=>6.0.3=>6.0.5 via quickpet/PPM=Not installed); slacko-5.7 occasionally. Frugal install, pupsave file, multi OS flashdrive, FAT32 , SYSLINUX boot, CPU-Dual E2140, 4GB RAM[/color]

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

#232 Post by Geoffrey »

@B.K. Johnson,

Weird, I can't fault it, ah yes so the box displays, it wouldn't if there was an error, let us know how you solve it, be interesting to see the cause.
[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]

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

#233 Post by MochiMoppel »

B.K. Johnson wrote:I have version 0.36.2 installed
...so do I and your code works fine here. Do you get a buttonless dialog with and without --timeout?

B.K. Johnson
Posts: 807
Joined: Mon 12 Oct 2009, 17:11

#234 Post by B.K. Johnson »

@MochiMoppel
B.K. Johnson wrote:
I have version 0.36.2 installed
...so do I and your code works fine here. Do you get a buttonless dialog with and without --timeout?
It is buttonless as the attached screenshot shows. Title OK. Times out OK too.
Attachments
notextyad.png
Shows titled box, but no text, yet times out
(3.19 KiB) Downloaded 944 times
[color=blue]B.K. Johnson
tahrpup-6.0.5 PAE (upgraded from 6.0 =>6.0.2=>6.0.3=>6.0.5 via quickpet/PPM=Not installed); slacko-5.7 occasionally. Frugal install, pupsave file, multi OS flashdrive, FAT32 , SYSLINUX boot, CPU-Dual E2140, 4GB RAM[/color]

B.K. Johnson
Posts: 807
Joined: Mon 12 Oct 2009, 17:11

#235 Post by B.K. Johnson »

@Geoffery, MochiMoppel
My set-up is tahr-6.0.2 that has been upgraded to 6.0.5 via tahr updates.

I booted as though I intended to create a new pupsave.
From CLI, yad --version showed 0.12.4
Ran the code from both command line and script.
-- Barfed because of text-align="center"
-- On correcting to text="center", the script displayed correctly with --no-buttons and --timeout="3"
So we know the earlier version worked. :)

Back on the regular 6.0.5, with yad version 0.36.2, the revised code still did not display: "This is a yad message box"

How did I get from 0.12.4 to 0.36.2? yad is not available in PPM. I have it in my repository, so I must have downloaded it from the thread. Since MochiMoppel's 0.36.2 works, then the question is what was the source of MochiMoppel's? Was the pet changed between our download times? Or is there some other reason?

My copy was downloaded on Jul 22 and the md5 is c31af28d09ac6c44b88bec2c2a306e05
[color=blue]B.K. Johnson
tahrpup-6.0.5 PAE (upgraded from 6.0 =>6.0.2=>6.0.3=>6.0.5 via quickpet/PPM=Not installed); slacko-5.7 occasionally. Frugal install, pupsave file, multi OS flashdrive, FAT32 , SYSLINUX boot, CPU-Dual E2140, 4GB RAM[/color]

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

#236 Post by slavvo67 »

If I can add two-cents, Victor, the creator of YAD, sometimes makes changes that negatively affect other commands of YAD so he will update again, sometimes in short time-frames. I'm not saying that is definitely the issue but it might be. Also, I'm thinking that YAD compiled in one Puppy or Quirky may not work properly in others.

Can anyone chime in on these thoughts?

Best,

Slavvo67

B.K. Johnson
Posts: 807
Joined: Mon 12 Oct 2009, 17:11

#237 Post by B.K. Johnson »

Hi guys
It is a tahr issue.
When I install yad-0.36.2 in a puppy created from a 605 iso, the script when run or invoked from the terminal does not display correctly - same as the case when I use the updated tahr-6.0.5. The display works correctly for MochiMoppel who uses the same yad version with slacko-5.6 and for Geoffrey who I assume uses Carolina.

I am repeating the code here and asking others with non-tahr puppies to copy, paste and run it in the terminal and post whether the window shows the text: This is a Yad message box before the window vanishes in 3 secs.

Code: Select all

yad --title="Yad Message Box" --width=200 --height=150 --fixed --text="center" --skip-taskbar --window-icon="gtk-dialog-info" \
--text="<big><b>
This is a Yad message box
</b></big>" --no-buttons --timeout="3" 
[EDIT]
xenial-7.0.1 has the same problem. It has yad- 0.12.4 OOTB and it works, but installed 0.36.2 does not.
[color=blue]B.K. Johnson
tahrpup-6.0.5 PAE (upgraded from 6.0 =>6.0.2=>6.0.3=>6.0.5 via quickpet/PPM=Not installed); slacko-5.7 occasionally. Frugal install, pupsave file, multi OS flashdrive, FAT32 , SYSLINUX boot, CPU-Dual E2140, 4GB RAM[/color]

User avatar
Semme
Posts: 8399
Joined: Sun 07 Aug 2011, 20:07
Location: World_Hub

#238 Post by Semme »

*Moved to PM..

B.K. Johnson
Posts: 807
Joined: Mon 12 Oct 2009, 17:11

#239 Post by B.K. Johnson »

Sorry to say Semme, but that didn't work either. :( :o :? :x :lol:
Dependency check - see screen-shot. This true for anyone else?
Attachments
missing yad dep.png
dependency check screen-shot
(13.26 KiB) Downloaded 776 times
[color=blue]B.K. Johnson
tahrpup-6.0.5 PAE (upgraded from 6.0 =>6.0.2=>6.0.3=>6.0.5 via quickpet/PPM=Not installed); slacko-5.7 occasionally. Frugal install, pupsave file, multi OS flashdrive, FAT32 , SYSLINUX boot, CPU-Dual E2140, 4GB RAM[/color]

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

#240 Post by slavvo67 »

I think that's a glitch. I don't think you need those dependencies. Anyone? BKJohnson - Are you using a YAD pet that was created in the forum? If it wasn't compiled in the distro you are using,. it might not work properly.

I'll try and grab a version of Tahr and compile it. It should work okay.....

Wait, are you using the 64 bit or 32 bit version of Tahr?

Post Reply