1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
#this import statement allows access to the karamba functions
import karamba
images = [0,0,0,0,0,0,0,0,0,0,0,0,0,0]
c = 0
#this is called when you widget is initialized
def initWidget(widget):
global images
images[0] = karamba.getThemeImage(widget, "image0")
images[1] = karamba.getThemeImage(widget, "image1")
images[2] = karamba.getThemeImage(widget, "image2")
images[3] = karamba.getThemeImage(widget, "image3")
images[4] = karamba.getThemeImage(widget, "image4")
images[5] = karamba.getThemeImage(widget, "image5")
images[6] = karamba.getThemeImage(widget, "image6")
images[7] = karamba.getThemeImage(widget, "image7")
images[8] = karamba.getThemeImage(widget, "image8")
images[9] = karamba.getThemeImage(widget, "image9")
images[10] = karamba.getThemeImage(widget, "image10")
images[11] = karamba.getThemeImage(widget, "image11")
images[12] = karamba.getThemeImage(widget, "image12")
images[13] = karamba.getThemeImage(widget, "image13")
#this is called everytime your widget is updated
#the update inverval is specified in the .theme file
def widgetUpdated(widget):
global images, c
b = c%2
# Create & delete
if(images[0]):
karamba.deleteImage(widget, images[0])
images[0] = 0
else:
images[0] = karamba.createImage(widget, 0, 20, "flag.png")
# Hide & Show
if(b):
karamba.hideImage(widget, images[1])
else:
karamba.showImage(widget, images[1])
# size & resize
size = karamba.getImageSize(widget, images[1])
print "getImageSize: " + str(size)
print "getImageWidth: " + str(karamba.getImageWidth(widget, images[1]))
print "getImageHeight: " + str(karamba.getImageHeight(widget, images[1]))
# Auto size
#size = ((b * 200) + 200, size[1])
#karamba.resizeImage(widget, images[1], size[0], size[1])
# pos & move
pos = karamba.getImagePos(widget, images[2])
print "getImagePos: " + str(pos)
pos = (b * 200, pos[1])
karamba.moveImage(widget, images[2], pos[0], pos[1])
# Sensor
sensor = karamba.getImageSensor(widget, images[3])
print "getSensor: " + str(sensor)
if(b):
karamba.setImageSensor(widget, images[3], 'SENSOR=PROGRAM PROGRAM="/tmp/test1.sh"')
else:
karamba.setImageSensor(widget, images[3], 'SENSOR=PROGRAM PROGRAM="/tmp/test2.sh"')
# Value
v = karamba.getImagePath(widget, images[4])
print "getImagePath: ", v
if(b):
v = 'flag.png'
else:
v = 'flag2.png'
karamba.setImagePath(widget, images[4], v)
if((c % 10) == 0):
karamba.removeImageEffects(widget, images[5])
karamba.removeImageEffects(widget, images[6])
karamba.removeImageEffects(widget, images[7])
else:
karamba.changeImageIntensity(widget, images[5], (float(c%10) / 5 - 1.0))
karamba.changeImageChannelIntensity(widget, images[6], (float(c%10) / 5 - 1.0), 'blue')
karamba.changeImageToGray(widget, images[7], 0)
if((c % 9) == 0):
karamba.removeImageTransformations(widget, images[8])
karamba.removeImageTransformations(widget, images[9])
karamba.removeImageTransformations(widget, images[10])
else:
karamba.rotateImage(widget, images[8], (c%9)*20 + 45)
karamba.resizeImage(widget, images[9], 50 + (c%5)*10, size[1])
karamba.resizeImageSmooth(widget, images[10], 50 + (c%5)*10, size[1])
if((c % 10) == 0):
karamba.addImageTooltip(widget, images[11], str(c))
if((c % 20) == 0):
if(images[12]):
karamba.deleteImage(widget, images[12])
images[12] = 0
else:
images[12] = karamba.createBackgroundImage(widget, 0, 340, "flag.png")
if(images[13]):
karamba.deleteImage(widget, images[13])
images[13] = 0
else:
tlist = karamba.getTaskList(widget)
images[13] = karamba.createTaskIcon(widget, 50, 340, tlist[c % len(tlist)])
c += 1
def widgetClicked(widget, x, y, button):
pass
def widgetMouseMoved(widget, x, y, button):
pass
# This will be printed when the widget loads.
print "Loaded Image test python extension!"
|