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/graph | |
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/graph')
-rw-r--r-- | superkaramba/examples/graph/graph.py | 89 | ||||
-rw-r--r-- | superkaramba/examples/graph/graph.theme | 26 |
2 files changed, 115 insertions, 0 deletions
diff --git a/superkaramba/examples/graph/graph.py b/superkaramba/examples/graph/graph.py new file mode 100644 index 0000000..5798612 --- /dev/null +++ b/superkaramba/examples/graph/graph.py @@ -0,0 +1,89 @@ +#this import statement allows access to the karamba functions +import karamba + +graphs = [0,0,0,0,0,0,0,0] +b = 0 + +#this is called when you widget is initialized +def initWidget(widget): + global graphs + graphs[0] = karamba.getThemeGraph(widget, "graph0") + graphs[1] = karamba.getThemeGraph(widget, "graph1") + graphs[2] = karamba.getThemeGraph(widget, "graph2") + graphs[3] = karamba.getThemeGraph(widget, "graph3") + graphs[4] = karamba.getThemeGraph(widget, "graph4") + graphs[5] = karamba.getThemeGraph(widget, "graph5") + graphs[6] = karamba.getThemeGraph(widget, "graph6") + graphs[7] = karamba.getThemeGraph(widget, "graph7") + + +#this is called everytime your widget is updated +#the update inverval is specified in the .theme file +def widgetUpdated(widget): + global graphs, b + + b = (b+1)%2 + + # Create & delete + if(graphs[0]): + karamba.deleteGraph(widget, graphs[0]) + graphs[0] = 0 + print "Deleted graph." + else: + graphs[0] = karamba.createGraph(widget, 0, 20, 400, 30, 400) + print "Created graph: " + str(graphs[0]) + + # size & resize + size = karamba.getGraphSize(widget, graphs[1]) + print "getGraphSize: " + str(size) + size = ((b * 200) + 200, size[1]) + karamba.resizeGraph(widget, graphs[1], size[0], size[1]) + + # pos & move + pos = karamba.getGraphPos(widget, graphs[2]) + print "getGraphPos: " + str(pos) + pos = (b * 200, pos[1]) + karamba.moveGraph(widget, graphs[2], pos[0], pos[1]) + + # Hide & Show + if(b): + karamba.hideGraph(widget, graphs[3]) + else: + karamba.showGraph(widget, graphs[3]) + + # Sensor + sensor = karamba.getGraphSensor(widget, graphs[4]) + print "getSensor: " + str(sensor) + if(b): + karamba.setGraphSensor(widget, graphs[4], 'SENSOR=NETWORK FORMAT="%in"') + else: + karamba.setGraphSensor(widget, graphs[4], 'SENSOR=CPU') + + # Min Max + minmax = karamba.getGraphMinMax(widget, graphs[5]) + print "getGraphMinMax: " + str(minmax) + minmax = (0, (b * 25) + 25) + karamba.setGraphMinMax(widget, graphs[5], minmax[0], minmax[1]) + + # Value + v = karamba.getGraphValue(widget, graphs[6]) + print "getGraphValue: ", v + v = (v + 1) % 30 + karamba.setGraphValue(widget, graphs[6], v) + + # Color + c = karamba.getGraphColor(widget, graphs[7]) + print "getGraphColor: ", c + r = (c[0] + 10) % 255 + g = (c[1] + 10) % 255 + bl = (c[2] + 10) % 255 + karamba.setGraphColor(widget, graphs[7], r, g, bl) + +def widgetClicked(widget, x, y, button): + pass + +def widgetMouseMoved(widget, x, y, button): + pass + +# This will be printed when the widget loads. +print "Loaded Graph test python extension!" diff --git a/superkaramba/examples/graph/graph.theme b/superkaramba/examples/graph/graph.theme new file mode 100644 index 0000000..d16c8b3 --- /dev/null +++ b/superkaramba/examples/graph/graph.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="createGraph & deleteGraph" name=text0 +GRAPH X=0 Y=20 W=400 H=30 POINTS=400 SENSOR=NETWORK FORMAT="%in" COLOR=192,192,192 MAX=50 NAME=graph0 + +TEXT x=0 Y=50 w=600 h=20 VALUE="getGraphSize & resizeGraph" name=text1 +GRAPH X=0 Y=70 W=400 H=30 POINTS=200 SENSOR=NETWORK FORMAT="%in" COLOR=192,192,192 MAX=50 NAME=graph1 + +TEXT x=0 Y=100 w=600 h=20 VALUE="getGraphPos & moveGraph" name=text2 +GRAPH X=0 Y=120 W=200 H=30 POINTS=200 SENSOR=NETWORK FORMAT="%in" COLOR=192,192,192 MAX=50 NAME=graph2 + +TEXT x=0 Y=150 w=600 h=20 VALUE="hideGraph & showGraph" name=text3 +GRAPH X=0 Y=170 W=200 H=30 POINTS=200 SENSOR=NETWORK FORMAT="%in" COLOR=192,192,192 MAX=50 NAME=graph3 + +TEXT x=0 Y=200 w=600 h=20 VALUE="getGraphSensor & setGraphSensor" name=text4 +GRAPH X=0 Y=220 W=200 H=30 POINTS=200 SENSOR=NETWORK FORMAT="%in" COLOR=192,192,192 MAX=50 NAME=graph4 + +TEXT x=0 Y=250 w=600 h=20 VALUE="getGraphMinMax & setGraphMinMax" name=text5 +GRAPH X=0 Y=270 W=200 H=30 POINTS=200 SENSOR=NETWORK FORMAT="%in" COLOR=192,192,192 MAX=50 NAME=graph5 + +TEXT x=0 Y=300 w=600 h=20 VALUE="getGraphValue & setGraphValue" name=text6 +GRAPH X=0 Y=320 W=200 H=30 POINTS=200 COLOR=192,192,192 NAME=graph6 MAX=30 + +TEXT x=0 Y=350 w=600 h=20 VALUE="getGraphColor & setGraphColor" name=text7 +GRAPH X=0 Y=370 W=200 H=30 POINTS=200 SENSOR=NETWORK FORMAT="%in" COLOR=192,192,192 MAX=50 NAME=graph7 |