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 Mon 18 Jun 2018, 06:09
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 24 of 29 [424 Posts]   Goto page: Previous 1, 2, 3, ..., 22, 23, 24, 25, 26, 27, 28, 29 Next
Author Message
matchpoint

Joined: 26 Jan 2018
Posts: 169

PostPosted: Sat 10 Feb 2018, 12:34    Post subject:  

Ha! I forgot to save the paste before running.

That the console now complains with "--text-align=center" tells me we have a Zenity/YAD version difference, right?

I've come across these type messages before.

Ultimately though, I'd like the choice selection to be made like in the original, by keystroke, not mouse click.

Maybe one more example, Fred. Then I think I may be able to run with it.
Back to top
View user's profile Send private message 
fredx181


Joined: 11 Dec 2013
Posts: 3092
Location: holland

PostPosted: Sat 10 Feb 2018, 12:50    Post subject:  

matchpoint wrote:
Ha! I forgot to save the paste before running.

That the console now complains with "--text-align=center" tells me we have a Zenity/YAD version difference, right?

I've come across these type messages before.

Ultimately though, I'd like the choice selection to be made like in the original, by keystroke, not mouse click.

Maybe one more example, Fred. Then I think I may be able to run with it.


Probably Zenity doesn't have "--text-align=center" Question , btw, I removed that from script above to be compatible with older yad versions. (see also edit in my previous post)

Let me understand, you want to run the script in terminal, type 1 or 2 and the rest by YAD gui, or do you want to type the temperature also in terminal and use YAD only for the final output ?

Fred

_________________
Dog Linux website

Last edited by fredx181 on Sat 10 Feb 2018, 13:31; edited 1 time in total
Back to top
View user's profile Send private message 
matchpoint

Joined: 26 Jan 2018
Posts: 169

PostPosted: Sat 10 Feb 2018, 13:05    Post subject:  

Fred, thanks and relax. I'll get back to this little later.
Back to top
View user's profile Send private message 
fredx181


Joined: 11 Dec 2013
Posts: 3092
Location: holland

PostPosted: Sat 10 Feb 2018, 13:13    Post subject:  

Hi matchpoint, I think I sort of get it now what you'd like, anyway here's another with 2 boxes where you can type in the choices, ok, I'll relax now Wink

Code:
#!/bin/bash

SETUP=`yad --title="Temperature scale conversion" --center --text="<b>*** Temperature scale conversion ***</b> \n Type 1 to convert Celsius to Fahrenheit \n Type 2 to convert Fahrenheit to Celsius" \
--width=400 \
--window-icon="preferences-system" --form  \
--field=" Type 1 or 2: : " "" \
--field=" Type temperature: : " "" \
--button="gtk-cancel:1" --button="gtk-ok:0"`
[[ $? -ne 0 ]] && exit 1

export CHOICE=$(echo $SETUP | cut -d "|" -f 1)
export TEMP_=$(echo $SETUP | cut -d "|" -f 2)

case $CHOICE in
1)
  tc=$TEMP_
  # formula Tf=(9/5)*Tc+32
  tf=$(echo "scale=2;((9/5) * $tc) + 32" |bc)
  echo "$tc C = $tf F" | yad --title="Celsius to Fahrenheit" --center --text-info --width=300 --button="gtk-close:0"
;;
2)
  tf=$TEMP_
  # formula Tc=(5/9)*(Tf-32)
  tc=$(echo "scale=2;(5/9)*($tf-32)"|bc)
  echo "$tf F = $tc C" | yad --title="Fahrenheit to Celsius" --center --text-info --width=300 --button="gtk-close:0"
;;
esac


Fred

_________________
Dog Linux website
Back to top
View user's profile Send private message 
matchpoint

Joined: 26 Jan 2018
Posts: 169

PostPosted: Sat 10 Feb 2018, 16:27    Post subject:  

Fred, I'd like the dialog to run and read like my script, except with one line spacings between each entry and not yet requesting temperature input until a choice has been made. Once made however, the dialog should then switch to an "Enter temperature (C/F)" sequence, rest for 3 or so seconds after user input, then exit, effectively removing the need to "Press any key to exit."

Very Happy Can do?

You know, even this script I have should sign off like how I've described.

And how do I get spacing between lines when dumping to stdout?

Like between these opening echos?
Code:
#!/bin/bash

echo "*** Temperature scale conversion ***"
echo "Convert Celsius to Fahrenheit = 1"
echo "Convert Fahrenheit to Celsius = 2"
echo -n "Select 1 or 2, then Enter:"
read choice

if [ $choice -eq 1 ]
then
  echo -n "Enter temperature (C) : "
  read tc
  # formula Tf=(9/5)*Tc+32
  tf=$(echo "scale=2;((9/5) * $tc) + 32" |bc)
  echo "$tc C = $tf F"
elif [ $choice -eq 2 ]
then
  echo -n "Enter temperature (F) : "
  read tf
  # formula Tc=(5/9)*(Tf-32)
  tc=$(echo "scale=2;(5/9)*($tf-32)"|bc)
  echo "$tf F = $tc C"
else
  echo "Please select 1 or 2 only"
  exit 1
fi

echo -n "
-->  Press any key to exit "
read echoice

exit 0
Back to top
View user's profile Send private message 
matchpoint

Joined: 26 Jan 2018
Posts: 169

PostPosted: Sat 10 Feb 2018, 16:49    Post subject:  

Check!
Code:
echo -e ' \t '
excellent.jpg
 Description   
 Filesize   29.6 KB
 Viewed   385 Time(s)

excellent.jpg

Back to top
View user's profile Send private message 
fredx181


Joined: 11 Dec 2013
Posts: 3092
Location: holland

PostPosted: Sun 11 Feb 2018, 09:18    Post subject:  

matchpoint wrote:
Very Happy Can do?


Hi matchpoint, sorry, I keep misunderstanding what you'd like to accomplish, maybe someone else understands.
Perhaps best to try make script yourself with gui dialog commands included and show that (even if doesn't work as you like, anyway then it's clear where the gui dialog part should be)

Fred

_________________
Dog Linux website
Back to top
View user's profile Send private message 
matchpoint

Joined: 26 Jan 2018
Posts: 169

PostPosted: Sun 11 Feb 2018, 11:55    Post subject:  

No worries Fred. I appreciate your time and the examples you've provided.

Proost en een goede gezondheid!
Back to top
View user's profile Send private message 
misko_2083


Joined: 08 Nov 2016
Posts: 41

PostPosted: Mon 12 Feb 2018, 02:18    Post subject:  

matchpoint, there is this script
https://www.gnome-look.org/content/show.php/YAD+Tempconverter?content=174312
I've had a quick look and it does what you need. Plus, it checks if you enter the temerature bellow the absolute zero.
Back to top
View user's profile Send private message 
stemsee

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

PostPosted: Sun 18 Feb 2018, 13:26    Post subject:  

I found the solution to my request, which was how to use yad --list --listen to receive data to replace existing data without closing and re-opening the yad gui.

I wonder how this will work in the tabbed version?
Code:
echo -e '\f' > /tmp/pipe

clears all data. No the same as updating existing data. Empty and refill.[/code]
Back to top
View user's profile Send private message MSN Messenger 
step

Joined: 04 May 2012
Posts: 1044

PostPosted: Mon 19 Feb 2018, 08:47    Post subject:  

stemsee wrote:

I wonder how this will work in the tabbed version?
Code:
echo -e '\f' > /tmp/pipe
Yes, it works for a tabbed dialog, as long as you write to the pipe of the contained yad --list process. When the container dialog exits, it outputs the current contents of the list widget having erased everything before the \f. In some cases involving multiple columns I had to use \f\n instead of \f.
_________________
Fatdog64-721|+Packages|Kodi|Findnrun|+forum|gtkmenuplus
Back to top
View user's profile Send private message 
fredx181


Joined: 11 Dec 2013
Posts: 3092
Location: holland

PostPosted: Mon 19 Feb 2018, 15:09    Post subject:  

stemsee wrote:
I found the solution to my request, which was how to use yad --list --listen to receive data to replace existing data without closing and re-opening the yad gui. .


Could you provide a simple example of why/how this can be useful ? (also, with tabbed dialog I'd like to understand also)

Thanks,

Fred

_________________
Dog Linux website
Back to top
View user's profile Send private message 
stemsee

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

PostPosted: Mon 19 Feb 2018, 16:04    Post subject:  

Thanks step! I haven't had a chance to try that out yet.

Here is yad 40.3 with html (webkit) 64bit compiled on fatdog 721
https://drive.google.com/open?id=11DrgG_Z5lKJzit8G-Qj1ZxiJogqlHS8A

Hi Fred

A lot of your yad GUIs like the ones for gdrive need to refresh update the data in the list field, normally you close the dialog gui and open a new one ... now you don't have to, as the fields are emptied and then refilled by using --list --listen <pipe to receive new data. One advantage as in wifi-scanner is that the gui can be placed and resized only once without fear of it re-opening somewhere differen on your desktop (manageability).

Here is what I needed it for (demo). Victor Ananjetsky kindly posted an answer to me!

In this example if you select with checkboxes on 'OK' gui closes and all checked rows are printed to stdout. Note '--dclick-action' I set to output to /tmp/net only one row which is double clicked, meaning the gui stays open with fresh scan results updated every 8 seconds in my while true loop.

Hope it helps.

Code:
#!/bin/bash
#Victor Ananjesky script adapted by stemsee for wifi scanning
#
test -e /tmp/yadpipe03 && rm -f /tmp/yadpipe03

# Named pipe initialization
export PIPE_03=/tmp/yadpipe03
mkfifo $PIPE_03
exec 3<> $PIPE_03

function clear_all
{
PATTERN='
s/^.*Address: ([0-9A-Z:]*)/\n\1/p
s/^.*Quality=([^ ]*).*Signal level=(.*)/\1 \2/p
s/^.*key:([onf]*)/~\1~/p
s/^.*ESSID://p'
while true
do
  iwlist wlan4 scan | sed -rn "$PATTERN" | tac > $PIPE_03
  sleep 8
  echo -e '\f'
done
}
export -f clear_all

# Main Dialog
Record=($(yad --list --separator="|" --grid-lines=hor \
    --width=300 --height=200 --center \
    --title="Wifi-Scanner" \
    --text="Example" \
    --dclick-action=echo -e $1 > /tmp/net \
    --column "AP ssid" --column "Encryption" --column "qualiy/strength" --column "bssid" --column "Check:CHK"\
    --button="Start Scannning!gtk-clear":'bash -c "clear_all > $PIPE_03"' \
    --button="OK!gtk-ok":0 \
    --listen --print-all < $PIPE_03))
Action=$?

echo ${Record[@]}
Back to top
View user's profile Send private message MSN Messenger 
fredx181


Joined: 11 Dec 2013
Posts: 3092
Location: holland

PostPosted: Tue 20 Feb 2018, 07:31    Post subject:  

Thanks Stemsee !
Nice, refresh while window stays open.
What I actually would like is a button to process an item (instead double click action) while the window stays open.
Do you know if that's possible ? (tried some things, but couldn't manage).
EDIT: Found this, which works similar (window stays open), but it also has only option double-click action.
https://sourceforge.net/p/yad-dialog/wiki/Frontend%20for%20find%2Bgrep%20commands/?limit=50

Fred

_________________
Dog Linux website
Back to top
View user's profile Send private message 
stemsee

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

PostPosted: Tue 20 Feb 2018, 11:28    Post subject:  

Back to top
View user's profile Send private message MSN Messenger 
Display posts from previous:   Sort by:   
Page 24 of 29 [424 Posts]   Goto page: Previous 1, 2, 3, ..., 22, 23, 24, 25, 26, 27, 28, 29 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.0984s ][ Queries: 13 (0.0291s) ][ GZIP on ]