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 Tue 22 Oct 2019, 07:19
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 46 of 50 [749 Posts]   Goto page: Previous 1, 2, 3, ..., 44, 45, 46, 47, 48, 49, 50 Next
Author Message
achim

Joined: 13 Apr 2017
Posts: 47
Location: Germany

PostPosted: Wed 21 Aug 2019, 18:49    Post subject: Create a continuous digital clock  

Hello, I would like to insert a continuous digital clock into a YAD title with --text-info. Can somebody help me with it?

Thanks in advance

achim

Last edited by achim on Wed 21 Aug 2019, 21:42; edited 1 time in total
Back to top
View user's profile Send private message 
stemsee

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

PostPosted: Wed 21 Aug 2019, 19:00    Post subject:  

hi Fred

yandex isnt working for me. Google not working for you. Script must have a bug!
Back to top
View user's profile Send private message MSN Messenger 
fredx181


Joined: 11 Dec 2013
Posts: 4125
Location: holland

PostPosted: Thu 22 Aug 2019, 04:09    Post subject:  

Nice work stemsee, working fine for me !!
Quote:
yandex isnt working for me. Google not working for you. Script must have a bug!

Google works again for me now, yes yandex often fails for me too.
I assume you mean the 'trans' script must have a bug ? (or maybe it's because of recent changes at the yandex end).
Hopefully it gets updated soon so yandex works again.

Fred

_________________
Dog Linux website
Tinylinux blog by wiak
Back to top
View user's profile Send private message 
misko_2083


Joined: 08 Nov 2016
Posts: 87

PostPosted: Thu 22 Aug 2019, 05:51    Post subject: Re: Create a continuous digital clock  

achim wrote:
Hello, I would like to insert a continuous digital clock into a YAD title with --text-info. Can somebody help me with it?

Thanks in advance

achim


Install/use wmctrl
Code:
#!/bin/bash

win_class="Achim"

yad --text-info --class="${win_class}" --title="Achim: $(date '+%T')" --width=300 & achims_pid=$!

trap "kill -s SIGUSR1 $achims_pid" EXIT

declare achim_xid

# need some time to register window class with X
while [[ ${achim_xid} == "" ]]; do
   # get Xwindow id
   achim_xid="$(wmctrl -lx | grep -e "yad.${win_class}" |  grep -oE "[0-9a-z]{10}")"
done

# convert to decimal number
achim_xid="$(echo $((${achim_xid})))"

while true
 do
   wmctrl -i -r "${achim_xid}" -N "Achim: $(date '+%T')" 2>/dev/null || break
   sleep 1
done

Last edited by misko_2083 on Thu 22 Aug 2019, 07:55; edited 1 time in total
Back to top
View user's profile Send private message 
stemsee

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

PostPosted: Thu 22 Aug 2019, 06:59    Post subject:  

Hi Fred et al

yes, trans script might have bug.

I want to implement another version which uses yad --notebook with tabs for each engines' result. My first effort failed! would be nice is all.

Also in the engine loop newline after do, by adding
Code:
echo "icon:/usr/share/pixmaps/$ex.png >$PIPE"
tray icon can show which engine is translating....of course need icons first.

Also the
Code:
echo -----^$ex $i^-----
should be at the head instead of underlining each translation in case of a large body of text.
Code:
echo -----$ex $i-----


regards
stemsee

EDIT hi Misko

wouldn't
Code:
while sleep 1; do
be better?
Back to top
View user's profile Send private message MSN Messenger 
achim

Joined: 13 Apr 2017
Posts: 47
Location: Germany

PostPosted: Thu 22 Aug 2019, 08:36    Post subject: Create a continuous digital clock  

Hello misko_2083,

your code works great.

Thank you for your help!

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


Joined: 11 Dec 2013
Posts: 4125
Location: holland

PostPosted: Thu 22 Aug 2019, 08:37    Post subject:  

Hi stemsee, good luck with the notebook version, don't think I can help, didn't do much with that.
Quote:
Also the
Code:
echo -----^$ex $i^-----
should be at the head instead of underlining each translation in case of a large body of text.
Code:
echo -----$ex $i-----


Yes, would be much better, also I like showing the full language names, so made the "trans_paste" function this(see pic):
Code:
trans_paste () {
#set -x
export TLANG=$(cat $HOME/.trans_target_lang2 2> /dev/null)
export _TLANG=$(cat $HOME/.trans_target_lang2 2> /dev/null | awk '{print $1}' | tr '\n' '+' | sed 's/.$//')
[ -z "$TLANG" ] && export TLANG="English - en"
export ENGINE=$(cat /tmp/_trans_engine_ 2> /dev/null)
[ -z "$ENGINE" ] && ENGINE=google
echo "Using $ENGINE for translating"
ICON="/tmp/trans-paste.svg"
if [ ! -e "$ICON" ]; then
   SVG="<""svg height='100' width='100'>
     <path style='fill:red;stroke:darkred;stroke-width:3;'
     d='M 93,62 C 83,82 65,96 48,96 32,96 19,89 15,79 L 5,90 5,53
     40,53 29,63 c 0,0 5,14 26,14 16,0 38,-15 38,-15 z'/>
     <path style='fill:red;stroke:darkred;stroke-width:3;'
     d='M 5,38 C 11,18 32,4 49,4 65,4 78,11 85,21 L 95,10 95,47
     57,47 68,37 C 68,37 63,23 42,23 26,23 5,38 5,38 z'/>
   </svg>"
   echo "$SVG" > /tmp/trans-paste.svg
fi
HELP=" Translating to $_TLANG... \n Press <b>ESC</b> key or click <b>EXIT</b> to dismiss."
MYTITLE="Trans"
BUT="<span color='darkblue'><b>Exit</b></span>"
FONT="Mono 12"
TWIDTH=$(xdpyinfo  | grep 'dimensions:' | cut -d' ' -f7 | cut -d'x' -f1)
SWIDTH=$(( $TWIDTH - 600 ))
#echo $SWIDTH
for ex in $ENGINE
do
while read i; do
echo " >  $ex translation to $(echo $i | awk '{print $1}'):"
xclip -o | trans -e $ex -b -tl $(echo $i | awk '{print $NF}')
done <<< "$TLANG"; done | tee >(yad \
--window-icon="$ICON" \
--text-align=center \
--title="$MYTITLE" \
--geometry=600x600+$SWIDTH+100 \
--fore="black" --back="#fef1e0" \
--margins=5 \
--button="$BUT" \
--text="$HELP" \
--fontname="$FONT" \
--text-info  --wrap)
}
export -f trans_paste


Fred
2019-08-22-143328_600x629_scrot.png
 Description   
 Filesize   61.75 KB
 Viewed   191 Time(s)

2019-08-22-143328_600x629_scrot.png


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

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

PostPosted: Thu 22 Aug 2019, 10:15    Post subject:  

Hi Fred

Is it possible to make the headings a different text color? If not I prefer the previous style!

The new code is difficult to understand, for me!

However _ _ _ _ _ Each to their own_ _ _ _ _ Laughing

stemsee

EDIT: I just discovered that google web translate has a character limit of about 3900! Maybe the script could be made to chunk xclip data accordingly?
Back to top
View user's profile Send private message MSN Messenger 
fredx181


Joined: 11 Dec 2013
Posts: 4125
Location: holland

PostPosted: Thu 22 Aug 2019, 10:28    Post subject:  

stemsee wrote:
Is it possible to make the headings a different text color? If not I prefer the previous style!

I'm almost sure that's not possible with the --text-info dialog. (e.g.cannot use <span...> etc..), but correct me if I'm wrong.
What exactly do you prefer then as "previous style" ?

EDIT:
Quote:
EDIT: I just discovered that google web translate has a character limit of about 3900! Maybe the script could be made to chunk xclip data accordingly?

Mmm.. that's a pity, not sure yet how to handle that.
BTW, I think it's better to remove Yandex from the translator choices, it really doesn't work well.

Fred

_________________
Dog Linux website
Tinylinux blog by wiak
Back to top
View user's profile Send private message 
misko_2083


Joined: 08 Nov 2016
Posts: 87

PostPosted: Thu 22 Aug 2019, 10:45    Post subject:  

stemsee wrote:

EDIT hi Misko

wouldn't
Code:
while sleep 1; do
be better?

Depends on the moment. Smile

fredx181 wrote:
stemsee wrote:
Is it possible to make the headings a different text color? If not I prefer the previous style!

I'm almost sure that's not possible with the --text-info dialog. (e.g.cannot use <span...> etc..), but correct me if I'm wrong.
What exactly do you prefer then as "previous style" ?

EDIT:
Quote:
EDIT: I just discovered that google web translate has a character limit of about 3900! Maybe the script could be made to chunk xclip data accordingly?


how about html? Smile
Code:
 echo "<h3>heading</h3><font color=red>some text</font>" | yad --html
Back to top
View user's profile Send private message 
stemsee

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

PostPosted: Thu 22 Aug 2019, 11:14    Post subject:  

Hi Fred, Misko et al

yad --html sounds like an interesting development!

by previous I meant the middle style.... not just _ _ _ _ dashes, but with $ex $i and placed as heading of translated text. I found that my eyes could more easily search and find each translated language section. but that's just my experience.

Indeed remove yandex ... maybe replace?? ... DeepL...?
stemsee
Back to top
View user's profile Send private message MSN Messenger 
fredx181


Joined: 11 Dec 2013
Posts: 4125
Location: holland

PostPosted: Thu 22 Aug 2019, 11:18    Post subject:  

misko wrote:
how about html? Smile
Code:
echo "<h3>heading</h3><font color=red>some text</font>" | yad --html


Ok, thanks, never did anything with the yad --html option, I think the compiled yad has to be configured with that, most yad packages (for e.g. Puppy or others) don't have this option by default, I think.

@stemsee
Quote:
The new code is difficult to understand, for me!

Not so difficult in fact, to explain:
At start of function:
Code:
export TLANG=$(cat $HOME/.trans_target_lang2 2> /dev/null)

$TLANG will output the full contents of $HOME/.trans_target_lang2
And further on:
Code:
while read i; do
echo " >  $ex translation to $(echo $i | awk '{print $1}'):"
xclip -o | trans -e $ex -b -tl $(echo $i | awk '{print $NF}')
done <<< "$TLANG";

Will extract the full language name, e.g. Spanish : $ex translation to $(echo $i | awk '{print $1}')
and the locale code to be used by trans, e.g. es : trans -e $ex -b -tl $(echo $i | awk '{print $NF}')

EDIT:
Quote:
by previous I meant the middle style.... not just _ _ _ _ dashes, but with $ex $i and placed as heading of translated text. I found that my eyes could more easily search and find each translated language section. but that's just my experience.


Ok, but how would you prefer exactly then as header, something like (or.. ?):
----- google translate to Bulgarian -----

I think deepl isn't supported by trans anymore.

Fred

_________________
Dog Linux website
Tinylinux blog by wiak

Last edited by fredx181 on Thu 22 Aug 2019, 11:44; edited 1 time in total
Back to top
View user's profile Send private message 
stemsee

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

PostPosted: Thu 22 Aug 2019, 11:39    Post subject:  

fredx181 wrote:

Ok, but how would you prefer exactly then as header, something like (or.. ?):
----- google translate to Bulgarian -----

Fred


Yes that's clearer!

EDIT 'tee >' is not needed
Back to top
View user's profile Send private message MSN Messenger 
stemsee

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

PostPosted: Thu 22 Aug 2019, 13:00    Post subject:  

I found the bug for google.

And I know why yandex is problematic.
Back to top
View user's profile Send private message MSN Messenger 
fredx181


Joined: 11 Dec 2013
Posts: 4125
Location: holland

PostPosted: Thu 22 Aug 2019, 13:17    Post subject:  

stemsee wrote:
I found the bug for google.

And I know why yandex is problematic.


So... what did you find then ?

_________________
Dog Linux website
Tinylinux blog by wiak
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 46 of 50 [749 Posts]   Goto page: Previous 1, 2, 3, ..., 44, 45, 46, 47, 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.1831s ][ Queries: 13 (0.1273s) ][ GZIP on ]