mister_electronico wrote:Hi step , yes I have other program with external script control the pixmap.
http://www.murga-linux.com/puppy/viewto ... 333#792333
this external script is:
#!/bin/sh
while true
do
let N=N+1
cp S$N.gif /dev/shm/sim.gif
sleep 0.2
if [ $N -eq 28 ]; then
N=0;
fi
done
Is a gif in gtkdialog form, but I don't like this now.
In this case I need increase the value of variable J inside of the timer and create the link with the image.
But this I don't know how do it.
So, if I understand you correctly, essentially you want to put the script inside the timer. And this we will do now.
The idea is that we move the body of the script loop into the script action. Then the timer is equivalent to the script loop when you set a recurring timer interval of 0.2 s. And you know how to do that already. Let'ss refine the dialog code step by step.
The body of the loop is simply
cp S$N.gif /dev/shm/sim.gif. But you said you don't like that and prefer something like
'`let "j=$j+1" ;if [ $j -eq 57 ]; then j=0 ; fi `'
In your code $j appears to have usable values from 0 to 56 with wrap around, that is modulo 57.
Variable $j needs to become a gtkdialog variable, we'll call it J and use an invisible entry widget to hold it. The timer will refresh J, which will increment itself.
Code: Select all
<entry visible="false">
<variable export="false">J</variable>
<default>-1</default> this might need to be 0 instead of -1, test it
<input>echo $((++J % 57))</input> increments J modulo 57
</entry>
Then the timer to keep J alive, I'm going to call it CLOCK
Code: Select all
<timer milliseconds="true" interval="200" visible="false">
<variable>CLOCK</variable>
<action>refresh:J</action>
</timer>
Now CLOCK refreshes J every 200 ms and J keeps running in [0..56]. We need to connect the message, which is a pixmap whose input is a link to image files named after J.
Code: Select all
<pixmap>
<variable>MSG</variable>
<input file>/tmp/link-to-J-files</input>
</pixmap>
It is imperative that /tmp/link-to-J-files exist BEFORE gtkdialog runs, otherwise this won't work at all. So you need to set the FIRST link outside of gtkdialog code. In your shell script:
Code: Select all
ln -s /tmp/panel/img/img0.gif /tmp/link-to-J-files
gtkdialog ...
Now we need to relink the image file each CLOCK tick. The shell command goes inside dialog, either as J's action or as CLOCK's action. Let's keep it with J. After the new link is in place, we can tell MSG to display the image file.
Code: Select all
<entry visible="false">
<variable export="false">J</variable>
<default>-1</default> this might need to be 0 instead of -1, test it
<input>echo $((++J % 57))</input> increments J modulo 57
<action>ln -s /tmp/img/img$J.gif /tmp/link-to-J-files</action>
<action>refresh:MSG</action>
</entry>
That's it, putting it all together
Code: Select all
export DIALOG='
<timer milliseconds="true" interval="200" visible="false">
<variable>CLOCK</variable>
<action>refresh:J</action>
</timer>
<entry visible="false">
<variable>J</variable>
<default>-1</default>
<input>echo $((++J % 57))</input>
<action>ln -s /tmp/img/img$J.gif /tmp/link-to-J-files</action>
<action>refresh:MSG</action>
</entry>
<pixmap>
<variable>MSG</variable>
<input file>/tmp/link-to-J-files</input>
</pixmap>'
ln -s /tmp/panel/img/img0.gif /tmp/link-to-J-files
gtkdialog -p DIALOG
This code assumes an external image pump, something that creates the image files before - or while - gtkdialog is running. Some remarks:
- 200 ms, or five frames a second, is fairly quick. start with small images to make sure gtkdialog can keep up. My concern is not so much the time it takes to redraw the pixmap, but the overall time spent going in and out of the shell to relink each file.
- are you sure <pixmap> supports the gif format? If not use jpg, or png for small enough images.
- if possible try to have the pump create all images before - rather than while - gtkdialog is running. it makes debugging easier.
- don't forget to test which is the correct default value for J, 0 or -1, and...
- this code is totally untested by me
, have fun!
[url=http://murga-linux.com/puppy/viewtopic.php?t=117546]Fatdog64-810[/url]|[url=http://goo.gl/hqZtiB]+Packages[/url]|[url=http://goo.gl/6dbEzT]Kodi[/url]|[url=http://goo.gl/JQC4Vz]gtkmenuplus[/url]