Hi, I like your gadget, but I think it would look better, if the heart enlarges keeping his center in the same position. I sugget you to modify the code as follow (I marked my changes with ###PAOLO###):
#heartbeat
import karamba
imageFiles = [
"pics/Station100.png",
"pics/Station101.png",
"pics/Station102.png",
"pics/Station103.png",
"pics/Station104.png",
"pics/Station105.png",
"pics/Station106.png",
"pics/Station107.png",
"pics/Station108.png",
"pics/Station109.png",
"pics/Station110.png",
"pics/Station111.png",
"pics/Station112.png",
"pics/Station111.png",
"pics/Station110.png",
"pics/Station109.png",
"pics/Station108.png",
"pics/Station107.png",
"pics/Station106.png",
"pics/Station107.png",
"pics/Station108.png",
"pics/Station109.png",
"pics/Station110.png",
"pics/Station111.png",
"pics/Station112.png",
"pics/Station111.png",
"pics/Station110.png",
"pics/Station109.png",
"pics/Station108.png",
"pics/Station107.png",
"pics/Station106.png",
"pics/Station105.png",
"pics/Station104.png",
"pics/Station103.png",
"pics/Station102.png",
"pics/Station101.png",
]
images = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
image = 0
init = 0
###PAOLO###
#The sizes of the biggest image
MaxX=120
MaxY=129
###/PAOLO###
def initWidget(widget):
#buggy in current version
pass
def widgetUpdated(widget):
global imageFiles
global images
global image
global init
if init == 0:
for i in range(36):
images[i] = karamba.createImage(widget, 150, 150, imageFiles[i])
karamba.moveImage(widget, images[0], 0, 0)
init = 1
else:
karamba.moveImage(widget, images[image], 150, 150)
if image < 35:
image = image + 1
else:
image = 0
###PAOLO###
x=(MaxX-karamba.getImageWidth(widget,images[image]))/2
y=(MaxY-karamba.getImageHeight(widget,images[image]))/2
karamba.moveImage(widget, images[image], x, y)
###PAOLO###
karamba.redrawWidget(widget)
def widgetClicked(widget, x, y, button):
pass
def widgetMouseMoved(widget, x, y, button):
pass
# This will be printed when the widget loads.
print "Loaded my python extension!"
If you need I will email you the code (the tabs are all flatten, grrr).
Write me at paolopantaleo -at- gmail -dot- com
You might want to remove the backup files from your archive before posting (*~). They add 307kb to the overall filesize. The archive would only be around 100k without them.
Ratings & Comments
3 Comments
Hi, I like your gadget, but I think it would look better, if the heart enlarges keeping his center in the same position. I sugget you to modify the code as follow (I marked my changes with ###PAOLO###): #heartbeat import karamba imageFiles = [ "pics/Station100.png", "pics/Station101.png", "pics/Station102.png", "pics/Station103.png", "pics/Station104.png", "pics/Station105.png", "pics/Station106.png", "pics/Station107.png", "pics/Station108.png", "pics/Station109.png", "pics/Station110.png", "pics/Station111.png", "pics/Station112.png", "pics/Station111.png", "pics/Station110.png", "pics/Station109.png", "pics/Station108.png", "pics/Station107.png", "pics/Station106.png", "pics/Station107.png", "pics/Station108.png", "pics/Station109.png", "pics/Station110.png", "pics/Station111.png", "pics/Station112.png", "pics/Station111.png", "pics/Station110.png", "pics/Station109.png", "pics/Station108.png", "pics/Station107.png", "pics/Station106.png", "pics/Station105.png", "pics/Station104.png", "pics/Station103.png", "pics/Station102.png", "pics/Station101.png", ] images = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] image = 0 init = 0 ###PAOLO### #The sizes of the biggest image MaxX=120 MaxY=129 ###/PAOLO### def initWidget(widget): #buggy in current version pass def widgetUpdated(widget): global imageFiles global images global image global init if init == 0: for i in range(36): images[i] = karamba.createImage(widget, 150, 150, imageFiles[i]) karamba.moveImage(widget, images[0], 0, 0) init = 1 else: karamba.moveImage(widget, images[image], 150, 150) if image < 35: image = image + 1 else: image = 0 ###PAOLO### x=(MaxX-karamba.getImageWidth(widget,images[image]))/2 y=(MaxY-karamba.getImageHeight(widget,images[image]))/2 karamba.moveImage(widget, images[image], x, y) ###PAOLO### karamba.redrawWidget(widget) def widgetClicked(widget, x, y, button): pass def widgetMouseMoved(widget, x, y, button): pass # This will be printed when the widget loads. print "Loaded my python extension!" If you need I will email you the code (the tabs are all flatten, grrr). Write me at paolopantaleo -at- gmail -dot- com
You might want to remove the backup files from your archive before posting (*~). They add 307kb to the overall filesize. The archive would only be around 100k without them.
thank you for your advice .... done