SuperKaramba 0.26 API

The latest API definition is always here.

All of the functions here are defined in the module karamba. To use them:

import karamba

All Functions

Groups of functions:

Context Functions
Widget functions getWidgetPosition(), createWidgetMask(), createWidgetMask(), redrawWidget(), resizeWidget(), moveWidget(),
Text functions getThemeText(), showText(), hideText(), moveText(), changeTextShadow(), changeTextSize(), changeTextColor(), changeTextFont(), changeText(), deleteText(), createText(),
Image functions getThemeImage(), removeImageEffects(), changeImageIntensity(), changeImageChannelIntensity(), changeImageToGray(), removeImageTransformations(), rotateImage(), getImageHeight(), getImageWidth(), resizeImageSmooth(), resizeImage(), showImage(), hideImage(), moveImage(), addImageTooltip(), deleteImage(), createImage(),
Task functions performTaskAction(), getTaskInfo(), getTaskNames(), getTaskList(),
Configuration functions addMenuConfigOption(), setMenuConfigOption(), readMenuConfigOption(), writeConfigEntry(), readConfigEntry(),
Popup Menu functions createMenu(), deleteMenu(), addMenuItem(), removeMenuItem(), popupMenu(),
Misc functions toggleShowDesktop(), getThemePath(), createClickArea(),

Function Documentation

createMenu(widget)

This creates an empty popup menu and returns a pointer to the menu.

deleteMenu(widget, menu)

This deletes the referenced menu if that menu exists. It returns 1 if menu existed and was deleted, returns 0 otherwise.

addMenuItem(widget, menu, text, icon)

This adds an entry to the given menu with label text and with given icon. icon can be just an application name in which case the user's current icon set is used, or can be a path to a 16x16 png file.

The function returns the id of the menu item, which identifies that popup menu item uniquely among popupmenu items application-wide or returns 0 if the given menu doesn't exist.

removeMenuItem(widget, menu, id)

This removes the item with given id from given menu if that menu exists.

The function returns 1 if the menu item existed and was removed or returns zero otherwise.

popupMenu(widget, menu, x, y)

This pops up the given menu at the given co-ordinates. The co-ordinates are relative to the widget, not the screen. You can use negative co-ordinates to make a menu appear to the right of or above your theme.

This function returns 1 if the menu existed and was popped up, returns 0 otherwise

getThemeText(widget, name)

You can reference text in your python code that was created in the .theme file. Basically, you just add a NAME= value to the TEXT line in the .theme file. Then if you want to use that object, instead of calling createText, you can call this function.

The name you pass to the function is the same one that you gave it for the NAME= parameter in the .theme file.

getThemeImage(widget, name)

You can reference an image in your python code that was created in the .theme file. Basically, you just add a NAME= value to the IMAGE line in the .theme file. Then if you want to use that object, instead of calling createImage, you can call this function.

The name you pass to the function is the same one that you gave it for the NAME= parameter in the .theme file.

addMenuConfigOption(widget, k, n)

SuperKaramba supports a simplistic configuration pop-up menu. This menu appears when you right-click on a widget and choose Configure Theme. Basically, it allows you to have check-able entrys in the menu to allow the user to enable or disable features in your theme.

Before you use any configuration menu stuff, you NEED to add a new callback to your script:

def menuOptionChanged(widget, key, value):

This will get called whenever a config menu option is changed. Now you can add items to the config menu:

addMenuConfigOption(widget, String key, String name)

Key is the name of a key value where the value will be saved automatically into the widget's config file. Name is the actual text that will show up in the config menu.

For example, I could allow the user to enable or disable a clock showing up in my theme:

karamba.addMenuConfigOption(widget, "showclock", "Display a clock")

setMenuConfigOption(widget, k, value)

This sets whether or not the given option is checked in the theme's Configure Theme menu. Value should be 0 if key should not be checked and 1 if key should be checked.

See addMenuConfigOption for a more detailed explanation.

readMenuConfigOption(widget, k)

This returns whether or not the given option is checked in the theme's Configure Theme menu. 0 is returned if it is not checked and 1 is returned if it is.

See addMenuConfigOption for a more detailed explanation.

writeConfigEntry(widget, k, value)

SuperKaramba automatically supports configuration files for each theme. These files will be saved in /your/home/dir/.superkaramba/ and will be named themenamerc where themename is the name of the theme.

This function writes an entry into the config file with the given key and value.

For example, to save my favorite color, I would do karamba.writeConfigEntry(widget, "FavColor", "Red")

readConfigEntry(widget, k)

SuperKaramba automatically supports configuration files for each theme. These files will be saved in /your/home/dir/.superkaramba/ and will be named themenamerc where themename is the name of the theme.

This function reads back any value saved for a certain key.

To read back my favorite color, I could do favcolor = karamba.readConfigEntry(widget, "FavColor?")

toggleShowDesktop(widget)

This shows/hides the current desktop just like the Show Desktop button on kicker. Basically, it minimizes all the windows on the current desktop. Call it once to show the desktop and again to hide it.

performTaskAction(widget, task, action)

This peforms the given action on a task object. widget is a reference to the current widget. task is a reference to a task object you got from getTaskList(). Action is a number from 1 to 10. See the list below.

Possible actions:

getTaskInfo(widget, task)

This returns all of the info about a certain task in the form of a Python List. widget is a reference to the current widget. task is a reference to the window you want info about which you obtain by calling getTaskList().

Here is the format of the returned list by index value:

getTaskNames(widget)

This returns a Python List containing the String names of all open windows on the system. This is for convience if you want to list open windows or see if a window by a certain name exists. Anything else requires the reference to the window you would obtain from getTaskList()

getTaskList(widget)

This returns a Python List object with references to all the current windows open on this system. You can then call performTaskAction() or getTaskInfo() on any of the entries in the list.

getWidgetPosition(widget)

Returns a Python Tuple containing the x and y position of you widget. widget is a reference to the current widget.

getThemePath(widget)

Returns a string containing the directory where your theme was loaded from.

createWidgetMask(widget, text)

This function doesn't work currently due to a bug in KDE. Please use MASK= in your .theme file for the time being.

createWidgetMask(widget, text)

This function doesn't work currently due to a bug in KDE. Please use MASK= in your .theme file for the time being.

createClickArea(widget, x, y, w, h, text)

This creates a clickable area at x,y with width and height w,h. When this area is clicked, cmd_to_run will be executed. The mouse will change to the clickable icon when over this area.

removeImageEffects(widget, image)

If you have called image effect commands on your image (ex: changeImageIntensity), you can call this to restore your image to it's original form.

changeImageIntensity(widget, image, ratio, millisec)

Changes the "intensity" of the image, which is similar to it's brightness. ratio is a floating point number from -1.0 to 1.0 that determines how much to brighten or darken the image. Millisec specifies how long in milliseconds before the image is restored to it's original form. This is useful for "mouse over" type animations. Using 0 for millisec disables this feature and leaves the image permanently affected.

changeImageChannelIntensity(widget, image, ratio, channel, millisec)

There is no infomation for this function yet.

changeImageToGray(widget, image, millisec)

Turns the given image into a grayscale image. Millisec specifies how long in milliseconds before the image is restored to it's original form. This is useful for "mouse over" type animations. Using 0 for millisec disables this feature and leaves the image permanently affected.

removeImageTransformations(widget, image)

If you have rotated or resized your image, you can call this to restore your image to it's original form.

rotateImage(widget, image, deg)

This rotates your image to by the specified amount of degrees. The imageToRotate parameter is a reference to an image that you saved as the return value from createImage()

getImageHeight(widget, image)

This returns the height of an image. This is useful if you have rotated an image and its size changed, so you do not know how big it is anymore. The return value is a long.

getImageWidth(widget, image)

This returns the width of an image. This is useful if you have rotated an image and its size changed, so you do not know how big it is anymore. The return value is a long.

resizeImageSmooth(widget, image, w, h)

DEPRECATED: resizeImage now allows the user to pick whether to use fast or smooth resizing from the SuperKaramba menu - This resizes your image to width, height. The imageToResize parameter is a reference to an image that you saved as the return value from createImage()

resizeImage(widget, image, w, h)

This resizes your image to width, height. The imageToResize parameter is a reference to an image that you saved as the return value from createImage()

showImage(widget, image)

This shows a previously hidden image. It does not actually refresh the image on screen. That is what redrawWidget() does.

hideImage(widget, image)

This hides an image. In other words, during subsequent calls to widgetUpdate(), this image will not be drawn.

moveImage(widget, image, x, y)

This moves an image to a new x, y relative to your widget. In other words, (0,0) is the top corner of your widget, not the screen. The imageToMove parameter is a reference to the image to move that you saved as the return value from createImage()

addImageTooltip(widget, image, text)

This creats a tooltip for image with tooltip_text.

NOTE

deleteImage(widget, image)

This removes image from memory. Please do not call functions on "image" after calling deleteImage, as it does not exist anymore and that could cause crashes in some cases.

createImage(widget, x, y, text)

This creates an image on your widget at x, y. The filename should be given as the path parameter. In theory the image could be local or could be a url. It works just like adding an image in your theme file. You will need to save the return value to be able to call other functions on your image, such as moveImage()

showText(widget, text)

Shows text that has been hidden with hideText()

hideText(widget, text)

Hides text that is visible. You need to call redrawWidget() afterwords to actually hide the text on screen.

moveText(widget, text, x, y)

This moves a text object to a new x, y relative to your widget. In other words, (0,0) is the top corner of your widget, not the screen.

changeTextShadow(widget, textSensor, shadow)

This will change the shadow size of a text widget (only ones you created through python currently). textToChange is the reference to the text object to change that you saved from the createText() call. size is the offset of the shadow in pixels. 1 or 2 is a good value in most cases.

changeTextSize(widget, textSensor, size)

This will change the font size of a text widget (only ones you created through python currently). textToChange is the reference to the text object to change that you saved from the createText() call. size is the new font point size.

changeTextColor(widget, textSensor, r, g, b)

This will change the color of a text widget (only ones you created through python currently). textToChange is the reference to the text object to change that you saved from the createText() call. r, g, b are ints from 0 to 255 that represent red, green, and blue.

changeTextFont(widget, textSensor, text)

This will change the font of a text widget (only ones you created through python currently). textToChange is the reference to the text object to change that you saved from the createText() call. newFont is a string the the name of the font to use.

changeText(widget, textSensor, text)

This will change the contents of a text widget (only ones you created through python currently). textToChange is the reference to the text object to change that you saved from the createText() call.

deleteText(widget, text)

This removes a text object from memory. Please do not call functions on "text" after calling deleteText, as it does not exist anymore and that could cause crashes in some cases.

createText(widget, x, y, w, h, text)

This creates creates a text string at x, y with the specified width and height. You need to save the return value of this function to call other functions on your text field, such as changeText()

redrawWidget(widget)

This is THE most important function. After you do a bunch of other calls (moving images, adding images or text, etc), you call this to update the widget display area. You will not see your changes until you call this.

resizeWidget(widget, x, y)

Resizes your karamba widget to width=w, height=h

moveWidget(widget, x, y)

Moves your karamba widget to a new screen location