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 Thu 17 Oct 2019, 11:10
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 39 of 50 [742 Posts]   Goto page: Previous 1, 2, 3, ..., 37, 38, 39, 40, 41, ..., 48, 49, 50 Next
Author Message
MochiMoppel


Joined: 26 Jan 2011
Posts: 1921
Location: Japan

PostPosted: Wed 13 Feb 2019, 00:07    Post subject:  

???
Please give a small example.
In principle it should work, but that depends very much on your code.

At least this should work:
Code:
#!/bin/bash
echo 'apple pie
banana cake
peach ice' > /tmp/testo

res=$(yad --form --separator="\n" --field=1 --field=2 --field=3 --button="Save &amp; Exit:0"  --button=Cancel:1 < /tmp/testo)
(($?)) && exit            #exit here if exit status of yad > 0 (Save&Exit button was not pressed)
echo "$res" > /tmp/testo  #write back to file
Back to top
View user's profile Send private message 
lamplinux


Joined: 21 Jan 2019
Posts: 31

PostPosted: Thu 14 Feb 2019, 00:19    Post subject: Got my example code to work  

@MochiMoppel, Thank You but, I got the below script to work. Its mainly from code you guys provided. (without it, I'd never have anything working Smile ) But, I'm loving it ! Things are working and I'm learning too.

Now, to do this yad --dialog-separator --form --icon-read --notepad all in one window...

Since the input should be a numerical only, do I use the NUM for fields in below script ?

I also would like to have all four numbers currently saved in file, to display RO in 4 other form boxes but, I'll get that sure enough (I know I can Smile . Would I do that in a --pane window ?

Code:
#!/bin/bash
# backup IFS
OIFS=$IFS
configDir=/home/bobby/yadbash/sparkypad/config
# set IFS to newline char
IFS=$'\n'

posFile=$configDir/docks/dock-size-position/dock-size-pos
sizPosDir=$configDir/docks/dock-size-position

wideDocks=$(sed -n 1p < $sizPosDir/dock-size-pos)
hiDocks=$(sed -n 2p < $sizPosDir/dock-size-pos)
posxDocks=$(sed -n 3p < $sizPosDir/dock-size-pos)
posyDocks=$(sed -n 4p < $sizPosDir/dock-size-pos)

yad --form --separator="\n" --field="Width" "$wideDocks" --field="Height" "$hiDocks" --field="From Left" "$posxDocks" --field="From Top" "$posyDocks" --window-icon="start-here" --center --title="Dock Window Sizing" --button="Cancel":0 --button="Save":0 > $posFile

# get exit status
out=$?

# Restore IFS
IFS=$OIFS

# 0K (0), canceled (1) or closed dialog (252)

[ $out -ne 0 ] && exit 0
Back to top
View user's profile Send private message Visit poster's website 
lamplinux


Joined: 21 Jan 2019
Posts: 31

PostPosted: Thu 14 Feb 2019, 01:15    Post subject: Switching out directory of --icons --read-dir  

Is it possible using a While True or case event to swap out the icon directory in a yad window and have it automatically updated it because it uses --monitor ?


Code:
yad --dialog-sep --image="my-image.png" --width="700" --height="400" --center --window-icon=$HOME/icons/window-icon.png  --icons --read-dir=$HOME/ions/dock/config --monitor --single-click --item-width=70 --sort-by-name  --title="Config Utility" --text="Please Make Your Selection\n" --button="Config" --button="Bookmarks" --button="Music" --button="Images" --button="Videos" --button="Exit":1


Update: I could use a default directory and copy icons to and from the default directory each time a button is clicked. (Non Programmer way) Smile
Back to top
View user's profile Send private message Visit poster's website 
MochiMoppel


Joined: 26 Jan 2011
Posts: 1921
Location: Japan

PostPosted: Thu 14 Feb 2019, 05:11    Post subject: Re: Got my example code to work  

lamplinux wrote:
@MochiMoppel, Thank You but, I got the below script to work
It works? Your Cancel button does not work as it should (you assigned it the same 0 exit code as the Save button) and since you immediately redirect the yad output to $posFile without checking the exit code you will end up with an empty $posFile if you close the dialog with Alt+F4 or with the window's x button.

lamplinux, I can't see what you are asking for as you already answered some of your questions yourself.
In any case I'm a bit busy now but I'm sure some of our yad experts can help you much better than I can.
Back to top
View user's profile Send private message 
lamplinux


Joined: 21 Jan 2019
Posts: 31

PostPosted: Thu 14 Feb 2019, 20:46    Post subject: Using images with --button=  

Just mentioning this because I happened upon it by accident hacking yad code

Code:
export imageDir=/home/user/images

go_imagebutton() {
     cd  $HOME/bobby
     ls -l
}
export -f go_imagebutton

--button="!$imageDir/bobby.png!Bobby Button":"bash -c go_imagebutton"


Example output:

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


Joined: 21 Jan 2019
Posts: 31

PostPosted: Thu 21 Feb 2019, 12:24    Post subject: How would I use Yad as a Wrapper for a program  

I'm trying to wrap Yad around mpv to play videos: Here's my code that does not work.

No examples on web anywhere.

(update: I have looked at code in miskos wrapper for youtube-dl but, I don't understand and its so complicated)

Code:
mpv /home/bobby/Videos/* | yad2 --dialog-sep --image="/home/bobby/yadbash/sparkypad/images/side-banners/niklback-revolution.png" --undecorated --geometry=1366x560+1+1  --title="Sparkpad Images" --border=0 --skip-taskbar
Back to top
View user's profile Send private message Visit poster's website 
vovchik


Joined: 23 Oct 2006
Posts: 1504
Location: Ukraine

PostPosted: Thu 21 Feb 2019, 12:51    Post subject:  

Dear lamplinux,

I cobbled this together for my own purposes and use it regularly:

Code:
#!/bin/bash

# ****************************************************************
# PROGRAM:      gmpv
# PURPOSE:      yad-based gui wrapper for mpv (URL or file)
# AUTHOR:       vovchik, November 2018
# DEPENDENCIES: bash, yad, mpv
# VERSION:      0.1c
# ****************************************************************


# ***********************
# INITIALIZATION
# ***********************

# create icon and copy to /tmp/mpv.svg
LOAD=""
TITLE="Wait..."
TXT="Loading video..."
TMP="/tmp/gmpv.txt"
SEARCH="VO:"
rm "$TMP"
# search for "VO:"
SVG="<svg width='48' height='48' viewBox='0 0 100 100'>
 <linearGradient id='l1' gradientUnits='objectBoundingBox'
  x1='1' x2='1' y1='0' y2='1'>
  <stop stop-color='skyblue' offset='1'/>
  <stop stop-color='white' offset='0'/>
 </linearGradient>
 <path style='fill:#111111' d='M 10,3.1 10,97 90,97 90,3.1 z m 4,5.9
  6,0 0,5 -6,0 z m 66,0 6,0 0,5 -6,0 z m -66,11 6,0 0,5 -6,0 z m 66,0
  6,0 0,5 -6,0 z m -66,11 6,0 0,5 -6,0 z m 66,0 6,0 0,5 -6,0 z m -66,11
  6,0 0,5 -6,0 z m 66,0 6,0 0,5 -6,0 z m -66,11 6,0 0,5 -6,0 z m 66,0
  6,0 0,5 -6,0 z m -66,11 6,0 0,5 -6,0 z m 66,0 6,0 0,5 -6,0 z m -66,11
  6,0 0,5 -6,0 z m 66,0 6,0 0,5 -6,0 z m -66,11 6,0 0,5 -6,0 z m 66,0
  6,0 0,5 -6,0 z'/>
 <path style='fill:url(#l1)' d='m 23,5 54,0 0,26 -54,0 z m 0,29 54,0
  0,28 -54,0 z m 0,31 54,0 0,30 -54,0 z'/>
</svg>"
IMAGE="/home/vovchik/my-documents/anim/c1.gif"
ICON="/tmp/mpv.svg"
if [ ! -e "$ICON" ]; then
   echo "$SVG" > /tmp/mpv.svg
fi
FONT="DejaVu Sans Mono Bold 14"
BUT="<span color='black'>Close</span>!!Close window"
NL="
"
results=""
get_url="$@"
LINE_COUNT=""
HELP="<b>Gmpv</b> needs an input argument.
Enter file/URL or '<b>?</b>' for help:"
ABOUT=$(mpv --list-options)
ERROR="$NL""<b>WARNING!</b>""$NL -----
Install <b>mpv</b> before""$NL""running this program.""$NL"
export SVG ICON FONT BUT NL HELP ABOUT results get_url SEARCH TMP IMAGE TITLE TXT LOAD

# ***********************
# END INITIALIZATION
# ***********************


# ***********************
# FUNCTIONS
# ***********************

# -----------------------
function GET_URL()
# -----------------------
{
   get_url=$(yad \
      --entry \
      --title="Play URL" \
      --text="$HELP" \
      --entry-text "$get_url" \
      --window-icon="$ICON" \
      --image="$ICON" \
      --image-on-top \
      --center \
      --margins=5 \
      --width=400 \
      --fontname="$FONT" \
      --text-info \
      --title="Mpv Gui" \
      --buttons-layout=end \
      --button="Play!!Play this URL":0 \
      --button="Quit!!Click to quit this little program":1 \
      --editable)
}; export -f GET_URL

# -----------------------
function SHOW_RESULTS()
# -----------------------
{
   echo "Play: $get_url"

   if [[ -z $get_url ]];then
      echo "No URL. Bye-bye."
      exit 1
   elif [[ "$get_url" = "?" || "$get_url" = " " ]];then
      # about box
      results="$ABOUT"
      echo "$results"
      echo "About:    mpv$NL$NL$results" | \
      yad \
      --window-icon="$ICON" \
      --geometry=700x550+300+100 \
      --title="Mpv About" \
      --tail \
      --text-info \
      --fore="black" \
      --back="#FFF7F7" \
      --margins=5 \
      --button="$BUT" \
      --fontname="DejaVu Sans Mono 13" \
      --autoscroll -
   else
      mpv "$get_url" >> "$TMP" &
      while  [ -z "$LOAD" ]; do
         LOAD=$(grep "$SEARCH" /tmp/gmpv.txt)
         echo running
         sleep 0.5
      done | yad \
      --progress \
      --title="$TITLE" \
      --picture \
      --size=orig \
      --filename="$IMAGE" \
      --width=280 \
      --height=190 \
      --pulsate \
      --center \
      --inc=2 \
      --no-buttons \
      --auto-close \
      --auto-kill \
      --undecorated \
      --text-align=center \
      --window-icon="$ICON" \
      --text="<b>Loading video...</b>"
   fi
}; export -f SHOW_RESULTS

# -----------------------
function SHOW_ERROR()
# -----------------------
{
   yad \
   --window-icon="$ICON" \
   --title="Mpv Gui" \
   --image-on-top \
   --center \
   --image="$ICON" \
   --text-align="center" \
   --text="$ERROR" \
   --button="$BUT"
}; export -f SHOW_ERROR

# ***********************
# END FUNCTIONS
# ***********************


# ***********************
# MAIN
# ***********************

if [ $(which mpv) ]; then
   while true; do
      GET_URL
      SHOW_RESULTS
   done
else
   echo "mpv was not found. Please install it."
   SHOW_ERROR
fi

# ***********************
# END MAIN
# ***********************


Change the image paths in the script and desktop, and it should work for you too.

With kind regards,
vovchik

UPDATED: Fixed the script above and in the archive to run mpv and not smplayer.
gmpv.tar.gz
Description 
gz

 Download 
Filename  gmpv.tar.gz 
Filesize  10.76 KB 
Downloaded  55 Time(s) 

Last edited by vovchik on Fri 22 Feb 2019, 06:41; edited 1 time in total
Back to top
View user's profile Send private message 
lamplinux


Joined: 21 Jan 2019
Posts: 31

PostPosted: Thu 21 Feb 2019, 14:38    Post subject: Yad Video Wrapper  

@vovchik - Thank You so much. I will use your script tonight and learn from your code.
Back to top
View user's profile Send private message Visit poster's website 
vovchik


Joined: 23 Oct 2006
Posts: 1504
Location: Ukraine

PostPosted: Thu 21 Feb 2019, 17:40    Post subject:  

Dear lamplinux,

You will see places in the code where I commented out mpv and used smplayer instead. Originally, I did it for mpv, and everything worked that way just fine, so just commnet out the smplayer lines and use the commented-out mpv ones. Smile

With kind regards,
vovchik
Back to top
View user's profile Send private message 
lamplinux


Joined: 21 Jan 2019
Posts: 31

PostPosted: Thu 21 Feb 2019, 22:46    Post subject:  

@vovchik, Yes, I noticed Committing out of mpv and switched it to mpv. Testing right now.
Back to top
View user's profile Send private message Visit poster's website 
lamplinux


Joined: 21 Jan 2019
Posts: 31

PostPosted: Fri 22 Feb 2019, 03:31    Post subject: Menu Context Command --html "open"  

What is the command that is used to get the URL window to open in the Yad --html Dialog ?

For example, Right Click --> in --html Dialog --> Context Menu = "Open"
Back to top
View user's profile Send private message Visit poster's website 
step

Joined: 04 May 2012
Posts: 1207

PostPosted: Fri 01 Mar 2019, 01:39    Post subject:  

Yad 0.42.0 was released last week https://github.com/v1cont/yad/releases. New features and bug fixes.
It's the last version with gtk2 support.
yad's author wrote:

upcoming release (0.42.0) will be the last release with gtk2 support. next releases will depends on gtk 3.22 (with porting to gtk4 in mind) and with versioning in format X.Y where X - a current version, starting from 1, and Y - current patchset.

dialog set will be hardly modified, for example, entry will be dropped, and both progress dialogs will be merged into a single one and some gtk3 specific dialogs like appchooser will be implemented. predefined (aka stock) items will have prefix yad-, and must be translated with yad, so any help with this will be highly appreciated.

support of tray icon will be a compile-time option, and may be dropped too in a future.


_________________
Fatdog64-802|+Packages|Kodi|Findnrun|+forum|gtkmenuplus
Back to top
View user's profile Send private message 
stemsee

Joined: 27 Jun 2013
Posts: 2483
Location: In The Way

PostPosted: Mon 04 Mar 2019, 15:48    Post subject:  

How can it be known which tab is selected in a multi-tabbed yad gui. So that the Yad frame which swallows the tabs, and has several buttons can assign the buttons to work in the selected tab, maybe differently than when in another tab? Is it possible without closing and reopening?
Back to top
View user's profile Send private message MSN Messenger 
step

Joined: 04 May 2012
Posts: 1207

PostPosted: Thu 07 Mar 2019, 05:56    Post subject:  

stemsee wrote:
How can it be known which tab is selected in a multi-tabbed yad gui. So that the Yad frame which swallows the tabs, and has several buttons can assign the buttons to work in the selected tab, maybe differently than when in another tab? Is it possible without closing and reopening?

Not exactly what you're looking for but close. I found this short video that demonstrates a navigation system. You'd have to contact the site's author for more info. My guess is that it's implemented as paned top/bottom dialog. The top section looks like an --icons box. The bottom section looks like a multi-button --form. Top and bottom can communicate via a FIFO. Top section listens on the FIFO like this (untested):

yad --icons --listen --plug=1234 &

Any button of the bottom form would then write (to the FIFO): Ctrl-J followed by the list of new icons/commands (see yad help for Iconbox for details). This effectively would switch the contents of the top section.

Caveat: I'm guessing the whole thing.

You could replace --icons in the top section with any other yad widget that accepts --listen and can be reset by sending Ctrl-J to it. For instance, --list satisfies both conditions. You couldn't put a --notebook in the top section.

_________________
Fatdog64-802|+Packages|Kodi|Findnrun|+forum|gtkmenuplus
Back to top
View user's profile Send private message 
step

Joined: 04 May 2012
Posts: 1207

PostPosted: Thu 07 Mar 2019, 05:56    Post subject:  

stemsee wrote:
How can it be known which tab is selected in a multi-tabbed yad gui. So that the Yad frame which swallows the tabs, and has several buttons can assign the buttons to work in the selected tab, maybe differently than when in another tab? Is it possible without closing and reopening?

Not exactly what you're looking for but close. I found this short video that demonstrates a navigation system. You'd have to contact the site's author for more info. My guess is that it's implemented as paned top/bottom dialog. The top section looks like an --icons box. The bottom section looks like a multi-button --form. Top and bottom can communicate via a FIFO. Top section listens on the FIFO like this (untested):

yad --icons --listen --plug=1234 &

Any button of the bottom form would then write (to the FIFO): Ctrl-J followed by the list of new icons/commands (see yad help for Iconbox for details). This effectively would switch the contents of the top section.

Caveat: I'm guessing the whole thing.

You could replace --icons in the top section with any other yad widget that accepts --listen and can be reset by sending Ctrl-J to it. For instance, --list satisfies both conditions. You couldn't put a --notebook in the top section.

_________________
Fatdog64-802|+Packages|Kodi|Findnrun|+forum|gtkmenuplus
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 39 of 50 [742 Posts]   Goto page: Previous 1, 2, 3, ..., 37, 38, 39, 40, 41, ..., 48, 49, 50 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.1522s ][ Queries: 12 (0.0870s) ][ GZIP on ]