KDE 4.7 PyKDE API Reference

- KDE's Python API

# AppletScript Class Reference

`from PyKDE4.plasma import *`

Inherits: Plasma.ScriptEngine → QObject
Namespace: Plasma

## Detailed Description

AppletScript plasma/scripting/appletscript.h <Plasma/Scripting/AppletScript>

Provides a restricted interface for scripted applets.

## Signals

| popupEvent (bool popped)
| saveState (KConfigGroup group)

## Methods

| __init__ (self, QObject parent=0)
| addStandardConfigurationPages (self, KConfigDialog dialog)
Plasma.Applet | applet (self)
| configChanged (self)
| configNeedsSaving (self)
| constraintsEvent (self, Plasma.Constraints constraints)
Plasma.Containment.Type | containmentType (self)
[QAction] | contextualActions (self)
Plasma.DataEngine | dataEngine (self, QString engine)
KPluginInfo | description (self)
bool | drawWallpaper (self)
Plasma.Extender | extender (self)
bool | isRegisteredAsDragHandle (self, QGraphicsItem item)
Plasma.Animation | loadAnimationFromPackage (self, QString name, QObject parent)
QString | mainScript (self)
Plasma.Package | package (self)
| paintInterface (self, QPainter painter, QStyleOptionGraphicsItem option, QRect contentsRect)
| registerAsDragHandle (self, QGraphicsItem item)
| setApplet (self, Plasma.Applet applet)
| setConfigurationRequired (self, bool req, QString reason=QString())
| setContainmentType (self, Plasma.Containment.Type type)
| setDrawWallpaper (self, bool drawWallpaper)
| setFailedToLaunch (self, bool failed, QString reason=QString())
| setHasConfigurationInterface (self, bool hasInterface)
QPainterPath | shape (self)
| showConfigurationInterface (self)
| showMessage (self, QIcon icon, QString message, Plasma.MessageButtons buttons)
QSizeF | size (self)
KConfigDialog | standardConfigurationDialog (self)
| unregisterAsDragHandle (self, QGraphicsItem item)

## Signal Documentation

popupEvent | ( | bool | popped
| ) |  |  |

See also:
  PopupApplet

Signal syntax:
  `QObject.connect(source, SIGNAL("popupEvent(bool)"), target_slot)`

saveState | ( | KConfigGroup | group
| ) |  |  |

See also:
  Applet

Signal syntax:
  `QObject.connect(source, SIGNAL("saveState(KConfigGroup&)"), target_slot)`

## Method Documentation

__init__ | ( | self, |
|  | QObject | parent=0
| ) |  |  |

Default constructor for an AppletScript.

Subclasses should not attempt to access the Plasma.Applet associated with this AppletScript in the constructor. All such set up that requires the Applet itself should be done in the init() method.

addStandardConfigurationPages | ( | self, |
|  | KConfigDialog | dialog
| ) |  |  |

This method should be called after a scripting applet has added its own pages to a configuration dialog

Since:
  4.3.1

Plasma.Applet applet | ( |  | self ) |

Returns the Plasma.Applet associated with this script component

configChanged | ( |  | self ) |

Configure was changed.

configNeedsSaving | ( |  | self ) |

See also:
  Applet

constraintsEvent | ( | self, |
|  | Plasma.Constraints | constraints
| ) |  |  |

Called when any of the geometry constraints have been updated.

This is always called prior to painting and should be used as an opportunity to layout the widget, calculate sizings, etc.

Do not call update() from this method; an update() will be triggered at the appropriate time for the applet.

Parameters:

  | constraints | the type of constraints that were updated

Plasma.Containment.Type containmentType | ( |  | self ) |

See also:
  Containment

Since:
  4.7

[QAction] contextualActions | ( |  | self ) |

Returns a list of context-related QAction instances.

Returns:
  A list of actions. The default implementation returns an empty list.

Plasma.DataEngine dataEngine | ( | self, |
|  | QString | engine
| ) |  |  |

Parameters:

  | engine | name of the engine

Returns:
  a data engine associated with this plasmoid

KPluginInfo description | ( |  | self ) |

Returns:
  the KPluginInfo associated with this plasmoid

bool drawWallpaper | ( |  | self ) |

Returns:
  true if the applet is a containment AND if the wallpaper is enabled

See also:
  Containment

Since:
  4.7

Plasma.Extender extender | ( |  | self ) |

See also:
  Applet

bool isRegisteredAsDragHandle | ( | self, |
|  | QGraphicsItem | item
| ) |  |  |

See also:
  Applet

Plasma.Animation loadAnimationFromPackage | ( | self, |
|  | QString | name,
|  | QObject | parent
| ) |  |  |

Loads an animation from the applet package

Parameters:

  | animation | the animation to load

Returns:
  an Animation object on success, a NULL pointer on failure

Since:
  4.5

QString mainScript | ( |  | self ) |

Returns:
  absolute path to the main script file for this plasmoid

Plasma.Package package | ( |  | self ) |

Returns:
  the Package associated with this plasmoid which can be used to request resources, such as images and interface files.

paintInterface | ( | self, |
|  | QPainter | painter,
|  | QStyleOptionGraphicsItem | option,
|  | QRect | contentsRect
| ) |  |  |

Called when the script should paint the applet

Parameters:

  | painter | the QPainter to use
  | option | the style option containing such flags as selection, level of detail, etc
  | contentsRect | the rect to paint within; automatically adjusted for the background, if any

registerAsDragHandle | ( | self, |
|  | QGraphicsItem | item
| ) |  |  |

See also:
  Applet

setApplet | ( | self, |
|  | Plasma.Applet | applet
| ) |  |  |

Sets the applet associated with this AppletScript

setConfigurationRequired | ( | self, |
|  | bool | req,
|  | QString | reason=QString()
| ) |  |  |

See also:
  Applet

setContainmentType | ( | self, |
|  | Plasma.Containment.Type | type
| ) |  |  |

See also:
  Containment

Since:
  4.7

setDrawWallpaper | ( | self, |
|  | bool | drawWallpaper
| ) |  |  |

set if the containment draws its own wallpaper: it has no effect if the applet is not a containment

See also:
  Containment

Since:
  4.7

setFailedToLaunch | ( | self, |
|  | bool | failed,
|  | QString | reason=QString()
| ) |  |  |

See also:
  Applet

setHasConfigurationInterface | ( | self, |
|  | bool | hasInterface
| ) |  |  |

Sets whether or not this script has a configuration interface or not

Parameters:

  | hasInterface | true if the applet is user configurable

QPainterPath shape | ( |  | self ) |

Returns the shape of the widget, defaults to the bounding rect

showConfigurationInterface | ( |  | self ) |

Show a configuration dialog.

showMessage | ( | self, |
|  | QIcon | icon,
|  | QString | message,
|  | Plasma.MessageButtons | buttons
| ) |  |  |

See also:
  Applet

QSizeF size | ( |  | self ) |

Returns the area within which contents can be painted.

KConfigDialog standardConfigurationDialog | ( |  | self ) |

Returns:
  a standard Plasma applet configuration dialog, ready to have pages added to it.

Note that the dialog returned is set to delete on close.

unregisterAsDragHandle | ( | self, |
|  | QGraphicsItem | item
| ) |  |  |

See also:
  Applet