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 Sat 23 Feb 2019, 22:47
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 38 of 39 [581 Posts]   Goto page: Previous 1, 2, 3, ..., 36, 37, 38, 39 Next
Author Message
vovchik


Joined: 23 Oct 2006
Posts: 1480
Location: Ukraine

PostPosted: Sun 03 Feb 2019, 18:50    Post subject:  

Dear all,

Just a little demo utilizing techniques mention here https://iwf1.com/how-to-change-gtk-apps-tooltips-text-and-background-color, with embedded svgs, so the script is self-contained.

With kind regards,
vovchik
yadstyle-vov.tar.gz
Description 
gz

 Download 
Filename  yadstyle-vov.tar.gz 
Filesize  2.44 KB 
Downloaded  28 Time(s) 
Back to top
View user's profile Send private message 
lamplinux


Joined: 21 Jan 2019
Posts: 28

PostPosted: Mon 04 Feb 2019, 13:09    Post subject: Yad Pad Docker  



https://www.youtube.com/watch?v=T9Wz_lwyeok
Back to top
View user's profile Send private message Visit poster's website 
lamplinux


Joined: 21 Jan 2019
Posts: 28

PostPosted: Tue 05 Feb 2019, 22:21    Post subject: Multiple filters in yad --filename window  

@MochiMoppel

I am using your below code and it works also for selecting and copying *.mp3 files. Thank You !!

Is it possible to have multiple filters in your code where the filters can be picked in drop down list (lower right) of Yad --filename window ?

Code:

TARGET="/home/bobby/Music/favorites"
CHECKED=$(yad --title="Please select (multiple) files" --file --geometry=700x500 --button="Copy to $TARGET":0 --button=Cancel:1 --file-filter=*.mp3 --file-filter*.desktop --multiple --filename=/home/bobby/Music/mp3-mew-rock-alt/* )
(($?)) && exit
IFS=TMP IFS='|'
cp -t "$TARGET" $CHECKED
IFS=$TMP
Back to top
View user's profile Send private message Visit poster's website 
lamplinux


Joined: 21 Jan 2019
Posts: 28

PostPosted: Tue 05 Feb 2019, 22:36    Post subject: Using yad --entry and have it save to a file  

How would I use yad --entry to have user enter and save to file "title_names.source"

name of Window1, Window2, Window3, etc.

title_names.source (content)

$window1="Applications"
$window2="Favorites"
$window3="Yad Help"
$window4="Toms Window"

Then I can read the variable from this one file for each window.

yad --title="$window1"
Back to top
View user's profile Send private message Visit poster's website 
MochiMoppel


Joined: 26 Jan 2011
Posts: 1777
Location: Japan

PostPosted: Tue 05 Feb 2019, 23:38    Post subject: Re: Multiple filters in yad --filename window  

lamplinux wrote:
Is it possible to have multiple filters in your code where the filters can be picked in drop down list (lower right) of Yad --filename window ?

Yes. Use a --file-filter option for each file pattern. You can also give your filter a name that will appear in the drop-down list and - probably most important - you can also define a set of file patterns for a single filter option:
Code:
--file-filter=*.mp3 --file-filter=*.ogg --file-filter="Audio files|*.mp3 *.ogg *.wav" --file-filter="All files|*"
Back to top
View user's profile Send private message 
lamplinux


Joined: 21 Jan 2019
Posts: 28

PostPosted: Wed 06 Feb 2019, 00:03    Post subject:  

@MochiMoppel -- Thank you again !!
Back to top
View user's profile Send private message Visit poster's website 
lamplinux


Joined: 21 Jan 2019
Posts: 28

PostPosted: Thu 07 Feb 2019, 02:07    Post subject: Multiple yad --entry write to separate files  

Is it possible for yad --entry to have several entry boxes in same window and then write each entry box input to a separate file ?

Code:
dock1_name=$(yad --entry --title="Change Dock1 Window Name" --text="Enter New Dock1 name") && echo $dock1_name > /home/bobby/yadbash/beta/code/dock1name.file




Code:
cd /home/bobby/yadbash/beta/code
dock1_name=$(head -n 1 dock1name.file)
yad --icons --read-dir=/usr/share/applications --monitor --single-click --item-width=70 --sort-by-name\
 --geometry="1244x153+1+592" --on-top --vscroll-policy=auto  --undecorated \
 --title="YadBash Simple Coding" --text="$dock1_name" --window-icon=/usr/share/icons/sparky/about/sparky48.png \
 --no-buttons --skip-taskbar
Back to top
View user's profile Send private message Visit poster's website 
misko_2083


Joined: 08 Nov 2016
Posts: 64

PostPosted: Thu 07 Feb 2019, 21:12    Post subject: Re: Multiple yad --entry write to separate files  

lamplinux wrote:
Is it possible for yad --entry to have several entry boxes in same window and then write each entry box input to a separate file ?

Code:
dock1_name=$(yad --entry --title="Change Dock1 Window Name" --text="Enter New Dock1 name") && echo $dock1_name > /home/bobby/yadbash/beta/code/dock1name.file




Code:
cd /home/bobby/yadbash/beta/code
dock1_name=$(head -n 1 dock1name.file)
yad --icons --read-dir=/usr/share/applications --monitor --single-click --item-width=70 --sort-by-name\
 --geometry="1244x153+1+592" --on-top --vscroll-policy=auto  --undecorated \
 --title="YadBash Simple Coding" --text="$dock1_name" --window-icon=/usr/share/icons/sparky/about/sparky48.png \
 --no-buttons --skip-taskbar


Well you can use the array
The trick is to use the quoted output and remove it later with xargs.

Also the internal field separator must be set for the array.
In this case newline character.

Code:
#!/bin/bash
# backup IFS
OIFS=$IFS

# set IFS to newline char
IFS=$'\n'

res=($(yad --form --quoted-output --separator="\n" \
          --field=1 --field=2 \
          --field=3 --field=4 \
          --field=5))

# get exit status
out=$?

# Restore IFS
IFS=$OIFS

# OK (0), canceled (1) or closed dialog (252)
[ $out -ne 0 ] && exit 1

# for looping trough array
for i in {0..4}; do
       # write each element 0-4 into field-1 to field-5
       # xargs removes outer quotes
       echo "${res[$i]}" | xargs > /tmp/field-$((i+1))
done


Btw this is a form dialog,
Back to top
View user's profile Send private message 
lamplinux


Joined: 21 Jan 2019
Posts: 28

PostPosted: Thu 07 Feb 2019, 22:36    Post subject: --form multiple records written to many files.  

@misko, That works great - as always. Thank You !!!!

May I ask for another option to your array output ? Then I'll be able to output and read all night long. Very Happy

Can the output of the array be written to the same line number of each of the "field-$" files ?

For example, Form data output is written to line 3 of each "field-$" file. So, not to over write the file, just update Line 3 of each file. I hope I'm asking this well enough.

I'm trying to use sed to accomplish this with your array but, don't fully understand what I m doing (learning though).

Bobby's attempt:

Code:
# Using sed to update file - line 3 looping trough array
for i in {0..4}; do
       sed '3 c\ > echo "${res[$i]}"' | xargs > /tmp/field-$((i+1))
Back to top
View user's profile Send private message Visit poster's website 
MochiMoppel


Joined: 26 Jan 2011
Posts: 1777
Location: Japan

PostPosted: Fri 08 Feb 2019, 00:08    Post subject:  

Instead of
Code:
echo "${res[$i]}" | xargs > /tmp/field-$((i+1))

try
Quote:
new=$(echo "${res[$i]}" | xargs)
sed -i "3s/.*/$new/" /tmp/field-$((i+1))

This assumes that the target file has a line 3, which sed will then replace with the field content.
Back to top
View user's profile Send private message 
lamplinux


Joined: 21 Jan 2019
Posts: 28

PostPosted: Fri 08 Feb 2019, 16:53    Post subject:  

Quote:
new=$(echo "${res[$i]}" | xargs)
sed -i "3s/.*/$new/" /tmp/field-$((i+1))

This assumes that the target file has a line 3, which sed will then replace with the field content.[/quote]

I tried code as written but, no file writing. 5 files with words on lines 1 through 4.

I will see if I can make some (roll of the dice mod" to your code and see what I get as output.

I appreciate your help as it gets me to research what the code is doing and learn from that.
Back to top
View user's profile Send private message Visit poster's website 
misko_2083


Joined: 08 Nov 2016
Posts: 64

PostPosted: Fri 08 Feb 2019, 18:58    Post subject:  

Bobby, Mochi's line should work, unless you are entering special characters in yad fields that mess up regular expressions or delimiter with sed later.
So you will want to escape them first.

Code:
for i in {0..4}; do
       new="$(echo "${res[$i]}" | xargs -I {} echo "{}" | sed -e 's/[]\/&$*.^[]/\\&/g')"
       sed -i "3s/.*/$new/" /tmp/field-$((i+1))
done
Back to top
View user's profile Send private message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 1777
Location: Japan

PostPosted: Fri 08 Feb 2019, 21:25    Post subject:  

- removed -
(was not directly related to lamplinux's issue)

Last edited by MochiMoppel on Sat 09 Feb 2019, 10:22; edited 1 time in total
Back to top
View user's profile Send private message 
lamplinux


Joined: 21 Jan 2019
Posts: 28

PostPosted: Fri 08 Feb 2019, 23:26    Post subject: My Life is now complete. Thank You :)  

@MochiMoppel @misko, I had to remove the backslashs between --field-1, --filed-2, etc. to get it to work. But, Dang it !!!! IT NOW WORKS !!! Whoo Whoo , Thank You Both !!!!!!!!!!!

Now its time to take over the world (or maybe not) but, lots of hours of fun time creating all kinds of fully user customizable Yad powered Launching and Bash Command solutions.

Have a Great Weekend ! I am very Happy !! All Thanks to you both. Cheers !!!!!!

Very Happy
Back to top
View user's profile Send private message Visit poster's website 
lamplinux


Joined: 21 Jan 2019
Posts: 28

PostPosted: Tue 12 Feb 2019, 22:57    Post subject: Focus - Automatic each --form --field user entry box  

I discovered that I can read current data to each field to a form entry box but, if user does not change the data, it is written back to the file as - blank space.

But, if I click in each field entry box, the read data then becomes an entry and saved properly back to same file.

?? Is there a way in Yad (or bash) to emulate a user clicking a box "like auto focus" for all --field boxes in a script - automatically ?

Last edited by lamplinux on Wed 13 Feb 2019, 02:37; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website 
Display posts from previous:   Sort by:   
Page 38 of 39 [581 Posts]   Goto page: Previous 1, 2, 3, ..., 36, 37, 38, 39 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.0669s ][ Queries: 13 (0.0167s) ][ GZIP on ]