superkaramba: convert examples to python3.

Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
pull/44/head
Michele Calgaro 2 years ago
parent 5dab6232ef
commit da9cd0c056
Signed by: MicheleC
GPG Key ID: 2A75B7CA8ADED5CF

@ -18,7 +18,6 @@ def widgetUpdated(widget):
hidden = 1 hidden = 1
karamba.moveWidget(widget, 0, -210) karamba.moveWidget(widget, 0, -210)
#This gets called everytime our widget is clicked. #This gets called everytime our widget is clicked.
#Notes: #Notes:
# widget = reference to our widget # widget = reference to our widget
@ -33,21 +32,10 @@ def widgetUpdated(widget):
def widgetClicked(widget, x, y, button): def widgetClicked(widget, x, y, button):
pass pass
#This gets called everytime our widget is clicked. #This gets called everytime the mouse moves on the widget area
#Notes #Warning: Don't do anything too intensive here
# widget = reference to our widget #You don't want to run some complex piece of code everytime the mouse moves
# x = x position (relative to our widget)
# y = y position (relative to our widget)
# botton = button being held:
# 0 = No Mouse Button
# 1 = Left Mouse Button
# 2 = Middle Mouse Button
# 3 = Right Mouse Button, but this will never happen
# because the right mouse button brings up the
# Karamba menu.
def widgetMouseMoved(widget, x, y, button): def widgetMouseMoved(widget, x, y, button):
#Warning: Don't do anything too intensive here
#You don't want to run some complex piece of code everytime the mouse moves
global hidden global hidden
global counter global counter
if (hidden==1): if (hidden==1):
@ -55,8 +43,6 @@ def widgetMouseMoved(widget, x, y, button):
hidden = 0 hidden = 0
counter = 0 counter = 0
# This will be printed when the widget loads. # This will be printed when the widget loads.
print "Loaded my python extension!" print("Loaded my python extension!")

@ -24,9 +24,9 @@ def widgetUpdated(widget):
# vertical & bitmap # vertical & bitmap
b = karamba.getBarVertical(widget, bars[7]) b = karamba.getBarVertical(widget, bars[7])
print "getVertical: " + str(b) print("getVertical: " + str(b))
bmp = karamba.getBarImage(widget, bars[7]) bmp = karamba.getBarImage(widget, bars[7])
print "getBitmap: " + str(bmp) print("getBitmap: " + str(bmp))
b = (b+1)%2 b = (b+1)%2
karamba.setBarVertical(widget, bars[7], b) karamba.setBarVertical(widget, bars[7], b)
if(b): if(b):
@ -38,13 +38,13 @@ def widgetUpdated(widget):
# size & resize # size & resize
size = karamba.getBarSize(widget, bars[1]) size = karamba.getBarSize(widget, bars[1])
print "getBarSize: " + str(size) print("getBarSize: " + str(size))
size = ((b * 100) + 100, size[1]) size = ((b * 100) + 100, size[1])
karamba.resizeBar(widget, bars[1], size[0], size[1]) karamba.resizeBar(widget, bars[1], size[0], size[1])
# pos & move # pos & move
pos = karamba.getBarPos(widget, bars[2]) pos = karamba.getBarPos(widget, bars[2])
print "getBarPos: " + str(pos) print("getBarPos: " + str(pos))
pos = (b * 200, pos[1]) pos = (b * 200, pos[1])
karamba.moveBar(widget, bars[2], pos[0], pos[1]) karamba.moveBar(widget, bars[2], pos[0], pos[1])
@ -56,19 +56,19 @@ def widgetUpdated(widget):
# Value # Value
v = karamba.getBarValue(widget, bars[5]) v = karamba.getBarValue(widget, bars[5])
print "getBarValue: ", v print("getBarValue: ", v)
v = (v + 10) % 110 v = (v + 10) % 110
karamba.setBarValue(widget, bars[5], v) karamba.setBarValue(widget, bars[5], v)
# Min Max # Min Max
minmax = karamba.getBarMinMax(widget, bars[6]) minmax = karamba.getBarMinMax(widget, bars[6])
print "getBarMinMax: " + str(minmax) print("getBarMinMax: " + str(minmax))
minmax = (0, (b * 100) + 100) minmax = (0, (b * 100) + 100)
karamba.setBarMinMax(widget, bars[6], minmax[0], minmax[1]) karamba.setBarMinMax(widget, bars[6], minmax[0], minmax[1])
# Sensor # Sensor
sensor = karamba.getBarSensor(widget, bars[4]) sensor = karamba.getBarSensor(widget, bars[4])
print "getSensor: " + str(sensor) print("getSensor: " + str(sensor))
if(b): if(b):
karamba.setBarSensor(widget, bars[4], 'SENSOR=SENSOR TYPE="cpu_temp"') karamba.setBarSensor(widget, bars[4], 'SENSOR=SENSOR TYPE="cpu_temp"')
else: else:
@ -90,4 +90,4 @@ def widgetMouseMoved(widget, x, y, button):
pass pass
# This will be printed when the widget loads. # This will be printed when the widget loads.
print "Loaded Bar test python extension!" print("Loaded Bar test python extension!")

@ -11,50 +11,53 @@ text = None
#this is called when you widget is initialized #this is called when you widget is initialized
def initWidget(widget): def initWidget(widget):
global seq
karamba.redrawWidget(widget) global text
seq = 0
text = None
karamba.redrawWidget(widget)
# sequence drops down to zero and changes the time interval to 1 second. # sequence drops down to zero and changes the time interval to 1 second.
# keeps counting down thereafter... # keeps counting down thereafter...
def widgetUpdated(widget): def widgetUpdated(widget):
global seq global seq
global text global text
seq -= 1 seq -= 1
if seq <= 0: if seq <= 0:
karamba.changeInterval(widget, 1000) karamba.changeInterval(widget, 1000)
if seq <= 0: if seq <= 0:
message = "biding-time seq:%d" % -seq message = "biding-time seq:%d" % -seq
else: else:
message = "wiggle seq:%d" % seq message = "wiggle seq:%d" % seq
# delete previous text if exists. # delete previous text if exists.
if text is not None: if text is not None:
karamba.deleteText(widget, text) karamba.deleteText(widget, text)
# display new message # display new message
text = karamba.createText(widget, 0, 20, 300, 20, message) text = karamba.createText(widget, 0, 20, 300, 20, message)
karamba.changeTextColor(widget, text, 252,252,252) karamba.changeTextColor(widget, text, 252,252,252)
karamba.redrawWidget(widget) karamba.redrawWidget(widget)
# wiggle the mouse over the widget to get the sequence number increased more. # wiggle the mouse over the widget to get the sequence number increased more.
# also set the refresh rate to 50ms so that the theme has to fight against # also set the refresh rate to 50ms so that the theme has to fight against
# the wiggling. # the wiggling.
def widgetMouseMoved(widget, x, y, button): def widgetMouseMoved(widget, x, y, button):
global seq global seq
if seq <= 0: if seq <= 0:
seq = 0 seq = 0
karamba.changeInterval(widget, 50) karamba.changeInterval(widget, 50)
seq += 1 seq += 1
# This will be printed when the widget loads. # This will be printed when the widget loads.
print "Loaded my python extension!" print("Loaded my python extension!")

@ -10,40 +10,40 @@ mgmt_txt = None
#this is called when you widget is initialized #this is called when you widget is initialized
def initWidget(widget): def initWidget(widget):
global do_nothing_txt global do_nothing_txt
global do_something_txt global do_something_txt
# display new message # display new message
do_nothing_txt = karamba.createText(widget, 0, 00, 300, 20, do_nothing_txt = karamba.createText(widget, 0, 00, 300, 20,
"Right mouse click me!") "Right mouse click me!")
karamba.changeTextColor(widget, do_nothing_txt, 252,252,252) karamba.changeTextColor(widget, do_nothing_txt, 252,252,252)
mgmt_txt = karamba.createText(widget, 0, 20, 300, 20, mgmt_txt = karamba.createText(widget, 0, 20, 300, 20,
"Righ mouse click me too!") "Righ mouse click me too!")
karamba.changeTextColor(widget, mgmt_txt, 252,252,252) karamba.changeTextColor(widget, mgmt_txt, 252,252,252)
karamba.redrawWidget(widget) karamba.redrawWidget(widget)
karamba.setWantRightButton(widget, 1) karamba.setWantRightButton(widget, 1)
def widgetUpdated(widget): def widgetUpdated(widget):
karamba.redrawWidget(widget) karamba.redrawWidget(widget)
def widgetClicked(widget, x, y, button): def widgetClicked(widget, x, y, button):
global do_nothing_txt global do_nothing_txt
if y < 20: if y < 20:
if do_nothing_txt is not None: if do_nothing_txt is not None:
karamba.deleteText(widget, do_nothing_txt) karamba.deleteText(widget, do_nothing_txt)
do_nothing_txt = karamba.createText(widget, do_nothing_txt = karamba.createText(widget,
0, 0, 300, 20, "I don't do anything when clicking here.") 0, 0, 300, 20, "I don't do anything when clicking here.")
karamba.changeTextColor(widget, do_nothing_txt, karamba.changeTextColor(widget, do_nothing_txt,
255,200,200) 255,200,200)
karamba.redrawWidget(widget) karamba.redrawWidget(widget)
return return
karamba.managementPopup(widget) karamba.managementPopup(widget)
# This will be printed when the widget loads. # This will be printed when the widget loads.
print "Loaded my python extension!" print("Loaded my python extension!")

@ -45,7 +45,7 @@ def widgetClicked(widget, x, y, button):
if text2: if text2:
karamba.deleteText(widget,text2) karamba.deleteText(widget,text2)
text2 = karamba.createText(widget,5,70,400,20,newText) text2 = karamba.createText(widget,5,70,400,20,newText)
print newText print(newText)
elif not clicked and button == 1: elif not clicked and button == 1:
clicked = True clicked = True
karamba.setWantRightButton(widget, True) karamba.setWantRightButton(widget, True)
@ -53,9 +53,9 @@ def widgetClicked(widget, x, y, button):
if text2: if text2:
karamba.deleteText(widget,text2) karamba.deleteText(widget,text2)
text2 = karamba.createText(widget,5,70,400,20,newText) text2 = karamba.createText(widget,5,70,400,20,newText)
print newText print(newText)
if button == 3: if button == 3:
print "Clicking the right mouse button is recognized now." print("Clicking the right mouse button is recognized now.")
karamba.redrawWidget(widget) karamba.redrawWidget(widget)
#This gets called everytime our widget is clicked. #This gets called everytime our widget is clicked.
@ -173,4 +173,4 @@ def keyPressed(widget, meter, char):
pass pass
# This will be printed when the widget loads. # This will be printed when the widget loads.
print "Loaded my python extension!" print("Loaded my python extension!")

@ -1,12 +1,14 @@
from distutils.core import setup, Extension from distutils.core import setup, Extension
module1 = Extension('xcursor', def main():
include_dirs = ['/usr/X11R6/include'], setup(name = 'XMouseCursor',
libraries = ['X11'], version = '1.0',
library_dirs = ['/usr/X11R6/lib'], description = 'Determines the position of the X mouse cursor',
sources = ['xcursor.c']) ext_modules = [Extension('xcursor',
include_dirs = ['/usr/X11R6/include'],
libraries = ['X11'],
library_dirs = ['/usr/X11R6/lib'],
sources = ['xcursor.c'])])
setup (name = 'XMouseCursor', if __name__ == "__main__":
version = '1.0', main()
description = 'Determines the position of the X mouse cursor',
ext_modules = [module1])

@ -26,6 +26,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
****************************************************************************/ ****************************************************************************/
#define PY_SSIZE_T_CLEAN
#include <Python.h> #include <Python.h>
#include <X11/Xlib.h> #include <X11/Xlib.h>
@ -96,9 +97,16 @@ static PyMethodDef xcursorMethods[] =
{NULL, NULL, 0, NULL} /* Sentinel */ {NULL, NULL, 0, NULL} /* Sentinel */
}; };
void initxcursor(void) static struct PyModuleDef xcursordef =
{ {
(void) Py_InitModule("xcursor", xcursorMethods); PyModuleDef_HEAD_INIT,
} "xcursor",
NULL,
-1,
xcursorMethods
};
PyMODINIT_FUNC PyInit_xcursor(void)
{
return PyModule_Create(&xcursordef);
}

@ -38,117 +38,122 @@ lp_width, lp_height = 11, 17
rp_width, rp_height = 11, 17 rp_width, rp_height = 11, 17
def pupille(mouse_x, mouse_y, eye_center_x, eye_center_y, eye_a, eye_b, widget_x, widget_y): def pupille(mouse_x, mouse_y, eye_center_x, eye_center_y, eye_a, eye_b, widget_x, widget_y):
x = mouse_x - eye_center_x - widget_x x = mouse_x - eye_center_x - widget_x
y = mouse_y - eye_center_y - widget_y y = mouse_y - eye_center_y - widget_y
#print x, y #print(x, y)
r = math.sqrt(x * x + y * y) r = math.sqrt(x * x + y * y)
phi = math.atan2(y, x) phi = math.atan2(y, x)
#print phi * math.pi #print(phi * math.pi)
eye_x = eye_a * math.cos(phi) eye_x = eye_a * math.cos(phi)
eye_y = eye_b * math.sin(phi) eye_y = eye_b * math.sin(phi)
eye_r = math.sqrt(eye_x * eye_x + eye_y * eye_y) eye_r = math.sqrt(eye_x * eye_x + eye_y * eye_y)
if eye_r < r: if eye_r < r:
return int(eye_x + eye_center_x), int(eye_y + eye_center_y) return int(eye_x + eye_center_x), int(eye_y + eye_center_y)
return int(x + eye_center_x), int(y + eye_center_y) return int(x + eye_center_x), int(y + eye_center_y)
#this is called when you widget is initialized #this is called when you widget is initialized
def initWidget(widget): def initWidget(widget):
pass global init
global linkePupille
global rechtePupille
init = 0
linkePupille = ""
rechtePupille = ""
#this is called everytime your widget is updated #this is called everytime your widget is updated
#the update inverval is specified in the .theme file #the update inverval is specified in the .theme file
def widgetUpdated(widget): def widgetUpdated(widget):
global init global init
global linkePupille global linkePupille
global rechtePupille global rechtePupille
global w_width global w_width
global w_height global w_height
global w_x global w_x
global w_y global w_y
global lx global lx
global ly global ly
global la global la
global lb global lb
global lp_width global lp_width
global lp_height global lp_height
global rx global rx
global ry global ry
global ra global ra
global rb global rb
global rp_width global rp_width
global rp_height global rp_height
global x_old global x_old
global y_old global y_old
if init == 0: if init == 0:
theme_path = karamba.getThemePath(widget) + "/" theme_path = karamba.getThemePath(widget) + "/"
# read widget coordinates from eyes.theme # read widget coordinates from eyes.theme
# f = open(theme_path + "eyes.theme") # f = open(theme_path + "eyes.theme")
# karamba_line = "" # karamba_line = ""
#while re.compile('KARAMBA').search(karamba_line) == None: #while re.compile('KARAMBA').search(karamba_line) == None:
# karamba_line = f.readline() # karamba_line = f.readline()
#w_x = int(re.compile('X=([0-9]+)').search(karamba_line).group(1)) #w_x = int(re.compile('X=([0-9]+)').search(karamba_line).group(1))
#w_y = int(re.compile('Y=([0-9]+)').search(karamba_line).group(1)) #w_y = int(re.compile('Y=([0-9]+)').search(karamba_line).group(1))
#f.close() #f.close()
#karamba.createWidgetMask(widget, theme_path + "pics/mask.png") #karamba.createWidgetMask(widget, theme_path + "pics/mask.png")
linkePupille = karamba.createImage(widget, 15, 30, theme_path + "pics/pupille.png") linkePupille = karamba.createImage(widget, 15, 30, theme_path + "pics/pupille.png")
rechtePupille = karamba.createImage(widget, 100, 30, theme_path + "pics/pupille.png") rechtePupille = karamba.createImage(widget, 100, 30, theme_path + "pics/pupille.png")
init = 1 init = 1
karamba.redrawWidget(widget) karamba.redrawWidget(widget)
# query mouse-cursor position # query mouse-cursor position
x, y = xcursor.position() x, y = xcursor.position()
#fp = os.popen("./xpos") #fp = os.popen("./xpos")
#output = fp.read() #output = fp.read()
#x, y = output.split() #x, y = output.split()
#print x, y #print(x, y)
if x != x_old or y != y_old: if x != x_old or y != y_old:
x_old, y_old = x, y x_old, y_old = x, y
# Get Widget Position # Get Widget Position
w_x, w_y = karamba.getWidgetPosition(widget) w_x, w_y = karamba.getWidgetPosition(widget)
# Calc left pupille # Calc left pupille
xp, yp = pupille (int(x), int(y), lx, ly, la, lb, w_x, w_y) xp, yp = pupille (int(x), int(y), lx, ly, la, lb, w_x, w_y)
xp = xp - lp_width / 2 xp = xp - lp_width // 2
yp = yp - lp_height / 2 yp = yp - lp_height // 2
#print xp, yp #print(xp, yp)
karamba.moveImage(widget, linkePupille, xp, yp) karamba.moveImage(widget, linkePupille, xp, yp)
# Calc right pupille # Calc right pupille
xp, yp = pupille (int(x), int(y), rx, ry, ra, rb, w_x, w_y) xp, yp = pupille (int(x), int(y), rx, ry, ra, rb, w_x, w_y)
xp = xp - rp_width / 2 xp = xp - rp_width // 2
yp = yp - rp_height / 2 yp = yp - rp_height // 2
#print xp, yp #print(xp, yp)
karamba.moveImage(widget, rechtePupille, xp, yp) karamba.moveImage(widget, rechtePupille, xp, yp)
karamba.redrawWidget(widget) karamba.redrawWidget(widget)
#This gets called everytime our widget is clicked. #This gets called everytime our widget is clicked.
#Notes: #Notes:
@ -180,13 +185,13 @@ def widgetClicked(widget, x, y, button):
def widgetMouseMoved(widget, x, y, button): def widgetMouseMoved(widget, x, y, button):
#Warning: Don't do anything too intensive here #Warning: Don't do anything too intensive here
#You don't want to run some complex piece of code everytime the mouse moves #You don't want to run some complex piece of code everytime the mouse moves
pass pass
#global linkePupille #global linkePupille
#karamba.moveImage(widget, linkePupille, x, y) #karamba.moveImage(widget, linkePupille, x, y)
#karamba.redrawWidget(widget) #karamba.redrawWidget(widget)
# This will be printed when the widget loads. # This will be printed when the widget loads.
print "Loaded Karamba Eyes" print("Loaded Karamba Eyes")

@ -28,20 +28,20 @@ def widgetUpdated(widget):
if(graphs[0]): if(graphs[0]):
karamba.deleteGraph(widget, graphs[0]) karamba.deleteGraph(widget, graphs[0])
graphs[0] = 0 graphs[0] = 0
print "Deleted graph." print("Deleted graph.")
else: else:
graphs[0] = karamba.createGraph(widget, 0, 20, 400, 30, 400) graphs[0] = karamba.createGraph(widget, 0, 20, 400, 30, 400)
print "Created graph: " + str(graphs[0]) print("Created graph: " + str(graphs[0]))
# size & resize # size & resize
size = karamba.getGraphSize(widget, graphs[1]) size = karamba.getGraphSize(widget, graphs[1])
print "getGraphSize: " + str(size) print("getGraphSize: " + str(size))
size = ((b * 200) + 200, size[1]) size = ((b * 200) + 200, size[1])
karamba.resizeGraph(widget, graphs[1], size[0], size[1]) karamba.resizeGraph(widget, graphs[1], size[0], size[1])
# pos & move # pos & move
pos = karamba.getGraphPos(widget, graphs[2]) pos = karamba.getGraphPos(widget, graphs[2])
print "getGraphPos: " + str(pos) print("getGraphPos: " + str(pos))
pos = (b * 200, pos[1]) pos = (b * 200, pos[1])
karamba.moveGraph(widget, graphs[2], pos[0], pos[1]) karamba.moveGraph(widget, graphs[2], pos[0], pos[1])
@ -53,7 +53,7 @@ def widgetUpdated(widget):
# Sensor # Sensor
sensor = karamba.getGraphSensor(widget, graphs[4]) sensor = karamba.getGraphSensor(widget, graphs[4])
print "getSensor: " + str(sensor) print("getSensor: " + str(sensor))
if(b): if(b):
karamba.setGraphSensor(widget, graphs[4], 'SENSOR=NETWORK FORMAT="%in"') karamba.setGraphSensor(widget, graphs[4], 'SENSOR=NETWORK FORMAT="%in"')
else: else:
@ -61,19 +61,19 @@ def widgetUpdated(widget):
# Min Max # Min Max
minmax = karamba.getGraphMinMax(widget, graphs[5]) minmax = karamba.getGraphMinMax(widget, graphs[5])
print "getGraphMinMax: " + str(minmax) print("getGraphMinMax: " + str(minmax))
minmax = (0, (b * 25) + 25) minmax = (0, (b * 25) + 25)
karamba.setGraphMinMax(widget, graphs[5], minmax[0], minmax[1]) karamba.setGraphMinMax(widget, graphs[5], minmax[0], minmax[1])
# Value # Value
v = karamba.getGraphValue(widget, graphs[6]) v = karamba.getGraphValue(widget, graphs[6])
print "getGraphValue: ", v print("getGraphValue: ", v)
v = (v + 1) % 30 v = (v + 1) % 30
karamba.setGraphValue(widget, graphs[6], v) karamba.setGraphValue(widget, graphs[6], v)
# Color # Color
c = karamba.getGraphColor(widget, graphs[7]) c = karamba.getGraphColor(widget, graphs[7])
print "getGraphColor: ", c print("getGraphColor: ", c)
r = (c[0] + 10) % 255 r = (c[0] + 10) % 255
g = (c[1] + 10) % 255 g = (c[1] + 10) % 255
bl = (c[2] + 10) % 255 bl = (c[2] + 10) % 255
@ -86,4 +86,4 @@ def widgetMouseMoved(widget, x, y, button):
pass pass
# This will be printed when the widget loads. # This will be printed when the widget loads.
print "Loaded Graph test python extension!" print("Loaded Graph test python extension!")

@ -44,22 +44,22 @@ def widgetUpdated(widget):
# size & resize # size & resize
size = karamba.getImageSize(widget, images[1]) size = karamba.getImageSize(widget, images[1])
print "getImageSize: " + str(size) print("getImageSize: " + str(size))
print "getImageWidth: " + str(karamba.getImageWidth(widget, images[1])) print("getImageWidth: " + str(karamba.getImageWidth(widget, images[1])))
print "getImageHeight: " + str(karamba.getImageHeight(widget, images[1])) print("getImageHeight: " + str(karamba.getImageHeight(widget, images[1])))
# Auto size # Auto size
#size = ((b * 200) + 200, size[1]) #size = ((b * 200) + 200, size[1])
#karamba.resizeImage(widget, images[1], size[0], size[1]) #karamba.resizeImage(widget, images[1], size[0], size[1])
# pos & move # pos & move
pos = karamba.getImagePos(widget, images[2]) pos = karamba.getImagePos(widget, images[2])
print "getImagePos: " + str(pos) print("getImagePos: " + str(pos))
pos = (b * 200, pos[1]) pos = (b * 200, pos[1])
karamba.moveImage(widget, images[2], pos[0], pos[1]) karamba.moveImage(widget, images[2], pos[0], pos[1])
# Sensor # Sensor
sensor = karamba.getImageSensor(widget, images[3]) sensor = karamba.getImageSensor(widget, images[3])
print "getSensor: " + str(sensor) print("getSensor: " + str(sensor))
if(b): if(b):
karamba.setImageSensor(widget, images[3], 'SENSOR=PROGRAM PROGRAM="/tmp/test1.sh"') karamba.setImageSensor(widget, images[3], 'SENSOR=PROGRAM PROGRAM="/tmp/test1.sh"')
else: else:
@ -67,7 +67,7 @@ def widgetUpdated(widget):
# Value # Value
v = karamba.getImagePath(widget, images[4]) v = karamba.getImagePath(widget, images[4])
print "getImagePath: ", v print("getImagePath: ", v)
if(b): if(b):
v = 'flag.png' v = 'flag.png'
else: else:
@ -118,4 +118,4 @@ def widgetMouseMoved(widget, x, y, button):
pass pass
# This will be printed when the widget loads. # This will be printed when the widget loads.
print "Loaded Image test python extension!" print("Loaded Image test python extension!")

@ -182,4 +182,4 @@ def keyPressed(widget, meter, char):
pass pass
# This will be printed when the widget loads. # This will be printed when the widget loads.
print "Loaded my python extension!" print("Loaded my python extension!")

@ -153,7 +153,7 @@ def wallpaperChanged(widget, desktop):
def keyPressed(widget, meter, char): def keyPressed(widget, meter, char):
global input, output global input, output
if meter == input: if meter == input:
print "keyPressed: key= '", char, "'" print("keyPressed: key= '", char, "'")
text = karamba.getInputBoxValue(widget, input) text = karamba.getInputBoxValue(widget, input)
karamba.changeText(widget, output, "Searched: " + text) karamba.changeText(widget, output, "Searched: " + text)
try: try:
@ -161,9 +161,9 @@ def keyPressed(widget, meter, char):
url = "konqueror leo:" + text url = "konqueror leo:" + text
os.system(url + "&") os.system(url + "&")
except TypeError: except TypeError:
print "There was a type error" print("There was a type error")
karamba.redrawWidget(widget) karamba.redrawWidget(widget)
# This will be printed when the widget loads. # This will be printed when the widget loads.
print "Loaded my python extension!" print("Loaded my python extension!")

@ -186,5 +186,5 @@ def activeTaskChanged(widget, task):
pass pass
# This will be printed when the widget loads. # This will be printed when the widget loads.
print "Loaded my python extension!" print("Loaded my python extension!")

@ -134,5 +134,5 @@ def activeTaskChanged(widget, task):
pass pass
# This will be printed when the widget loads. # This will be printed when the widget loads.
print "Loaded my python extension!" print("Loaded my python extension!")

@ -20,21 +20,21 @@ def initWidget(widget):
global id5 global id5
menu1 = karamba.createMenu(widget) menu1 = karamba.createMenu(widget)
print "menu 1 created!" print("menu 1 created!")
menu2 = karamba.createMenu(widget) menu2 = karamba.createMenu(widget)
print "menu 2 created!" print("menu 2 created!")
id1 = karamba.addMenuItem(widget, menu1, "menu 1 first item", "kword") id1 = karamba.addMenuItem(widget, menu1, "menu 1 first item", "kword")
print "item 1 entered in menu 1" print("item 1 entered in menu 1")
id2 = karamba.addMenuItem(widget, menu1, "menu 1 second item", "kate") id2 = karamba.addMenuItem(widget, menu1, "menu 1 second item", "kate")
print "item 2 entered in menu 1" print("item 2 entered in menu 1")
id3 = karamba.addMenuItem(widget, menu2, "menu 2 first item", "kword") id3 = karamba.addMenuItem(widget, menu2, "menu 2 first item", "kword")
print "item 1 entered in menu 2" print("item 1 entered in menu 2")
id4 = karamba.addMenuItem(widget, menu2, "menu 2 second item", "kate") id4 = karamba.addMenuItem(widget, menu2, "menu 2 second item", "kate")
print "item 2 entered in menu 2" print("item 2 entered in menu 2")
id5 = karamba.addMenuItem(widget, menu2, "menu 2 third item", "/opt/kde/share/icons/kdeclassic/16x16/apps/kicker.png") id5 = karamba.addMenuItem(widget, menu2, "menu 2 third item", "/opt/kde/share/icons/kdeclassic/16x16/apps/kicker.png")
print "item 3 entered in menu 2" print("item 3 entered in menu 2")
@ -95,23 +95,23 @@ def menuItemClicked(widget, menu, id):
if (menu == menu1): if (menu == menu1):
if(id == id1): if(id == id1):
print "item 1 in menu 1 clicked." print("item 1 in menu 1 clicked.")
elif(id == id2): elif(id == id2):
print "item 2 in menu 1 clicked, removing item 2 in menu 2" print("item 2 in menu 1 clicked, removing item 2 in menu 2")
karamba.removeMenuItem(widget, menu2, id4) karamba.removeMenuItem(widget, menu2, id4)
elif (menu == menu2): elif (menu == menu2):
if(id == id3): if(id == id3):
print "item 1 in menu 2 clicked." print("item 1 in menu 2 clicked.")
elif(id == id4): elif(id == id4):
print "item 2 in menu 2 clicked, deleting menu 1 (if menu1 still exists...)" print("item 2 in menu 2 clicked, deleting menu 1 (if menu1 still exists...)")
karamba.deleteMenu(widget, menu1) karamba.deleteMenu(widget, menu1)
elif(id == id5): elif(id == id5):
print "item 3 in menu 2 clicked, removing item 2 in menu 1 (if menu1 still exists...)" print("item 3 in menu 2 clicked, removing item 2 in menu 1 (if menu1 still exists...)")
karamba.removeMenuItem(widget, menu1, id2) karamba.removeMenuItem(widget, menu1, id2)
# This will be printed when the widget loads. # This will be printed when the widget loads.
print "Loaded my python extension!" print("Loaded my python extension!")

@ -30,7 +30,7 @@ is used to encode the formatting commands.</p>
<p><font size=+2>Some features:</font> <p><font size=+2>Some features:</font>
<ul> <ul>
<li>Numbered and unnumbered lists</li> <li>Numbered and unnumbered lists</li>
<li>Inline Images <img src=\"""" + karamba.getThemePath(widget) + u"""info.png\"</li> <li>Inline Images <img src=\"""" + karamba.getThemePath(widget) + """info.png\"</li>
<li>Various <font color="red">different</font><font color="blue"> text</font><font color="green"> colours</font></li> <li>Various <font color="red">different</font><font color="blue"> text</font><font color="green"> colours</font></li>
<li>Hyperlinks: <a href="kfmclient openURL http://netdragon.sourceforge.net"> Superkaramba Homepage</a></li> <li>Hyperlinks: <a href="kfmclient openURL http://netdragon.sourceforge.net"> Superkaramba Homepage</a></li>
<li>Links can also <a href="#trigger">trigger</a> actions in the script</li> <li>Links can also <a href="#trigger">trigger</a> actions in the script</li>
@ -53,7 +53,7 @@ http://doc.trolltech.com/3.0/qstylesheet.html</a>.
karamba.moveRichText(widget, richtext, 10, 10) karamba.moveRichText(widget, richtext, 10, 10)
print "richText Size = ", karamba.getRichTextSize(widget, richtext) print("richText Size = ", karamba.getRichTextSize(widget, richtext))
karamba.setRichTextWidth(widget, richtext, 345) karamba.setRichTextWidth(widget, richtext, 345)
@ -104,7 +104,7 @@ def meterClicked(widget, meter, button):
global penguin_hidden global penguin_hidden
global richtext global richtext
print "Meter clicked", meter print("Meter clicked", meter)
if meter == "trigger": if meter == "trigger":
if penguin_hidden: if penguin_hidden:
karamba.showImage(widget, penguin) karamba.showImage(widget, penguin)
@ -133,4 +133,4 @@ def widgetMouseMoved(widget, x, y, button):
pass pass
# This will be printed when the widget loads. # This will be printed when the widget loads.
print "Loaded Karamba Unicode Test" print("Loaded Karamba Unicode Test")

@ -38,19 +38,19 @@ def widgetUpdated(widget):
karamba.moveRichText(widget, texts[0], 0, 20) karamba.moveRichText(widget, texts[0], 0, 20)
karamba.resizeRichText(widget, texts[0], 200, 20) karamba.resizeRichText(widget, texts[0], 200, 20)
pos = karamba.getRichTextPos(widget, texts[0]) pos = karamba.getRichTextPos(widget, texts[0])
print "--getRichTextPos: " + str(pos) print("--getRichTextPos: " + str(pos))
size = karamba.getRichTextSize(widget, texts[0]) size = karamba.getRichTextSize(widget, texts[0])
print "--getRichTextSize: " + str(size) print("--getRichTextSize: " + str(size))
# size & resize # size & resize
size = karamba.getRichTextSize(widget, texts[1]) size = karamba.getRichTextSize(widget, texts[1])
print "getRichTextSize: " + str(size) print("getRichTextSize: " + str(size))
size = ((b * 200) + 200, size[1]) size = ((b * 200) + 200, size[1])
karamba.resizeRichText(widget, texts[1], size[0], size[1]) karamba.resizeRichText(widget, texts[1], size[0], size[1])
# pos & move # pos & move
pos = karamba.getRichTextPos(widget, texts[2]) pos = karamba.getRichTextPos(widget, texts[2])
print "getRichTextPos: " + str(pos) print("getRichTextPos: " + str(pos))
pos = (b * 200, pos[1]) pos = (b * 200, pos[1])
karamba.moveRichText(widget, texts[2], pos[0], pos[1]) karamba.moveRichText(widget, texts[2], pos[0], pos[1])
@ -62,7 +62,7 @@ def widgetUpdated(widget):
# Sensor # Sensor
sensor = karamba.getRichTextSensor(widget, texts[4]) sensor = karamba.getRichTextSensor(widget, texts[4])
print "getSensor: " + str(sensor) print("getSensor: " + str(sensor))
if(b): if(b):
karamba.setRichTextSensor(widget, texts[4], 'SENSOR=SENSOR TYPE="cpu_temp"') karamba.setRichTextSensor(widget, texts[4], 'SENSOR=SENSOR TYPE="cpu_temp"')
else: else:
@ -70,19 +70,19 @@ def widgetUpdated(widget):
# Value # Value
v = karamba.getRichTextValue(widget, texts[5]) v = karamba.getRichTextValue(widget, texts[5])
print "getRichTextValue: ", v print("getRichTextValue: ", v)
v += '.' v += '.'.encode('utf-8')
karamba.changeRichText(widget, texts[5], v) karamba.changeRichText(widget, texts[5], v)
# Font size # Font size
v = karamba.getRichTextFontSize(widget, texts[7]) v = karamba.getRichTextFontSize(widget, texts[7])
print "getRichTextFontSize: ", v print("getRichTextFontSize: ", v)
v = 10 + ((v-10)+1)%10; v = 10 + ((v-10)+1)%10;
karamba.changeRichTextSize(widget, texts[7], v) karamba.changeRichTextSize(widget, texts[7], v)
# RichText Font # RichText Font
v = karamba.getRichTextFont(widget, texts[9]) v = karamba.getRichTextFont(widget, texts[9])
print "getRichTextFont: ", v print("getRichTextFont: ", v)
if(b): if(b):
v = 'Bitstream Vera Sans' v = 'Bitstream Vera Sans'
else: else:
@ -96,4 +96,4 @@ def widgetMouseMoved(widget, x, y, button):
pass pass
# This will be printed when the widget loads. # This will be printed when the widget loads.
print "Loaded RichText test python extension!" print("Loaded RichText test python extension!")

@ -16,23 +16,25 @@ import karamba
# simple function to display # simple function to display
def create_text(widget, line, depth, disp, name=None, command=None, icon=None): def create_text(widget, line, depth, disp, name=None, command=None, icon=None):
print(name)
print(disp)
x = depth*30 x = depth*30
y = line*7 y = line*12
width = 400 width = 400
height = 8 height = 12
drop_txt = karamba.createText(widget, x, y, width, height, disp) drop_txt = karamba.createText(widget, x, y, width, height, disp)
karamba.changeTextSize(widget, drop_txt, 7) karamba.changeTextSize(widget, drop_txt, 11)
karamba.changeTextColor(widget, drop_txt, 252,252,252) karamba.changeTextColor(widget, drop_txt, 252,252,252)
# create a (very narrow! only an 8-pixel-high area!) # create a (very narrow! only an 12-pixel-high area!)
# service click area to demonstrate that commands get # service click area to demonstrate that commands get
# executed correctly. # executed correctly.
if name: if name:
karamba.createServiceClickArea( widget, karamba.createServiceClickArea( widget,
x,y,width,height, x,y,width,height,
name, command, icon) str(name), str(command), str(icon))
# okay. you really should be looking up the KDE Developer documentation # okay. you really should be looking up the KDE Developer documentation
@ -92,14 +94,14 @@ def display_svc_group(widget, rel_path, line, depth):
for (type, d) in grps: for (type, d) in grps:
if type is 0: if type == 0:
# it's a # it's a
sub_relpath = d['relpath'] sub_relpath = d[b'relpath'].decode('utf-8')
icon = d.get('icon', 'unknown') icon = d.get(b'icon', 'unknown').decode('utf-8')
caption = d.get('caption', None) caption = d.get(b'caption', b'').decode('utf-8')
comment = d.get('comment', None) comment = d.get(b'comment', b'').decode('utf-8')
cmt = '' cmt = ''
# get at least something to display # get at least something to display
@ -109,23 +111,24 @@ def display_svc_group(widget, rel_path, line, depth):
cmt = caption cmt = caption
msg = "SVCGRP: %s %s" % (icon, cmt) msg = "SVCGRP: %s %s" % (icon, cmt)
print("MSG="+msg)
create_text(widget, line, depth, msg) create_text(widget, line, depth, msg)
line += 1 line += 1
line = display_svc_group(widget, sub_relpath, line = display_svc_group(widget, str(sub_relpath),
line, depth+1) line, depth+1)
elif type is 1 and d.has_key('menuid'): elif type == 1 and b'menuid' in d:
relpath = d.get('relpath', '') relpath = d.get(b'relpath', b'').decode('utf-8')
cmd = d['exec'] cmd = d[b'exec'].decode('utf-8')
icon = d.get('icon', 'unknown') icon = d.get(b'icon', 'unknown').decode('utf-8')
name = d.get('name', None) name = d.get(b'name', b'').decode('utf-8')
genericname = d.get('genericname', None) genericname = d.get(b'genericname', b'')
cmt = '' cmt = ''
# get at least something to display # get at least something to display
if genericname: if genericname:
cmt = genericname cmt = genericname.decode('utf-8')
elif name: elif name:
cmt = name cmt = name

@ -14,7 +14,7 @@ def initWidget(widget):
# this resets the text to "" so we know we've never # this resets the text to "" so we know we've never
# received anything yet from the other theme # received anything yet from the other theme
name = karamba.getPrettyThemeName(widget) name = karamba.getPrettyThemeName(widget)
print "2.py name: ", name print("2.py name: ", name)
karamba.setIncomingData(widget, name, "") karamba.setIncomingData(widget, name, "")
karamba.redrawWidget(widget) karamba.redrawWidget(widget)
@ -47,7 +47,7 @@ def widgetUpdated(widget):
# get the "message"... # get the "message"...
disp = karamba.getIncomingData(widget) disp = karamba.getIncomingData(widget)
if disp == "": if disp == "" or disp == b'':
return return
# decode it... # decode it...
@ -74,5 +74,5 @@ def widgetUpdated(widget):
pass pass
# This will be printed when the widget loads. # This will be printed when the widget loads.
print "Loaded my python 2.py extension!" print("Loaded my python 2.py extension!")

@ -34,7 +34,7 @@ havexwi = os.system("which xwininfo")
if (havexwi == 0): if (havexwi == 0):
pass pass
else: else:
print "\nCan't find xwininfo in your path." print("\nCan't find xwininfo in your path.")
fp = os.popen("xwininfo -root -stats") fp = os.popen("xwininfo -root -stats")
output = fp.read() output = fp.read()
@ -49,8 +49,6 @@ for x in output:
resY = int(param[1]) resY = int(param[1])
def drawTaskbar(widget): def drawTaskbar(widget):
global taskPanels global taskPanels
global taskText global taskText
@ -81,40 +79,41 @@ def drawTaskbar(widget):
#build groups list that contains sub-lists of taskInfo sorted by group #build groups list that contains sub-lists of taskInfo sorted by group
for j in range(len(taskList)): for j in range(len(taskList)):
taskinfo = karamba.getTaskInfo(widget, taskList[j]) taskinfo = karamba.getTaskInfo(widget, taskList[j])
if knownGroups.has_key(taskinfo[2]) == 0: if (taskinfo[2] in knownGroups) == 0:
groupCount = groupCount + 1 groupCount = groupCount + 1
if (taskinfo[7] == 1): if (taskinfo[7] == 1):
activeGroup = groupCount activeGroup = groupCount
knownGroups[taskinfo[2]] = 1 knownGroups[taskinfo[2]] = 1
thisGroup = [] thisGroup = []
thisGroup.append(taskinfo) thisGroup.append(taskinfo)
groupRefs[taskinfo[2]] = len(groups) groupRefs[taskinfo[2]] = len(groups)
groups.append(thisGroup) groups.append(thisGroup)
else: else:
if (taskinfo[7] == 1): if (taskinfo[7] == 1):
activeGroup = groupRefs[taskinfo[2]] + 1 activeGroup = groupRefs[taskinfo[2]] + 1
knownGroups[taskinfo[2]] = knownGroups[taskinfo[2]] + 1 knownGroups[taskinfo[2]] = knownGroups[taskinfo[2]] + 1
thisGroup = groups[groupRefs[taskinfo[2]]] thisGroup = groups[groupRefs[taskinfo[2]]]
thisGroup.append(taskinfo) thisGroup.append(taskinfo)
#fill out the task bar #fill out the task bar
j = 0 j = 0
for group in groups: for group in groups:
#safety check (could be more task groups than bar is long) #safety check (could be more task groups than bar is long)
if (j < length): if (j < length):
karamba.showImage(widget, taskPanels[j]) karamba.showImage(widget, taskPanels[j])
if len(group) != 1: if len(group) != 1:
karamba.changeText(widget, taskText[j], group[0][2] + " [" + str(len(group)) + "]") karamba.changeText(widget, taskText[j], group[0][2].decode('utf-8') + ' [' + str(len(group)) + ']')
else: else:
karamba.changeText(widget, taskText[j], (group[0][0])) karamba.changeText(widget, taskText[j], group[0][0].decode('utf-8'))
j = j + 1 j = j + 1
if (activeGroup != 0): if (activeGroup != 0):
karamba.changeTextShadow(widget, taskText[activeGroup - 1], 1) karamba.changeTextShadow(widget, taskText[activeGroup - 1], 1)
karamba.changeTextColor(widget, taskText[activeGroup - 1], 239, 220, 11) karamba.changeTextColor(widget, taskText[activeGroup - 1], 239, 220, 11)
karamba.moveWidget(widget, 0, resY - 32)
karamba.resizeWidget(widget, resX, resY)
karamba.redrawWidget(widget) karamba.redrawWidget(widget)
#this is called when your widget is initialized #this is called when your widget is initialized
@ -126,7 +125,7 @@ def initWidget(widget):
global timeText global timeText
karamba.createImage(widget, resX - 149, 0, "pics/rightend_new.png") karamba.createImage(widget, resX - 149, 0, "pics/rightend_new.png")
numOfTasks = (resX - 198 - 149)/121 numOfTasks = (resX - 198 - 149) // 121
timeText = karamba.createText(widget, resX - 149 + 54, 10, 140, 20, "time") timeText = karamba.createText(widget, resX - 149 + 54, 10, 140, 20, "time")
karamba.changeTextColor(widget, timeText, 0,0,0) karamba.changeTextColor(widget, timeText, 0,0,0)
@ -143,13 +142,13 @@ def initWidget(widget):
# called to indicate that a new task is currently started # called to indicate that a new task is currently started
def startupAdded(widget, startup): def startupAdded(widget, startup):
pass pass
# called whenever a startup is removed. Which either means the task is # called whenever a startup is removed. Which either means the task is
# successfully started (and taskAdded will be called), or the task could # successfully started (and taskAdded will be called), or the task could
# not be started for some reason. # not be started for some reason.
def startupRemoved(widget, startup): def startupRemoved(widget, startup):
pass pass
# called whenever a new task has been started # called whenever a new task has been started
def taskAdded(widget, task): def taskAdded(widget, task):
@ -190,78 +189,75 @@ def widgetClicked(widget, x, y, button):
global taskMenu global taskMenu
global taskMenuLookup global taskMenuLookup
taskSelected = (x-198)/121 taskSelected = (x-198) // 121
## Make sure its a valid task ## Make sure its a valid task
if (0 <= taskSelected < numOfTasks): if (0 <= taskSelected < numOfTasks):
taskList = karamba.getTaskList(widget) taskList = karamba.getTaskList(widget)
#free last menu #free last menu
karamba.deleteMenu(widget, taskMenu) karamba.deleteMenu(widget, taskMenu)
#create new menu #create new menu
taskMenu = karamba.createMenu(widget) taskMenu = karamba.createMenu(widget)
taskMenuLoopup = {} taskMenuLoopup = {}
length = len(taskList) length = len(taskList)
if (numOfTasks < length): if (numOfTasks < length):
length = numOfTasks length = numOfTasks
knownGroups = {} knownGroups = {}
groups = [] groups = []
groupRefs = {} groupRefs = {}
for j in range(len(taskList)): for j in range(len(taskList)):
taskinfo = karamba.getTaskInfo(widget, taskList[j]) taskinfo = karamba.getTaskInfo(widget, taskList[j])
if knownGroups.has_key(taskinfo[2]) == 0: if (taskinfo[2] in knownGroups) == 0:
knownGroups[taskinfo[2]] = 1 knownGroups[taskinfo[2]] = 1
thisGroup = [] thisGroup = []
thisGroup.append(taskinfo) thisGroup.append(taskinfo)
groupRefs[taskinfo[2]] = len(groups) groupRefs[taskinfo[2]] = len(groups)
groups.append(thisGroup) groups.append(thisGroup)
else: else:
knownGroups[taskinfo[2]] = knownGroups[taskinfo[2]] + 1 knownGroups[taskinfo[2]] = knownGroups[taskinfo[2]] + 1
thisGroup = groups[groupRefs[taskinfo[2]]] thisGroup = groups[groupRefs[taskinfo[2]]]
thisGroup.append(taskinfo) thisGroup.append(taskinfo)
if taskSelected < len(groups): if taskSelected < len(groups):
taskGroup = groups[taskSelected] taskGroup = groups[taskSelected]
if len(taskGroup) == 1:
if len(taskGroup) == 1: #only one task in group - just switch to that app
#only one task in group - just switch to that app ## perform the task action (see Task API for list of numbers)
## perform the task action (see Task API for list of numbers) karamba.performTaskAction(widget, taskGroup[0][8], 8)
karamba.performTaskAction(widget, taskGroup[0][8], 8) else:
#more than one task in this group, make a popup
else: for task in taskGroup:
#more than one task in this group, make a popup #if it's minimized, put []'s around name
for task in taskGroup: if task[5] == 1:
#if it's minimized, put []'s around name item = karamba.addMenuItem(widget, taskMenu, "[ " + task[0].decode('utf-8') + " ]", task[2].decode('utf-8'))
if task[5] == 1: else:
item = karamba.addMenuItem(widget, taskMenu, "[ " + task[0] + " ]", task[2]) item = karamba.addMenuItem(widget, taskMenu, task[0].decode('utf-8'), task[2].decode('utf-8'))
else: #save the taskInfo item for later use
item = karamba.addMenuItem(widget, taskMenu, task[0], task[2]) #so we will know info for the task that
#save the taskInfo item for later use #will be clicked in the callback
#so we will know info for the task that taskMenuLookup[item] = task
#will be clicked in the callback
taskMenuLookup[item] = task numOfItems = len(taskGroup)
karamba.popupMenu(widget, taskMenu, 198 + (121*taskSelected), -1 * (numOfItems * 26))
numOfItems = len(taskGroup)
karamba.popupMenu(widget, taskMenu, 198 + (121*taskSelected), -1 * (numOfItems * 26))
if (taskSelected == numOfTasks): if (taskSelected == numOfTasks):
karamba.toggleShowDesktop(widget) karamba.toggleShowDesktop(widget)
#This gets called when an item is clicked in a popup menu you have created. #This gets called when an item is clicked in a popup menu you have created.
# menu = a reference to the menu # menu = a reference to the menu
# id = the number of the item that was clicked. # id = the number of the item that was clicked.
def menuItemClicked(widget, menu, id): def menuItemClicked(widget, menu, id):
global taskMenuLookup global taskMenuLookup
taskinfo = taskMenuLookup[id] taskinfo = taskMenuLookup[id]
karamba.performTaskAction(widget, taskinfo[8], 8) karamba.performTaskAction(widget, taskinfo[8], 8)

@ -157,4 +157,4 @@ def keyPressed(widget, meter, char):
pass pass
# This will be printed when the widget loads. # This will be printed when the widget loads.
print "Loaded my python extension!" print("Loaded my python extension!")

@ -38,13 +38,13 @@ def widgetUpdated(widget):
# size & resize # size & resize
size = karamba.getTextSize(widget, texts[1]) size = karamba.getTextSize(widget, texts[1])
print "getTextSize: " + str(size) print("getTextSize: " + str(size))
size = ((b * 200) + 200, size[1]) size = ((b * 200) + 200, size[1])
karamba.resizeText(widget, texts[1], size[0], size[1]) karamba.resizeText(widget, texts[1], size[0], size[1])
# pos & move # pos & move
pos = karamba.getTextPos(widget, texts[2]) pos = karamba.getTextPos(widget, texts[2])
print "getTextPos: " + str(pos) print("getTextPos: " + str(pos))
pos = (b * 200, pos[1]) pos = (b * 200, pos[1])
karamba.moveText(widget, texts[2], pos[0], pos[1]) karamba.moveText(widget, texts[2], pos[0], pos[1])
@ -56,7 +56,7 @@ def widgetUpdated(widget):
# Sensor # Sensor
sensor = karamba.getTextSensor(widget, texts[4]) sensor = karamba.getTextSensor(widget, texts[4])
print "getSensor: " + str(sensor) print("getSensor: " + str(sensor))
if(b): if(b):
karamba.setTextSensor(widget, texts[4], 'SENSOR=SENSOR TYPE="cpu_temp"') karamba.setTextSensor(widget, texts[4], 'SENSOR=SENSOR TYPE="cpu_temp"')
else: else:
@ -64,30 +64,30 @@ def widgetUpdated(widget):
# Value # Value
v = karamba.getTextValue(widget, texts[5]) v = karamba.getTextValue(widget, texts[5])
print "getTextValue: ", v print("getTextValue: ", v)
v += '.' v += '.'
karamba.changeText(widget, texts[5], v) karamba.changeText(widget, texts[5], v)
# Shadow # Shadow
v = karamba.getTextShadow(widget, texts[6]) v = karamba.getTextShadow(widget, texts[6])
print "getTextShadow: ", v print("getTextShadow: ", v)
v = (v+1)%10; v = (v+1)%10;
karamba.changeTextShadow(widget, texts[6], v) karamba.changeTextShadow(widget, texts[6], v)
# Font size # Font size
v = karamba.getTextFontSize(widget, texts[7]) v = karamba.getTextFontSize(widget, texts[7])
print "getTextFontSize: ", v print("getTextFontSize: ", v)
v = 10 + ((v-10)+1)%10; v = 10 + ((v-10)+1)%10;
karamba.changeTextSize(widget, texts[7], v) karamba.changeTextSize(widget, texts[7], v)
# Text color # Text color
v = karamba.getTextColor(widget, texts[8]) v = karamba.getTextColor(widget, texts[8])
print "getTextColor: ", v print("getTextColor: ", v)
karamba.changeTextColor(widget, texts[8], b*255, b*255, b*255) karamba.changeTextColor(widget, texts[8], b*255, b*255, b*255)
# Text Font # Text Font
v = karamba.getTextFont(widget, texts[9]) v = karamba.getTextFont(widget, texts[9])
print "getTextFont: ", v print("getTextFont: ", v)
if(b): if(b):
v = 'Bitstream Vera Sans' v = 'Bitstream Vera Sans'
else: else:
@ -97,7 +97,7 @@ def widgetUpdated(widget):
# Text Alignment # Text Alignment
a = (a+1)%3 a = (a+1)%3
v = karamba.getTextAlign(widget, texts[10]) v = karamba.getTextAlign(widget, texts[10])
print "getTextAlign: ", v print("getTextAlign: ", v)
karamba.setTextAlign(widget, texts[10], align[a]) karamba.setTextAlign(widget, texts[10], align[a])
def widgetClicked(widget, x, y, button): def widgetClicked(widget, x, y, button):
@ -107,4 +107,4 @@ def widgetMouseMoved(widget, x, y, button):
pass pass
# This will be printed when the widget loads. # This will be printed when the widget loads.
print "Loaded Text test python extension!" print("Loaded Text test python extension!")

@ -9,7 +9,7 @@ import karamba
#this is called when you widget is initialized #this is called when you widget is initialized
def initWidget(widget): def initWidget(widget):
text=u""" text="""
<h1>UNICODE Example</h1> <h1>UNICODE Example</h1>
<h3>Greek:</h3> <h3>Greek:</h3>
\u03B1\u03B2\u03B3\u03B4\u03B5\u03B6\u03B7\u03B8\u03B9\u03BA\u03BB\u03BC\u03BD\u03BE\u03BF\u03C0 \u03B1\u03B2\u03B3\u03B4\u03B5\u03B6\u03B7\u03B8\u03B9\u03BA\u03BB\u03BC\u03BD\u03BE\u03BF\u03C0
@ -113,4 +113,4 @@ def widgetMouseMoved(widget, x, y, button):
pass pass
# This will be printed when the widget loads. # This will be printed when the widget loads.
print "Loaded Karamba Unicode Test" print("Loaded Karamba Unicode Test")

Loading…
Cancel
Save