KDE 4.2 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.

## Methods

| __init__ (self, QObject parent=0)
Plasma.Applet | applet (self)
| configChanged (self)
| configNeedsSaving (self)
| constraintsEvent (self, Plasma.Constraints constraints)
[QActio] | contextualActions (self)
Plasma.DataEngine | dataEngine (self, QString engine)
QString | mainScript (self)
Plasma.Package | package (self)
| paintInterface (self, QPainter painter, QStyleOptionGraphicsItem option, QRect contentsRect)
| setApplet (self, Plasma.Applet applet)
| setConfigurationRequired (self, bool req, QString reason=QString())
| setFailedToLaunch (self, bool failed, QString reason=QString())
| setHasConfigurationInterface (self, bool hasInterface)
QPainterPath | shape (self)
| showConfigurationInterface (self)
QSizeF | size (self)

## 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.

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

[QActio] 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
| ) |  |  |

@arg engine name of the engine

Returns:
  a data engine associated with this plasmoid

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

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

Sets the applet associated with this AppletScript

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

See also:
  Applet

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

@arg 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.

QSizeF size | ( |  | self ) |

Returns the area within which contents can be painted.