diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | 2bda8f7717adf28da4af0d34fb82f63d2868c31d (patch) | |
tree | 8d927b7b47a90c4adb646482a52613f58acd6f8c /superkaramba/examples/text | |
download | tdeutils-2bda8f7717adf28da4af0d34fb82f63d2868c31d.tar.gz tdeutils-2bda8f7717adf28da4af0d34fb82f63d2868c31d.zip |
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdeutils@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'superkaramba/examples/text')
-rw-r--r-- | superkaramba/examples/text/text.py | 110 | ||||
-rw-r--r-- | superkaramba/examples/text/text.theme | 35 |
2 files changed, 145 insertions, 0 deletions
diff --git a/superkaramba/examples/text/text.py b/superkaramba/examples/text/text.py new file mode 100644 index 0000000..4612dd5 --- /dev/null +++ b/superkaramba/examples/text/text.py @@ -0,0 +1,110 @@ +#this import statement allows access to the karamba functions +import karamba + +align = ['LEFT', 'CENTER', 'RIGHT'] +texts = [0,0,0,0,0,0,0,0,0,0,0] +b = 0 +a = 0 + +#this is called when you widget is initialized +def initWidget(widget): + global texts, b + texts[0] = karamba.getThemeText(widget, "text0") + texts[1] = karamba.getThemeText(widget, "text1") + texts[2] = karamba.getThemeText(widget, "text2") + texts[3] = karamba.getThemeText(widget, "text3") + texts[4] = karamba.getThemeText(widget, "text4") + texts[5] = karamba.getThemeText(widget, "text5") + texts[6] = karamba.getThemeText(widget, "text6") + texts[7] = karamba.getThemeText(widget, "text7") + texts[8] = karamba.getThemeText(widget, "text8") + texts[9] = karamba.getThemeText(widget, "text9") + texts[10] = karamba.getThemeText(widget, "text10") + + +#this is called everytime your widget is updated +#the update inverval is specified in the .theme file +def widgetUpdated(widget): + global texts, b, a + + b = (b+1)%2 + + # Create & delete + if(texts[0]): + karamba.deleteText(widget, texts[0]) + texts[0] = 0 + else: + texts[0] = karamba.createText(widget, 0, 20, 200, 20, "Text meter") + + # size & resize + size = karamba.getTextSize(widget, texts[1]) + print "getTextSize: " + str(size) + size = ((b * 200) + 200, size[1]) + karamba.resizeText(widget, texts[1], size[0], size[1]) + + # pos & move + pos = karamba.getTextPos(widget, texts[2]) + print "getTextPos: " + str(pos) + pos = (b * 200, pos[1]) + karamba.moveText(widget, texts[2], pos[0], pos[1]) + + # Hide & Show + if(b): + karamba.hideText(widget, texts[3]) + else: + karamba.showText(widget, texts[3]) + + # Sensor + sensor = karamba.getTextSensor(widget, texts[4]) + print "getSensor: " + str(sensor) + if(b): + karamba.setTextSensor(widget, texts[4], 'SENSOR=SENSOR TYPE="cpu_temp"') + else: + karamba.setTextSensor(widget, texts[4], 'SENSOR=CPU') + + # Value + v = karamba.getTextValue(widget, texts[5]) + print "getTextValue: ", v + v += '.' + karamba.changeText(widget, texts[5], v) + + # Shadow + v = karamba.getTextShadow(widget, texts[6]) + print "getTextShadow: ", v + v = (v+1)%10; + karamba.changeTextShadow(widget, texts[6], v) + + # Font size + v = karamba.getTextFontSize(widget, texts[7]) + print "getTextFontSize: ", v + v = 10 + ((v-10)+1)%10; + karamba.changeTextSize(widget, texts[7], v) + + # Text color + v = karamba.getTextColor(widget, texts[8]) + print "getTextColor: ", v + karamba.changeTextColor(widget, texts[8], b*255, b*255, b*255) + + # Text Font + v = karamba.getTextFont(widget, texts[9]) + print "getTextFont: ", v + if(b): + v = 'Bitstream Vera Sans' + else: + v = 'Bitstream Vera Serif' + karamba.changeTextFont(widget, texts[9], v) + + # Text Alignment + a = (a+1)%3 + v = karamba.getTextAlign(widget, texts[10]) + print "getTextAlign: ", v + karamba.setTextAlign(widget, texts[10], align[a]) + +def widgetClicked(widget, x, y, button): + pass + +def widgetMouseMoved(widget, x, y, button): + pass + +# This will be printed when the widget loads. +print "Loaded Text test python extension!" diff --git a/superkaramba/examples/text/text.theme b/superkaramba/examples/text/text.theme new file mode 100644 index 0000000..522640a --- /dev/null +++ b/superkaramba/examples/text/text.theme @@ -0,0 +1,35 @@ +KARAMBA x=100 y=10 w=600 h=580 INTERVAL=1000 LOCKED=true +DEFAULTFONT font="Bitstream Vera Sans" fontsize=16 color=200,200,200 + +TEXT x=0 Y=0 w=600 h=20 VALUE="createText & deleteText" name=ttext0 +TEXT x=0 Y=20 w=200 h=20 value="Text meter" min=0 max=100 name=text0 + +TEXT x=0 Y=45 w=600 h=20 VALUE="getTextSize & resizeText" name=ttext1 +TEXT x=0 Y=65 w=200 h=20 value="The quick brown fox jumps over the lazy dog" min=0 max=100 name=text1 + +TEXT x=0 Y=90 w=600 h=20 VALUE="getTextPos & moveText" name=ttext2 +TEXT x=0 Y=110 w=200 h=20 value="Text meter" min=0 max=100 name=text2 + +TEXT x=0 Y=135 w=600 h=20 VALUE="hideText & showText" name=ttext3 +TEXT x=0 Y=155 w=200 h=20 value="Text meter" min=0 max=100 name=text3 + +TEXT x=0 Y=180 w=600 h=20 VALUE="getTextSensor & setTextSensor" name=ttext4 +TEXT x=0 Y=200 w=200 h=20 value=50 min=0 max=100 name=text4 + +TEXT x=0 Y=225 w=600 h=20 VALUE="getTextValue & setTextValue" name=ttext5 +TEXT x=0 Y=245 w=200 h=20 value="." min=0 max=100 name=text5 + +TEXT x=0 Y=270 w=600 h=20 VALUE="getTextShadow & setTextShadow" name=ttext6 +TEXT x=0 Y=290 w=400 h=20 value="The quick brown fox jumps over the lazy dog" min=0 max=100 name=text6 + +TEXT x=0 Y=315 w=600 h=20 VALUE="setTextSize & getTextSize" name=ttext7 +TEXT x=0 Y=335 w=200 h=20 value="Text meter" min=0 max=100 name=text7 + +TEXT x=0 Y=360 w=600 h=20 VALUE="setTextColor & getTextColor" name=ttext8 +TEXT x=0 Y=380 w=400 h=20 value="The quick brown fox jumps over the lazy dog" min=0 max=100 name=text8 + +TEXT x=0 Y=405 w=600 h=20 VALUE="setTextFont & getTextFont" name=ttext9 +TEXT x=0 Y=425 w=400 h=20 value="The quick brown fox jumps over the lazy dog" min=0 max=100 name=text9 + +TEXT x=0 Y=450 w=600 h=20 VALUE="setTextAlign & getTextAlign" name=ttext10 +TEXT x=0 Y=470 w=400 h=20 value="Text meter" min=0 max=100 name=text10 |