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/input_example | |
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/input_example')
-rw-r--r-- | superkaramba/examples/input_example/input_example.py | 169 | ||||
-rw-r--r-- | superkaramba/examples/input_example/input_example.theme | 5 |
2 files changed, 174 insertions, 0 deletions
diff --git a/superkaramba/examples/input_example/input_example.py b/superkaramba/examples/input_example/input_example.py new file mode 100644 index 0000000..c0145c9 --- /dev/null +++ b/superkaramba/examples/input_example/input_example.py @@ -0,0 +1,169 @@ +#this import statement allows access to the karamba functions +import karamba +import os + +input = 0 +output = 0 +i = 0 + +#this is called when your widget is initialized +def initWidget(widget): + global input, output + #input = karamba.getThemeInputBox(widget, "input01") + input = karamba.createInputBox(widget,0,0,50,20,"foo") + output = karamba.getThemeText(widget, "output01") + karamba.changeTextColor(widget, output, 0, 0, 0) + karamba.changeTextSize(widget, output, 10) + karamba.redrawWidget(widget) + +#This is called when your widget is closed. You can use this to clean +#up open files, etc. You don't need to delete text and images in your +#theme. That is done automatically. This callback is just for cleaning up +#external things. Most people don't need to put anything here. +def widgetClosed(widget): + pass + +#this is called everytime your widget is updated +#the update inverval is specified in the .theme file +def widgetUpdated(widget): + pass + +#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): + pass + +#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): + #Warning: Don't do anything too intensive here + #You don't want to run some complex piece of code everytime the mouse moves + pass + + +#This gets called when an item is clicked in a popup menu you have created. +# menu = a reference to the menu +# id = the number of the item that was clicked. +def menuItemClicked(widget, menu, id): + pass + +#This gets called when an item is clicked in the theme CONFIGURATION menu, +#not the popup menus that you create. +# key = the reference to the configuration key that was changed +# value = the new value (true or false) that was selected +def menuOptionChanged(widget, key, value): + pass + +#This gets called when a meter (image, text, etc) is clicked. +# NOTE you must use attachClickArea() to make a meter +# clickable. +# widget = reference to your theme +# meter = the meter clicked +# button = the button clicked (see widgetClicked for button numbers) +def meterClicked(widget, meter, button): + pass + +#This gets called when a command you have executed with executeInteractive() outputs something +#to stdout. This way you can get the output of for example kdialog without freezing up the widget +#waiting for kdialog to end. +# widget = reference to your theme +# pid = process number of the program outputting (use this if you execute more than out process) +# output = the text the program outputted to stdout +def commandOutput(widget, pid, output): + pass + +#This gets called when an item is dropped on this widget. +# NOTE you have to call acceptDrops() before your widget will accept drops. +# widget = reference to your theme +# dropText = the text of the dropped item (probably a URL to it's location in KDE) +def itemDropped(widget, dropText): + pass + + +#This gets called when a new program is LOADING in KDE. When it is done +#loading, startupRemoved() is called, followed by taskAdded(). +# widget = reference to your widget +# task = A refence to the task that is starting. +def startupAdded(widget, startup): + pass + +#This gets called when a new program is done LOADING in KDE. +# widget = reference to your widget +# task = A refence to the task that just finished loading. +def startupRemoved(widget, startup): + pass + +#This is called every time a new task (program) is started in KDE. +# widget = reference to your widget +# task = A refence to the new task. Call getTaskInfo() with this reference +# to get the name, etc of this new task. +def taskAdded(widget, task): + pass + +#This is called everytime a task (program) is closed in KDE. +# widget = reference to your widget +# task = A refence to the task. +def taskRemoved(widget, task): + pass + +#This is called everytime a different task gains focus (IE, the user clicks +#on a different window). +# widget = reference to your widget +# task = A refence to the task. Call getTaskInfo() with this reference +# to get the name, etc of this new task. +def activeTaskChanged(widget, task): + pass + +#This is called everytime the systray you created with createSystray() is updated +def systrayUpdated(widget): + pass + +#This is called everytime the current desktop changes +# widget = reference to your widget +# desktop = the current desktop +def desktopChanged(widget, desktop): + pass + +#This is called everytime the wallpaper changes on a desktop +# widget = reference to your widget +# desktop = the desktop whose wallpaper changed +def wallpaperChanged(widget, desktop): + pass + +def keyPressed(widget, meter, char): + global input, output + if meter == input: + print "keyPressed: key= '", char, "'" + text = karamba.getInputBoxValue(widget, input) + karamba.changeText(widget, output, "Searched: " + text) + try: + if ord(char) == 13: # Enter + url = "konqueror leo:" + text + os.system(url + "&") + except TypeError: + print "There was a type error" + karamba.redrawWidget(widget) + + +# This will be printed when the widget loads. +print "Loaded my python extension!" diff --git a/superkaramba/examples/input_example/input_example.theme b/superkaramba/examples/input_example/input_example.theme new file mode 100644 index 0000000..2cb5ee3 --- /dev/null +++ b/superkaramba/examples/input_example/input_example.theme @@ -0,0 +1,5 @@ +KARAMBA x=0 y=0 w=100 h=50 INTERVAL=1000 LOCKED=true +DEFAULTFONT font="Bitstream Vera Sans" fontsize=16 color=200,200,200 + +#INPUT x=0 y=0 w=100 h=25 name=input01 +TEXT x=0 y=30 w=100 h=25 name=output01 |