summaryrefslogtreecommitdiffstats
path: root/superkaramba/examples/richtext
diff options
context:
space:
mode:
Diffstat (limited to 'superkaramba/examples/richtext')
-rw-r--r--superkaramba/examples/richtext/info.pngbin0 -> 641 bytes
-rw-r--r--superkaramba/examples/richtext/penguin_executive.pngbin0 -> 5159 bytes
-rw-r--r--superkaramba/examples/richtext/richtext.py136
-rw-r--r--superkaramba/examples/richtext/richtext.theme1
-rw-r--r--superkaramba/examples/richtext/rtext.py99
-rw-r--r--superkaramba/examples/richtext/rtext.theme26
6 files changed, 262 insertions, 0 deletions
diff --git a/superkaramba/examples/richtext/info.png b/superkaramba/examples/richtext/info.png
new file mode 100644
index 0000000..43b0297
--- /dev/null
+++ b/superkaramba/examples/richtext/info.png
Binary files differ
diff --git a/superkaramba/examples/richtext/penguin_executive.png b/superkaramba/examples/richtext/penguin_executive.png
new file mode 100644
index 0000000..6f855d3
--- /dev/null
+++ b/superkaramba/examples/richtext/penguin_executive.png
Binary files differ
diff --git a/superkaramba/examples/richtext/richtext.py b/superkaramba/examples/richtext/richtext.py
new file mode 100644
index 0000000..518aa65
--- /dev/null
+++ b/superkaramba/examples/richtext/richtext.py
@@ -0,0 +1,136 @@
+#Unicode Example
+
+#For Symbol Tables look at www.unicode.org/charts/
+
+hidden = 0
+
+penguin = 0
+penguin_hidden = 1
+
+#this import statement allows access to the karamba functions
+import karamba
+
+#this is called when you widget is initialized
+def initWidget(widget):
+ global richtext
+ global penguin
+
+ karamba.resizeWidget(widget, 360, 520)
+
+ penguin = karamba.createImage(widget, 250, 150, karamba.getThemePath(widget) + "/penguin_executive.png")
+ karamba.hideImage(widget, penguin)
+
+
+ text = """
+<h1>Richtext Example</h1>
+<p>A rich text object allows to display a string interpreted as rich text.
+To create a rich text object use the command:<br> <p align="center">karamba.createRichText(widget, text)</p>
+A simple subset of <a href="kfmclient openURL http://www.selfhtml.org"><font color="black"><i>HTML</i></font></a>-tags
+is used to encode the formatting commands.</p>
+<p><font size=+2>Some features:</font>
+<ul>
+<li>Numbered and unnumbered lists</li>
+<li>Inline Images <img src=\"""" + karamba.getThemePath(widget) + u"""info.png\"</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>Links can also <a href="#trigger">trigger</a> actions in the script</li>
+<li><i>Various</i> <b>different</b> <u>caracter</u> <s>styles</s></li>
+<li><a href="kfmclient openURL http://www.unicode.org">Unicode</a>: \u03B6 \u03B3 \u03BB \u03A3 \u03A9 </li>
+<li>Simple Tables:
+<table bgcolor="darkgray" border="1" width="80%">
+<tr><th colspan="3">Header</th></tr>
+<tr><td>Cell (1,1)</td><td>Cell (1,2)</td><td>Cell (1,3)</td><tr>
+<tr><td>Cell (2,1)</td><td>Cell (2,2)</td><td>Cell (2,3)</td><tr>
+</table></li>
+</ul>
+For a complete documentation of all supported tags look at:
+<a href="kfmclient openURL http://doc.trolltech.com/3.0/qstylesheet.html">
+http://doc.trolltech.com/3.0/qstylesheet.html</a>.
+</p><br>
+"""
+
+ richtext = karamba.createRichText(widget, text)
+
+ karamba.moveRichText(widget, richtext, 10, 10)
+
+ print "richText Size = ", karamba.getRichTextSize(widget, richtext)
+
+ karamba.setRichTextWidth(widget, richtext, 345)
+
+ #karamba.deleteRichText(widget, richtext)
+
+ karamba.redrawWidget(widget)
+
+
+
+
+#this is called everytime your widget is updated
+#the update inverval is specified in the .theme file
+def widgetUpdated(widget):
+ global hidden
+ global richtext
+
+ #if hidden == 0:
+ # hidden = 1
+ # karamba.hideRichText(widget, richtext)
+ #else:
+ # hidden = 0
+ # karamba.showRichText(widget, richtext)
+
+
+#This gets called everytime our widget is clicked.
+#Notes:
+# widget = reference to our widget
+# x = x position (relative to our widget)
+# y = y position (relative to our widget)
+# botton = button clicked:
+# 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.
+# 4,5 = Scroll wheel up and down
+def widgetClicked(widget, x, y, button):
+ global richtext
+ global hidden
+
+ #hidden = 0
+ #karamba.showRichText(widget, richtext)
+
+ #karamba.changeRichText(widget, richtext, "hihi\n huhu")
+
+def meterClicked(widget, meter, button):
+ global penguin
+ global penguin_hidden
+ global richtext
+
+ print "Meter clicked", meter
+ if meter == "trigger":
+ if penguin_hidden:
+ karamba.showImage(widget, penguin)
+ penguin_hidden = 0
+ else:
+ karamba.hideImage(widget, penguin)
+ penguin_hidden = 1
+ if meter == "delete":
+ karamba.deleteRichText(widget, richtext)
+
+ karamba.redrawWidget(widget)
+
+#This gets called everytime our widget is clicked.
+#Notes
+# widget = reference to our widget
+# 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):
+ pass
+
+# This will be printed when the widget loads.
+print "Loaded Karamba Unicode Test"
diff --git a/superkaramba/examples/richtext/richtext.theme b/superkaramba/examples/richtext/richtext.theme
new file mode 100644
index 0000000..1fae0ec
--- /dev/null
+++ b/superkaramba/examples/richtext/richtext.theme
@@ -0,0 +1 @@
+KARAMBA X=80 Y=20 W=400 H=500 LOCKED=true INTERVAL=2000
diff --git a/superkaramba/examples/richtext/rtext.py b/superkaramba/examples/richtext/rtext.py
new file mode 100644
index 0000000..68c800a
--- /dev/null
+++ b/superkaramba/examples/richtext/rtext.py
@@ -0,0 +1,99 @@
+#!/usr/bin/python
+# -*- coding: latin-1 -*-
+#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.getThemeRichText(widget, "text0")
+ texts[1] = karamba.getThemeRichText(widget, "text1")
+ texts[2] = karamba.getThemeRichText(widget, "text2")
+ texts[3] = karamba.getThemeRichText(widget, "text3")
+ texts[4] = karamba.getThemeRichText(widget, "text4")
+ texts[5] = karamba.getThemeRichText(widget, "text5")
+ texts[7] = karamba.getThemeRichText(widget, "text7")
+ texts[9] = karamba.getThemeRichText(widget, "text9")
+
+
+#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
+ text = "Unicode text: Ähtärissä on Öljyä"
+
+ # Create & delete
+ if(texts[0]):
+ karamba.deleteRichText(widget, texts[0])
+ texts[0] = 0
+ else:
+ texts[0] = karamba.createRichText(widget, text)
+ karamba.moveRichText(widget, texts[0], 0, 20)
+ karamba.resizeRichText(widget, texts[0], 200, 20)
+ pos = karamba.getRichTextPos(widget, texts[0])
+ print "--getRichTextPos: " + str(pos)
+ size = karamba.getRichTextSize(widget, texts[0])
+ print "--getRichTextSize: " + str(size)
+
+ # size & resize
+ size = karamba.getRichTextSize(widget, texts[1])
+ print "getRichTextSize: " + str(size)
+ size = ((b * 200) + 200, size[1])
+ karamba.resizeRichText(widget, texts[1], size[0], size[1])
+
+ # pos & move
+ pos = karamba.getRichTextPos(widget, texts[2])
+ print "getRichTextPos: " + str(pos)
+ pos = (b * 200, pos[1])
+ karamba.moveRichText(widget, texts[2], pos[0], pos[1])
+
+ # Hide & Show
+ if(b):
+ karamba.hideRichText(widget, texts[3])
+ else:
+ karamba.showRichText(widget, texts[3])
+
+ # Sensor
+ sensor = karamba.getRichTextSensor(widget, texts[4])
+ print "getSensor: " + str(sensor)
+ if(b):
+ karamba.setRichTextSensor(widget, texts[4], 'SENSOR=SENSOR TYPE="cpu_temp"')
+ else:
+ karamba.setRichTextSensor(widget, texts[4], 'SENSOR=CPU')
+
+ # Value
+ v = karamba.getRichTextValue(widget, texts[5])
+ print "getRichTextValue: ", v
+ v += '.'
+ karamba.changeRichText(widget, texts[5], v)
+
+ # Font size
+ v = karamba.getRichTextFontSize(widget, texts[7])
+ print "getRichTextFontSize: ", v
+ v = 10 + ((v-10)+1)%10;
+ karamba.changeRichTextSize(widget, texts[7], v)
+
+ # RichText Font
+ v = karamba.getRichTextFont(widget, texts[9])
+ print "getRichTextFont: ", v
+ if(b):
+ v = 'Bitstream Vera Sans'
+ else:
+ v = 'Bitstream Vera Serif'
+ karamba.changeRichTextFont(widget, texts[9], v)
+
+def widgetClicked(widget, x, y, button):
+ pass
+
+def widgetMouseMoved(widget, x, y, button):
+ pass
+
+# This will be printed when the widget loads.
+print "Loaded RichText test python extension!"
diff --git a/superkaramba/examples/richtext/rtext.theme b/superkaramba/examples/richtext/rtext.theme
new file mode 100644
index 0000000..487065d
--- /dev/null
+++ b/superkaramba/examples/richtext/rtext.theme
@@ -0,0 +1,26 @@
+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="createRichText & deleteRichText" name=ttext0
+RICHTEXT x=0 Y=20 w=200 h=20 value="RichText meter" min=0 max=100 name=text0
+
+TEXT x=0 Y=45 w=600 h=20 VALUE="getRichTextSize & resizeRichText" name=ttext1
+RICHTEXT x=0 Y=65 w=200 h=20 value="The quick brown <b>fox</b> jumps over the lazy <i>dog</i>" min=0 max=100 name=text1
+
+TEXT x=0 Y=90 w=600 h=20 VALUE="getRichTextPos & moveRichText" name=ttext2
+RICHTEXT x=0 Y=110 w=200 h=20 value="RichText meter" min=0 max=100 name=text2
+
+TEXT x=0 Y=135 w=600 h=20 VALUE="hideRichText & showRichText" name=ttext3
+RICHTEXT x=0 Y=155 w=200 h=20 value="RichText meter" min=0 max=100 name=text3
+
+TEXT x=0 Y=180 w=600 h=20 VALUE="getRichTextSensor & setRichTextSensor" name=ttext4
+RICHTEXT 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="getRichTextValue & setRichTextValue" name=ttext5
+RICHTEXT x=0 Y=245 w=200 h=20 value="." min=0 max=100 name=text5
+
+TEXT x=0 Y=315 w=600 h=20 VALUE="setRichTextSize & getRichTextSize" name=ttext7
+RICHTEXT x=0 Y=335 w=200 h=20 value="RichText meter" min=0 max=100 name=text7
+
+TEXT x=0 Y=405 w=600 h=20 VALUE="setRichTextFont & getRichTextFont" name=ttext9
+RICHTEXT x=0 Y=425 w=400 h=20 value="The quick brown fox jumps over the lazy dog" min=0 max=100 name=text9