Page 37 of 76
vary the width opf combobox
Posted: Thu 07 Mar 2013, 01:27
by don570
I've discovered how to vary the width of the combobox at
the time of launch of the script.
A practical example is
Bulldog finder, which widens up
when it is launched with a folder path as an argument $1
As an example I change the width based on whether my app has an
argument $1
Code: Select all
export WIDTH=240
[ -z "$1" ] && WIDTH=150]
then while building the combobox
Code: Select all
<combobox case-sensitive="false" value-in-list="true" width-request="'$WIDTH'">
.
DYCP Effect
Posted: Fri 15 Mar 2013, 19:48
by SFR
Ah, the good old C64 times...
Does anyone remember DYCP (Different Y Character Position) effect?
It seems that Bash+Gtkdialog+SVG are powerful enough for that - here's an example (save it with
.sh extension or else ROX will identify it as .svg file):
Code: Select all
#!/bin/bash
# DYCP example by SFR'2013
export SINUS=/dev/shm/sinus_table
[ -e $SINUS ] && rm $SINUS
# Create sinus table
for i in {0..63}; do
RAD=`echo "$i*(3.14/32)" | bc -l`
VAL=`echo "s($RAD) * 48 + 72" | bc -l`
echo ${VAL/.*} >> $SINUS
done
dycp () {
SIN=( `cat $SINUS` )
echo '<svg width="256" height="128" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<text font-family="Monospace" font-size="32" font-weight="bold">
<tspan x="10" y="'${SIN[0]}'">P</tspan>
<tspan x="30" y="'${SIN[2]}'">U</tspan>
<tspan x="50" y="'${SIN[4]}'">P</tspan>
<tspan x="70" y="'${SIN[6]}'">P</tspan>
<tspan x="90" y="'${SIN[8]}'">Y</tspan>
<tspan x="130" y="'${SIN[12]}'">L</tspan>
<tspan x="150" y="'${SIN[14]}'">I</tspan>
<tspan x="170" y="'${SIN[16]}'">N</tspan>
<tspan x="190" y="'${SIN[18]}'">U</tspan>
<tspan x="210" y="'${SIN[20]}'">X</tspan>
<tspan x="230" y="'${SIN[22]}'">!</tspan>
</text>
</svg>' > /dev/shm/dycp_pic.svg
# Shift array right
echo ${SIN[63]} ${SIN[@]:0:63} > $SINUS
}
export -f dycp && dycp
export MAIN='
<window title="DYCP">
<vbox>
<pixmap>
<variable>PICTURE</variable>
<input file>/dev/shm/dycp_pic.svg</input>
</pixmap>
<button ok></button>
<timer visible="false" milliseconds="true" interval="50">
<action>dycp</action>
<action>refresh:PICTURE</action>
</timer>
</vbox>
</window>
'
gtkdialog -cp MAIN
Of course it's rather pointless (and resource hungry), but personally I love such things!
_________________
EDIT: Ok, I wouldn't be myself if I wouldn't go further - here's DYCP-Scroller:
Code: Select all
#!/bin/bash
# DYCP Scroll by SFR'2013
export TEXT=" Hey! This is probably the very first DYCP-Scroller for Puppy Linux. ;) Greetings!"
TEMPDIR=/dev/shm/dycp_scroll_$$
mkdir $TEMPDIR
trap 'rm -rf $TEMPDIR' EXIT
export PIC=$TEMPDIR/pic.svg
export SINUS=$TEMPDIR/sinus_table
export X_POS=$TEMPDIR/dycp_x
export TEXT_POS=$TEMPDIR/text_position
echo 0 > $X_POS
echo 0 > $TEXT_POS
# Create sinus table
for i in {0..63}; do
RAD=`echo "$i*(3.14/32)" | bc -l`
VAL=`echo "s($RAD) * 48 + 72" | bc -l`
echo ${VAL/.*} >> $SINUS
done
dycp () {
SIN=( `cat $SINUS` )
read X < $X_POS
read POS < $TEXT_POS
echo '<svg width="256" height="128" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<text font-family="Monospace" font-size="32" font-weight="bold">
<tspan x="'$((10-$X))'" y="'${SIN[0]}'">'${TEXT:$POS:1}'</tspan>
<tspan x="'$((30-$X))'" y="'${SIN[2]}'">'${TEXT:$(($POS+1)):1}'</tspan>
<tspan x="'$((50-$X))'" y="'${SIN[4]}'">'${TEXT:$(($POS+2)):1}'</tspan>
<tspan x="'$((70-$X))'" y="'${SIN[6]}'">'${TEXT:$(($POS+3)):1}'</tspan>
<tspan x="'$((90-$X))'" y="'${SIN[8]}'">'${TEXT:$(($POS+4)):1}'</tspan>
<tspan x="'$((110-$X))'" y="'${SIN[10]}'">'${TEXT:$(($POS+5)):1}'</tspan>
<tspan x="'$((130-$X))'" y="'${SIN[12]}'">'${TEXT:$(($POS+6)):1}'</tspan>
<tspan x="'$((150-$X))'" y="'${SIN[14]}'">'${TEXT:$(($POS+7)):1}'</tspan>
<tspan x="'$((170-$X))'" y="'${SIN[16]}'">'${TEXT:$(($POS+8)):1}'</tspan>
<tspan x="'$((190-$X))'" y="'${SIN[18]}'">'${TEXT:$(($POS+9)):1}'</tspan>
<tspan x="'$((210-$X))'" y="'${SIN[20]}'">'${TEXT:$(($POS+10)):1}'</tspan>
<tspan x="'$((230-$X))'" y="'${SIN[22]}'">'${TEXT:$(($POS+11)):1}'</tspan>
<tspan x="'$((250-$X))'" y="'${SIN[24]}'">'${TEXT:$(($POS+12)):1}'</tspan>
</text>
</svg>' > $PIC
X=$(($X+2))
if [ $X = 20 ]; then
X=0
POS=$(($POS+1)); [ $POS -gt ${#TEXT} ] && POS=0
echo ${SIN[@]:1:63} ${SIN[0]} > $SINUS
else
echo ${SIN[63]} ${SIN[@]:0:63} > $SINUS
fi
echo $X > $X_POS
echo $POS > $TEXT_POS
}
export -f dycp && dycp
export MAIN='
<window title="DYCP Scroller">
<vbox>
<pixmap>
<variable>PICTURE</variable>
<input file>'$PIC'</input>
</pixmap>
<button ok></button>
<timer visible="false" milliseconds="true" interval="50">
<action>dycp</action>
<action>refresh:PICTURE</action>
</timer>
</vbox>
</window>
'
gtkdialog -cp MAIN
Have fun & Greetings!
Posted: Fri 15 Mar 2013, 22:53
by zigbert
like it
The days of C64 were sure wonderful. The coding wasn't meant to be useful - only cool.
Thank you for sharing
Sigmund
Posted: Sun 17 Mar 2013, 16:02
by vovchik
Dear SFR,
That was an impressive bit of coding. I ported it to BaCon, with a few mods to reduce file reads/writes, and it works nicely. Thanks. Now to find a good use for this lovely routine
With kind regards,
vovchik
http://www.murga-linux.com/puppy/viewto ... 604#692604
Posted: Sun 17 Mar 2013, 21:29
by SFR
Thanks guys!
I guess I also miss the old days, because computers' capabilities were very limited and there was a challenge - to crush those limits!
For instance - see how
amazing gfx can still be created in ancient 320x256x32 (my_jaw_dropped).
[sorry for being a bit off-topic]
@Vovchik - Bacon version works OOTB on Slacko, no recompiling needed; nice work!
Greetings!
Posted: Wed 20 Mar 2013, 16:24
by thunor
@SFR: Awesome work
I'd like to add those to the gtkdialog repository so is it okay and what is the licence? GPL2 would be good.
Regards,
Thunor
Posted: Wed 20 Mar 2013, 17:03
by SFR
Thanks
Sure, and GPL2 is fine.
Greetings!
Always on top or underneath
Posted: Thu 21 Mar 2013, 02:55
by brokenman
I cut my teeth on a C64. I remember the 20min load times from an external cassette reader for some games like ghost busters. Good times.
I'd like to know if it is possible to launch a gtkdialog app and have it always underneath all other apps, as opposed to always on top? I mean to say if i click the gtkdialog app it will not come to the front but remain at the back under all other apps on the desktop layer. The app is a desklet type thing that i want to remain on the desktop.
Posted: Thu 21 Mar 2013, 06:17
by 01micko
Hello brokenman
maybe try gtkdesklets by akash_rawal, supports transparency too. Ah..but you've been there! Did it not work?
There is code earlier in that thread that I used with raw gtkdialog, I wrote a weather widget , broken now of course due to the change in the sites html, but nevertheless may give you an idea
http://murga-linux.com/puppy/viewtopic. ... 629#598629.. plus even earlier there is a basic RAM widget. I got bored with widgets though after that!
Posted: Sat 23 Mar 2013, 02:47
by brokenman
Thanks very much. Your gtkdesklet seems to remain on the desktop layer and doesn't come to the front when clicked which is exactly what i need! Now i just need to scour your code to see what makes it stay there. I am using the gtkdesklet applet but my applet doesn't behave in the manner i want (staying in background).
Posted: Sun 24 Mar 2013, 12:42
by vovchik
Dear SFR,
I re-did one of your wave examples only to use markup - no svgs - and obtain the same wave effect using the little-used span markup command "rise". It gives you a y-axis displacement in "pango" units. I also use the span attrobute "letter_spacing" for the x axis (in 1024th of a point). My code is attached.
With kind regards,
vovchik
Posted: Sun 24 Mar 2013, 18:37
by SFR
Hey Vovchik
Thanks for the tip, I had no idea about this 'rise' attribute.
And, what's most important, it works also in Gtkdialog:
Code: Select all
#!/bin/bash
# DYCP 2 by SFR'2013
# Uses Vovchik's tip: markup "rise" attribute instead of svg
# GPL v2 applies
TEMPDIR=/dev/shm/dycp_$$
mkdir $TEMPDIR
trap 'rm -rf $TEMPDIR' EXIT
export SINUS=$TEMPDIR/sinus_table
# Create sinus table
for i in {0..63}; do
RAD=`echo "$i*(3.14/64)" | bc -l`
SIN[$i]=$(printf "%.0f" $(echo "((s($RAD)*100)+10)*1024" | bc -l))
done
echo ${SIN[@]} > $SINUS
# -----------------------------------------------------------------------------
dycp () {
TEXT="DYCP using 'rise' attribute."
SIN=( $(<$SINUS) )
echo -n '<span font="Monospace bold 36" color="black">'
for i in `seq 0 $((${#TEXT}-1))`; do
echo -n '<span rise="'${SIN[$(( ($i*3)&63 ))]}'">'${TEXT:$i:1}'</span>'
done
echo -n '</span>'
echo ${SIN[63]} ${SIN[@]:0:63} > $SINUS
}
export -f dycp
export MAIN='
<window title="DYCP" height-request="256" allow-grow="false">
<text use-markup="true" wrap="false">
<variable>DYCP</variable>
<input>dycp</input>
</text>
<timer visible="false" milliseconds="true" interval="50">
<action>refresh:DYCP</action>
</timer>
<action signal="hide">exit:abort</action>
</window>
'
gtkdialog -cp MAIN
___________
PS. In .tgz below there's a couple of other old effects ported to Bash/Gtkdialog (same 'svg+refresh' technique, so nothing original really
).
Greetings!
Posted: Sun 24 Mar 2013, 18:52
by vovchik
Dear5 SFR,
Nice job. I honestly didn't know about the "rise" attribute either, until recently, and then thought it might just work. Your code is tiny, which is very nice. Too bad that <span> doesn't have an x-axis attribute like "shift". Then we could control the entire space in both directions.
With kind regards,
vovchik
Posted: Sun 24 Mar 2013, 19:25
by vovchik
Dear SFR,
The archive contains great stuff by you. I will try to port those demos. Have a problem with interference.sh, but I will try to figure out why.
With kind regards,
vovchik
Posted: Sun 24 Mar 2013, 19:53
by SFR
Oops, I think I know what kind of problems.
I forgot that in Gtkdialog-0.8.0 (you're still on Lupu, right?) in some cases closing the window through upper-right X won't terminate gtkdialog process...
So most likely my scripts just jammed your CPU (sorry about that
).
Ok, I reuploaded corrected scripts, with added:
Code: Select all
<action signal="hide">exit:abort</action>
line, which should prevent the problem.
Sorry again &
Greetings!
Posted: Sun 24 Mar 2013, 20:10
by vovchik
Dear SFR,
Many thanks, but it doesn't seem to be a gtkdialog problem. I am using thunor's latest - compiled on my machine:
And I have all the other dependencies: bc, rsvg*. And my bash is relatively new. And everything works except for interference.sh. I am scratching my head a bit, but something will occur to me eventually. I had a similar problem in programming a chess front end a few days ago. I dimensioned two arrays from 0 to 15 to hold chess figures and, in my stupidity, wrote DECLARE xx[15], yy[15]. After hours scouring the code, it occurred to me that the arrays should be [16] in size, with indexes starting at 0
With kind regards,
vovchik
PS. I am using Lucid - but very modified...upgraded and enhanced
Posted: Tue 26 Mar 2013, 14:38
by vovchik
Dear SFR,
Here are two BaCon versions of your very nice cube demo. I had to modify the bacon source because of nesting limitations in one of my versions, but both attached binaries will run just fine. And the mod to BaCon is pretty trivial and explained in the source. There is very little CPU use.
Thanks for the great stuff.
With kind regards,
vovchik
Posted: Tue 26 Mar 2013, 16:32
by SFR
Cool, thanks!
Precalculating sin/cos tables is instant now.
BTW, have you found out what's wrong with interference, because I tried it in Lupu (VBox) and works ok for me.
Greetings!
Posted: Mon 01 Apr 2013, 20:51
by thunor
@SFR
Is there a gtkdialog version of your cube demo?
I'm just committing your programs now and I was seeing if there were any more.
Regards,
Thunor
Posted: Mon 01 Apr 2013, 21:15
by SFR
Hey Thunor
Yes, a few post above, in attached tgz (I just re-uploaded it again, because
vector.sh was creating some tempfiles in / instead of /dev/shm/.... Corrected now.)
http://murga-linux.com/puppy/viewtopic. ... 355#694355
Greetings!