GtkDialog - tips
- mister_electronico
- Posts: 969
- Joined: Sun 20 Jan 2008, 20:20
- Location: Asturias_ España
- Contact:
Explanation
To make turning the knob and needed to create the following variables.
DEGRED = IF THE POSITION OF RED POINT.
DEGR= IF THE VARIABLE OF ANGLE ROTATION
This variable can be used later to tell the program where the control level is
X = position of your mouse axis X
Y = position of your mouse axis Y
Px = position of the red dot on axis X
Py = position of the red dot on axis Y
Px=cosine(DEGRED)
Py=sine(DEGRED)
Here I leave a picture to try to clarify how it works
DEGRED = IF THE POSITION OF RED POINT.
DEGR= IF THE VARIABLE OF ANGLE ROTATION
This variable can be used later to tell the program where the control level is
X = position of your mouse axis X
Y = position of your mouse axis Y
Px = position of the red dot on axis X
Py = position of the red dot on axis Y
Px=cosine(DEGRED)
Py=sine(DEGRED)
Here I leave a picture to try to clarify how it works
- Attachments
-
- explanation program.png
- (9.04 KiB) Downloaded 888 times
- mister_electronico
- Posts: 969
- Joined: Sun 20 Jan 2008, 20:20
- Location: Asturias_ España
- Contact:
All program.
All program:
I will continue working on.
Code: Select all
#!/bin/bash
export TEMPDIR=/tmp/knob
mkdir $TEMPDIR
trap 'rm -rf $TEMPDIR' EXIT
export PIC=$TEMPDIR/pic.svg
export DEGREE=$TEMPDIR/degree
export CORDENATE=$TEMPDIR/cordenate
echo 0 > $DEGREE
# DEGREE is the angle you have to turn is not the actual angle in the red dot is
cp ./rotary1.svg $PIC
cp ./rotary1.png $TEMPDIR
export WIN_NAME="KNOB"
export YF=6
export PIC_X=300
# Get current, relative position of cursor
get_xy () {
read MX MY WX WY WI <<< `getcurpos && xwininfo -name "$WIN_NAME" 2>/dev/null | awk 'NR>=4&&NR<=5 {print $4} NR==8 {print $2}'`
X=$((($MX-$WX)-($WI-$PIC_X)/2))
Y=$(($MY-$WY-$YF))
echo "X: $X Y: $Y"
DEGR=$(<$DEGREE)
let DEGRED=240-DEGR # Get the value of the angle where it really is the red dot
PI=$(echo "scale=10; 4*a(1)" | bc -l )
RADIANS=$(echo "scale=5; $DEGRED*$PI/180" | bc -l )
VAL=$(echo "scale=5; 120*s($RADIANS)" | bc -l )
Py=$(echo "(-1)*$VAL/1+150" | bc )
VAL=$(echo "scale=5; 135*c($RADIANS)" | bc -l )
Px=$(echo "$VAL/1+150" | bc )
echo "the value DEGRED es " $DEGRED
echo "the value DEGR es " $DEGR
echo "the value Px es " $Px
echo "the value Py es " $Py
if [ $DEGR -lt 154 ] && [ $Px -lt 151 ] && [ $X -lt 150 ] && [ $Py -lt $Y ] && [ $Y -lt 260 ]; then DEGR=$(($DEGR-5)); echo $DEGR > $DEGREE; fi
if [ $DEGR -lt 154 ] && [ $Px -lt 151 ] && [ $X -lt 150 ] && [ $Py -gt $Y ] && [ $Y -lt 260 ]; then DEGR=$(($DEGR+5)); echo $DEGR > $DEGREE; fi
if [ $DEGR -lt 154 ] && [ $Px -lt 151 ] && [ $X -gt 150 ] && [ $Y -lt 260 ]; then DEGR=$(($DEGR+5)); echo $DEGR > $DEGREE; fi
if [ $DEGR -gt 154 ] && [ $Px -gt 150 ] && [ $X -gt 150 ] && [ $Py -lt $Y ] && [ $Y -lt 260 ]; then DEGR=$(($DEGR+5)); echo $DEGR > $DEGREE; fi
if [ $DEGR -gt 154 ] && [ $Px -gt 150 ] && [ $X -gt 150 ] && [ $Y -lt $Py ] && [ $Y -lt 260 ]; then DEGR=$(($DEGR-5)); echo $DEGR > $DEGREE; fi
if [ $DEGR -gt 154 ] && [ $Px -gt 150 ] && [ $X -lt 150 ] && [ $Y -lt 260 ]; then DEGR=$(($DEGR-5)); echo $DEGR > $DEGREE; fi
echo '<svg width="35mm" height="35mm" transform="scale(1.0) rotate('$DEGR' 60 60)"
id="svg1"
sodipodi:version="0.32"
inkscape:version="0.36"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:xlink="http://www.w3.org/1999/xlink"
sodipodi:docbase="/tmp/knob"
sodipodi:docname="/tmp/knob/rotary1.svg">
<defs
id="defs3" />
<sodipodi:namedview
id="base" />
<image
xlink:href="rotary1.png"
sodipodi:absref="/tmp/knob/rotary1.png"
x="0" y="0"
width="120.000000"
height="120.000000"
id="image562" />
</svg>' > $PIC
}
export -f get_xy
echo '
<window title="'${WIN_NAME}'">
<vbox>
<eventbox>
<pixmap>
<variable>PICTURE</variable>
<input file>'$PIC'</input>
<width>'${PIC_X}'</width>
</pixmap>
<action signal="button-press-event">enable:varTIMER</action>
<action signal="button-release-event">disable:varTIMER</action>
</eventbox>
<timer visible="false" milliseconds="true" interval="100" sensitive="false">
<variable>varTIMER</variable>
<action>get_xy</action>
<action>refresh:PICTURE</action>
</timer>
</vbox>
</window>' | gtkdialog -s
I will continue working on.
- mister_electronico
- Posts: 969
- Joined: Sun 20 Jan 2008, 20:20
- Location: Asturias_ España
- Contact:
Some considerations.
Some considerations:
The knob rotates very slow for me, I think this is because the burning process SVG image files on the memory in the /tmp/knob is a slow process.
I think that any process of recording a file on memory or hard disk makes the process very slow independent that the file has a very small as is the case in this instance size.
So I'm thinking it could create all SVG images when begin the program.
Thinking that knob rotate in steps of 5 degrees this would
300º / 5 = 60 images
rotary1.svg=899bits so
60x899=53940 bits ---------so ------- 53942 / 1024 = about 53 K
This deal would make the program a little more memory, but
Then one would have to be loading picture as the angle, and in this case the program would have to read only pictures, no burn it.
I think it would be much faster.
Well I'm thinking out loud, so let you is burning my single neuron that I have.
see you
Regards
The knob rotates very slow for me, I think this is because the burning process SVG image files on the memory in the /tmp/knob is a slow process.
I think that any process of recording a file on memory or hard disk makes the process very slow independent that the file has a very small as is the case in this instance size.
So I'm thinking it could create all SVG images when begin the program.
Thinking that knob rotate in steps of 5 degrees this would
300º / 5 = 60 images
rotary1.svg=899bits so
60x899=53940 bits ---------so ------- 53942 / 1024 = about 53 K
This deal would make the program a little more memory, but
Then one would have to be loading picture as the angle, and in this case the program would have to read only pictures, no burn it.
I think it would be much faster.
Well I'm thinking out loud, so let you is burning my single neuron that I have.
see you
Regards
- mister_electronico
- Posts: 969
- Joined: Sun 20 Jan 2008, 20:20
- Location: Asturias_ España
- Contact:
Question?
Question? Is there any way to pass a variable to the input pixmap to change the name example:
function{
Here I want give diferent names to $PIC
PIC = img1.svg next time img2.svg............
}
<pixmap>
<input file>'$PIC'</input>
</pixmap>
Do not let me change it only gets the name I give to "export"
Thank you
function{
Here I want give diferent names to $PIC
PIC = img1.svg next time img2.svg............
}
<pixmap>
<input file>'$PIC'</input>
</pixmap>
Do not let me change it only gets the name I give to "export"
Thank you
- mister_electronico
- Posts: 969
- Joined: Sun 20 Jan 2008, 20:20
- Location: Asturias_ España
- Contact:
yes.
Yes don570 you are right every step 5 degrees rotation knob :
Make image svg file - write in memory - read in pixmap .
This makes the process very slow in gkdialog.
I'll try in C as you say to try to do it faster.
Thank for check the program and and give me an answer
See you.
Make image svg file - write in memory - read in pixmap .
This makes the process very slow in gkdialog.
I'll try in C as you say to try to do it faster.
Thank for check the program and and give me an answer
See you.
Knob
A simpler and faster approach
NB! remove existing /tmp/knob
A simpler and faster approach
NB! remove existing /tmp/knob
Code: Select all
#!/bin/bash
export PIC_Y=300 #set height/width of knob
export COLOR='#444'
export COLOR_DOT='red'
export TEMPDIR=/tmp/knob
if [ ! -d $TEMPDIR ]; then
mkdir $TEMPDIR
echo 0 > $TEMPDIR/degree
fi
# Get current, relative position of cursor
get_xy () {
DEGR="$(<$TEMPDIR/degree)"
Y="`getcurpos | awk '{print $2}'`"
Y2="$(<$TEMPDIR/cursor_y)"
DEGR=$(($DEGR+($Y2-$Y)))
[ $DEGR -lt 1 ] && DEGR=0; [ $DEGR -gt 250 ] && DEGR=250 #keep value in range
echo $Y > $TEMPDIR/cursor_y
echo $DEGR > $TEMPDIR/degree
echo Y:$Y DEGR:$DEGR
echo '
<svg width="'${PIC_Y}'" height="'${PIC_Y}'" transform="scale(1.0) rotate('$DEGR' '$((${PIC_Y}/2))' '$((${PIC_Y}/2))')">
<circle style="fill:'$COLOR';" cx="'$((${PIC_Y}/2))'" cy="'$((${PIC_Y}/2))'" r="'$((${PIC_Y}*45/100))'"/>
<circle style="fill:'$COLOR_DOT';" cx="'$((${PIC_Y}*20/100))'" cy="'$((${PIC_Y}*75/100))'" r="'$((${PIC_Y}*3/100))'"/>
</svg>' > $TEMPDIR/pic.svg
}
export -f get_xy
echo '
<window title="knob">
<vbox>
<eventbox>
<pixmap>
<variable>PICTURE</variable>
<input file>'$TEMPDIR/pic.svg'</input>
<height>'${PIC_Y}'</height>
</pixmap>
<action signal="button-press-event">getcurpos | awk '"'"'{print $2}'"'"' > '$TEMPDIR'/cursor_y</action>
<action signal="button-press-event">enable:varTIMER</action>
<action signal="button-release-event">disable:varTIMER</action>
</eventbox>
<timer visible="false" milliseconds="true" interval="50" sensitive="false">
<variable>varTIMER</variable>
<action>get_xy</action>
<action>refresh:PICTURE</action>
</timer>
</vbox>
</window>' | gtkdialog -s
- mister_electronico
- Posts: 969
- Joined: Sun 20 Jan 2008, 20:20
- Location: Asturias_ España
- Contact:
hi
Zigbert very smart , It is now much faster.
I always thinking in the SVG image and forgot the rotary1.png image of 15 Kbit.
I think the load this png file makes the process slower.
I'll try to make it more attractive rotary knob by SVG like bottons of don570, I hope not increase much in size and make the process slower.
The knob does not respond correctly to mouse in my system, I will try to study your code.
But now I'm five days off to my small town retake it when I return.
Thanks for everything
Greetings.
I always thinking in the SVG image and forgot the rotary1.png image of 15 Kbit.
I think the load this png file makes the process slower.
I'll try to make it more attractive rotary knob by SVG like bottons of don570, I hope not increase much in size and make the process slower.
The knob does not respond correctly to mouse in my system, I will try to study your code.
But now I'm five days off to my small town retake it when I return.
Thanks for everything
Greetings.
This snippet handles the 4 knobs separately
Code: Select all
#!/bin/bash
export KNOB_Y=60 #set height/width of knob
export COLOR='#A4BEA9' #78837A
export COLOR_DOT='#eee' #999
export WORKDIR=/tmp/knob
draw_knob (){
echo '
<svg width="'${KNOB_Y}'" height="'${KNOB_Y}'">
<defs>
<radialGradient
id="RG1" cx="'$((${KNOB_Y}*30/100))'" cy="'$((${KNOB_Y}*30/100))'" fx="'$((${KNOB_Y}*30/100))'" fy="'$((${KNOB_Y}*30/100))'" r="'$((${KNOB_Y}*45/100))'"
gradientUnits="userSpaceOnUse">
<stop style="stop-color:#393939;stop-opacity:1;" offset="1"/>
<stop style="stop-color:#888;stop-opacity:1;" offset="0"/>
</radialGradient>
</defs>
<circle style="fill:#111;" cx="'$(((${KNOB_Y}/2)+(${KNOB_Y}*3/100)))'" cy="'$(((${KNOB_Y}/2)+(${KNOB_Y}*3/100)))'" r="'$((${KNOB_Y}*46/100))'"/>
<circle style="fill:#585858" cx="'$((${KNOB_Y}/2))'" cy="'$((${KNOB_Y}/2))'" r="'$((${KNOB_Y}*46/100))'"/>
<circle style="fill:url(#RG1);stroke:'$COLOR';stroke-width:'$((${KNOB_Y}*2/100))'" cx="'$((${KNOB_Y}/2))'" cy="'$((${KNOB_Y}/2))'" r="'$((${KNOB_Y}*40/100))'"/>
<circle style="fill:'$COLOR_DOT';" cx="'$((${KNOB_Y}*27/100))'" cy="'$((${KNOB_Y}*75/100))'" r="'$((${KNOB_Y}*4/100))'" transform="rotate('$1' '$((${KNOB_Y}/2))' '$((${KNOB_Y}/2))')"/>
</svg>' > $2
}
# Get current, relative position of cursor
get_y (){
NR="$(<$WORKDIR/knob_nr)"
DEGR="$(<$WORKDIR/knob_${NR}_value)"
Y="`getcurpos | awk '{print $2}'`"
Y2="$(<$WORKDIR/cursor_y)"
DEGR=$(($DEGR+($Y2-$Y))) #The knob's value range is equal to moving mouse 250 px.
[ $DEGR -lt 1 ] && DEGR=0; [ $DEGR -gt 250 ] && DEGR=250 #keep value inside range
echo $Y > $WORKDIR/cursor_y
echo $DEGR > $WORKDIR/knob_${NR}_value
echo Knob_${NR}: Y:$Y DEGR:$DEGR
draw_knob $DEGR $WORKDIR/knob_${NR}.svg
}
export -f draw_knob get_y
if [ ! -d $WORKDIR ]; then
mkdir $WORKDIR
for I in 1 2 3 4; do
echo 0 > $WORKDIR/knob_${I}_value
draw_knob 0 $WORKDIR/knob_${I}.svg
done
fi
echo '
<window title="knob">
<vbox>
<hbox>
<timer visible="false" milliseconds="true" interval="100" sensitive="false">
<variable>TIMER</variable>
<action>get_y</action>
<action>refresh:KNOB_1</action>
<action>refresh:KNOB_2</action>
<action>refresh:KNOB_3</action>
<action>refresh:KNOB_4</action>
</timer>' > $WORKDIR/xml_knob
for I in 1 2 3 4; do
echo '
<eventbox>
<pixmap>
<variable>KNOB_'$I'</variable>
<input file>'$WORKDIR/knob_${I}.svg'</input>
<height>'${KNOB_Y}'</height>
</pixmap>
<action signal="button-press-event">getcurpos | awk '"'"'{print $2}'"'"' > '$WORKDIR'/cursor_y</action>
<action signal="button-press-event">echo '$I' > '$WORKDIR'/knob_nr</action>
<action signal="button-press-event">enable:TIMER</action>
<action signal="button-release-event">disable:TIMER</action>
</eventbox>' >> $WORKDIR/xml_knob
done
echo '
</hbox>
</vbox>
</window>' >> $WORKDIR/xml_knob
gtkdialog -f $WORKDIR/xml_knob
- technosaurus
- Posts: 4853
- Joined: Mon 19 May 2008, 01:24
- Location: Blue Springs, MO
- Contact:
You can do this in svg with paths and a transform="rotate(...)":
https://developer.mozilla.org/en-US/doc ... definition
I like to hand write my SVGs for better control, but existing editors either mangle the code or don't have good access to the source, so I wrote a simple editor here:
http://murga-linux.com/puppy/viewtopic. ... 250#836250
I've found it to be extremely useful to play with paths and transforms until I understand them
Here is a simplified knob using only paths and rotate() ... just change height and width to XXpx
<svg id="svg" width="100%" height="100%" viewBox="0 0 96 96"><path d="M47 1A47 47 0 1 0 49 1z"/>
<path fill="red" transform="rotate(270, 48, 48)" d="M48 1A4 4 0 1 0 50 1z"/>
</svg>
https://developer.mozilla.org/en-US/doc ... definition
I like to hand write my SVGs for better control, but existing editors either mangle the code or don't have good access to the source, so I wrote a simple editor here:
http://murga-linux.com/puppy/viewtopic. ... 250#836250
I've found it to be extremely useful to play with paths and transforms until I understand them
Here is a simplified knob using only paths and rotate() ... just change height and width to XXpx
<svg id="svg" width="100%" height="100%" viewBox="0 0 96 96"><path d="M47 1A47 47 0 1 0 49 1z"/>
<path fill="red" transform="rotate(270, 48, 48)" d="M48 1A4 4 0 1 0 50 1z"/>
</svg>
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].
That darn droid and that darntechnosaurus wrote:You can do this in svg with paths and a transform="rotate(...)":
https://developer.mozilla.org/en-US/doc ... definition
I like to hand write my SVGs for better control, but existing editors either mangle the code or don't have good access to the source, so I wrote a simple editor here:
http://murga-linux.com/puppy/viewtopic. ... 250#836250
I've found it to be extremely useful to play with paths and transforms until I understand them
Here is a simplified knob using only paths and rotate() ... just change height and width to XXpxCode: Select all
<svg id="svg" width="100%" height="100%" viewBox="0 0 96 96"><path d="M47 1A47 47 0 1 0 49 1z"/> <path fill="red" transform="rotate(270, 48, 48)" d="M48 1A4 4 0 1 0 50 1z"/> </svg>
Puppy Linux Blog - contact me for access
- mister_electronico
- Posts: 969
- Joined: Sun 20 Jan 2008, 20:20
- Location: Asturias_ España
- Contact:
trying again.
Just back from my little vacation, hi zigbert I was watching you watching your penultimate code:
http://murga-linux.com/puppy/viewtopic. ... 718#837718
It's fast but for me has a problem that does not obey either the mouse.
I think that in the code must be taken into account also the X axis to rotate knob in the appropriate direction depending on the position in which it find.
I was freaking out that even a slight modification I make of your code causes it to become very slow.
The buttons on your last code are very nice, but not if it will be only in my system but I have to hold down the mouse outside the window and turn it so that the knob can fully rotate.
In the code of SFR the mouse only works over knob window I like it but this it is that makes the program more slower.
I think that is right don570 perhaps be better to try piece of code in C.
I am currently developing this program ligth panel:
https://www.youtube.com/watch?v=-B6hQdiPCaM
As soon as I finish I'll put it here, I think part of the code is faster that is in C.
Very interesting Technosaurus the path and rotate () I'll try to have if the speed improves.
Thanks gentlemen for all the information I will continue studying and making progress here
Greetings
http://murga-linux.com/puppy/viewtopic. ... 718#837718
It's fast but for me has a problem that does not obey either the mouse.
I think that in the code must be taken into account also the X axis to rotate knob in the appropriate direction depending on the position in which it find.
I was freaking out that even a slight modification I make of your code causes it to become very slow.
The buttons on your last code are very nice, but not if it will be only in my system but I have to hold down the mouse outside the window and turn it so that the knob can fully rotate.
In the code of SFR the mouse only works over knob window I like it but this it is that makes the program more slower.
I think that is right don570 perhaps be better to try piece of code in C.
I am currently developing this program ligth panel:
https://www.youtube.com/watch?v=-B6hQdiPCaM
As soon as I finish I'll put it here, I think part of the code is faster that is in C.
Very interesting Technosaurus the path and rotate () I'll try to have if the speed improves.
Thanks gentlemen for all the information I will continue studying and making progress here
Greetings
-
- Posts: 8
- Joined: Mon 02 Mar 2015, 22:35
Re: GtkDialog - tips
Hi zigbert et al,zigbert wrote:Code: Select all
#!/bin/bash echo 'style "specialmono" { font_name="Mono 12" } widget "*mono" style "specialmono" class "GtkText*" style "specialmono"' > /tmp/gtkrc_mono export GTK2_RC_FILES=/tmp/gtkrc_mono:/root/.gtkrc-2.0 export test_app=" <vbox> <text name="mono"><label>This text-widget uses monospace font....</label></text> <text><label>...while this text-widget don't.</label></text> <edit><default>All edit-widgets gets monospace.</default></edit> </vbox>" gtkdialog --program=test_app
What is the following line, in the code above, supposed to do exactly?
Code: Select all
export GTK2_RC_FILES=/tmp/gtkrc_mono:/root/.gtkrc-2.0
When I use the following, for example, ...
Code: Select all
export GTK2_RC_FILES=/tmp/gtkrc_title:~/.gtkrc-2.0
Thanks, Michael.
- mister_electronico
- Posts: 969
- Joined: Sun 20 Jan 2008, 20:20
- Location: Asturias_ España
- Contact:
Close to slit my wrists
Sorry to present a code in C on a forum gtkdialog
But it's the only way I've found to increase slightly speed knob.
I think the refresh process images in gtkdialog is a slow process.
A slightly increased considering doing more things anyway as it
was not fast enough steps to increase knob 10 degrees.
Anyway not know how many more will these steps in commercial programs.
I copied the rotary knob Zigbert but only one because all code of him is crazy for me.
Just as I left the code SFR for the coordinates of the mouse.
The program still needs tweaking but it could be a start for me.
I hope the C program can run on other computers, but if not it is very easy to compile.
gcc -o knob knob.c -lm
To run the program first unzip the file and run within the directory KNOB:
# ./knob1
If someone prove it I very grateful to tell your impressions.
All codes are in the compressed archive.
Greating
But it's the only way I've found to increase slightly speed knob.
I think the refresh process images in gtkdialog is a slow process.
A slightly increased considering doing more things anyway as it
was not fast enough steps to increase knob 10 degrees.
Anyway not know how many more will these steps in commercial programs.
I copied the rotary knob Zigbert but only one because all code of him is crazy for me.
Just as I left the code SFR for the coordinates of the mouse.
The program still needs tweaking but it could be a start for me.
I hope the C program can run on other computers, but if not it is very easy to compile.
gcc -o knob knob.c -lm
To run the program first unzip the file and run within the directory KNOB:
# ./knob1
If someone prove it I very grateful to tell your impressions.
All codes are in the compressed archive.
Greating
- Attachments
-
- knob.tar.gz
- (17.17 KiB) Downloaded 262 times
- mister_electronico
- Posts: 969
- Joined: Sun 20 Jan 2008, 20:20
- Location: Asturias_ España
- Contact:
Thinking of many things forgotten in the simplest
Thinking of many things forgotten in the simplest, thought the refresh time it marked the click of the mouse, but forget the most obvious.
If we change the timer 100 ms to 50 ms is obviously faster.
However this can produce jumps in the knob I do not like it.
What imply that this timer setting depends of the speed of our CPU.
Greetings.
Code: Select all
<timer visible="false" milliseconds="true" interval="100" sensitive="false">
<variable>varTIMER</variable>
<action>get_xy</action>
<action>refresh:PICTURE</action>
</timer>
However this can produce jumps in the knob I do not like it.
What imply that this timer setting depends of the speed of our CPU.
Greetings.
- mister_electronico
- Posts: 969
- Joined: Sun 20 Jan 2008, 20:20
- Location: Asturias_ España
- Contact:
improving knob
This a new version knob, No rebounds in the pointer and softer in slip.
Checking the speed of the program in C from the terminal is found to have enough speed.
If it does not work or is jerky at best is convenient in some computers speed up timer in the "knob1" program at the line of code.
Doing more than 80
I hope to be useful and my thanks to all the great people of this forum Puppy.
Checking the speed of the program in C from the terminal is found to have enough speed.
Code: Select all
# cd /mnt/home/KNOBC2
# ls
imgini.svg img.svg knob knob1 knob.c
# mkdir /tmp/knob
# cp imgini.svg /tmp/knob
# cp img.svg /tmp/knob
# echo "0" > /tmp/knob/DEGR.dat
#
# time ./knob 78 98
real 0m0.003s
user 0m0.000s
sys 0m0.000s
If it does not work or is jerky at best is convenient in some computers speed up timer in the "knob1" program at the line of code.
Code: Select all
<timer visible="false" milliseconds="true" interval="80" sensitive="false">
I hope to be useful and my thanks to all the great people of this forum Puppy.
- Attachments
-
- knob2.tar.gz
- (6.94 KiB) Downloaded 340 times
Last edited by mister_electronico on Wed 15 Apr 2015, 19:23, edited 1 time in total.
I modified a Thunor example to show how to use SVG image buttons
in a toggle button example. A menu heading is disabled in this example.
I'm sure lots of other useful things could be done as well.
You can change the size of the button by fiddling with the height and width tags.
Explanation: I generate two SVG images, then change their names to
true.svg and false.svg .
Note the importance of the variable tgb1. I am using Thunor's notation.
in a toggle button example. A menu heading is disabled in this example.
I'm sure lots of other useful things could be done as well.
You can change the size of the button by fiddling with the height and width tags.
Explanation: I generate two SVG images, then change their names to
true.svg and false.svg .
Note the importance of the variable tgb1. I am using Thunor's notation.
Code: Select all
#!/bin/sh
#example to toggle menu by don570
rm -rf /tmp/TOGGLE_EXAMPLE # start fresh
TMPDIR=/tmp/TOGGLE_EXAMPLE
mkdir -p $TMPDIR
cd $TMPDIR # create and load images from this folder
for LABEL in 1 2 ;do
[ $LABEL -eq 1 ] && TEXT="Enable Menu"
[ $LABEL -eq 2 ] && TEXT="Disable Menu"
X1=$(echo "$TEXT"|wc -c) # number of letters
W=$((${X1}*6*95/31))
DISPLACE=$(($W/7))
FILL=white
echo '<svg version="1.1">
<rect
style="fill:'$FILL';fill-opacity:.7;stroke-width:2;stroke:black;stroke-opacity:1;"
width='\"$W\"' height="36" rx="10" ry="10" x="1" y="1"/>
<text style="font-family:DejaVu;font-size:24;fill-opacity:1"
x='\"$DISPLACE\"' y="26" >
'$TEXT'
</text>
</svg>
'> "$TEXT".svg
done
ln -sf "Disable Menu".svg tgb0.svg
ln -sf "Enable Menu".svg tgb1.svg
# create true and false images
cp "Disable Menu".svg true.svg
cp "Enable Menu".svg false.svg
MAIN_DIALOG='
<window title="ToggleButton Advanced" resizable="false" border-width="0">
<vbox>
<menubar>
<menu use-underline="true">
<menuitem stock-id="gtk-quit" accel-key="0x51" accel-mods="4">
<action>exit:Quit</action>
</menuitem>
<label>"_File"</label>
<variable>mnuFile</variable>
<sensitive>false</sensitive>
</menu>
</menubar>
<vbox border-width="20" spacing="20">
<hbox homogeneous="true">
<text><label>My Example</label></text>
<entry>
<default>true</default>
<variable>entry</variable>
<input>echo $tgb1</input>
</entry>
</hbox>
<hseparator></hseparator>
<hbox homogeneous="true">
<togglebutton>
<variable>tgb1</variable>
<input file>tgb1.svg</input>
<action>ln -sf $tgb1.svg tgb1.svg</action>
<action>refresh:tgb1</action>
<action>refresh:entry</action>
<action>if true enable:mnuFile</action>
<action>if false disable:mnuFile</action>
</togglebutton>
</hbox>
</vbox>
</vbox>
</window>
'
export MAIN_DIALOG
gtkdialog --program=MAIN_DIALOG
design gui
Hi All,
I want to make a gui about encryption and decription of image. I have wrote my code in python 2.7.6. In puppy linux, we just load our devx.sfs. We also must install Image library from PIL, and I had done. My code has so many def.
Is there possible to implement it into gtkdialog? Could someone give me an example gui of that please (button, image, frame, etc.)?
Thanks.
Recobayu
Edited:
Finally, i know something like gtkdialog. There is Tkinter. I'm sorry for my out of topic here.
I want to make a gui about encryption and decription of image. I have wrote my code in python 2.7.6. In puppy linux, we just load our devx.sfs. We also must install Image library from PIL, and I had done. My code has so many def.
Is there possible to implement it into gtkdialog? Could someone give me an example gui of that please (button, image, frame, etc.)?
Thanks.
Recobayu
Edited:
Finally, i know something like gtkdialog. There is Tkinter. I'm sorry for my out of topic here.
Last edited by recobayu on Fri 24 Apr 2015, 10:03, edited 1 time in total.