Plasma.IconWidget

KDE 4.2 PyKDE API Reference

- KDE's Python API

# IconWidget Class Reference

`from PyKDE4.plasma import *`

Inherits: QGraphicsWidget → QObject
Namespace: Plasma

## Detailed Description

## Signals
| activated ()
| changed ()
| clicked ()
| doubleClicked ()
| pressed (bool down)
## Methods
| __init__ (self, QGraphicsItem parent=0)
| __init__ (self, QString text, QGraphicsItem parent=0)
| __init__ (self, QIcon icon, QString text, QGraphicsItem parent=0)
QAction | action (self)
| activated (self)
| addIconAction (self, QAction action)
| changed (self)
| clicked (self)
| doubleClicked (self)
| drawActionButtonBase (self, QPainter painter, QSize size, int element)
bool | drawBackground (self)
| hoverEnterEvent (self, QGraphicsSceneHoverEvent event)
| hoverLeaveEvent (self, QGraphicsSceneHoverEvent event)
QIcon | icon (self)
QSizeF | iconSize (self)
QString | infoText (self)
| invertLayout (self, bool invert)
bool | invertedLayout (self)
bool | isDown (self)
| mouseDoubleClickEvent (self, QGraphicsSceneMouseEvent event)
| mouseMoveEvent (self, QGraphicsSceneMouseEvent event)
| mousePressEvent (self, QGraphicsSceneMouseEvent event)
| mouseReleaseEvent (self, QGraphicsSceneMouseEvent event)
int | numDisplayLines (self)
| paint (self, QPainter painter, QStyleOptionGraphicsItem option, QWidget widget=0)
| pressed (self, bool down)
| setAction (self, QAction action)
| setDrawBackground (self, bool draw)
| setIcon (self, QIcon icon)
| setIcon (self, QString icon)
| setInfoText (self, QString text)
| setNumDisplayLines (self, int numLines)
| setOrientation (self, Qt.Orientation orientation)
| setPressed (self, bool pressed=1)
| setSvg (self, QString svgFilePath, QString svgIconElement=QString())
| setText (self, QString text)
| setUnpressed (self)
QPainterPath | shape (self)
QSizeF | sizeFromIconSize (self, float iconWidth)
QString | text (self)

## Method Documentation

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

Creates a new Plasma.IconWidget.

Parameters:

  | parent | the QGraphicsItem this icon is parented to.

__init__ | ( | self, |
|  | QString | text,
|  | QGraphicsItem | parent=0
| ) |  |  |

Convenience constructor to create a Plasma.IconWidget with text.

Parameters:

  | text | the text that will be displayed with this icon.
  | parent | the QGraphicsItem this icon is parented to.

__init__ | ( | self, |
|  | QIcon | icon,
|  | QString | text,
|  | QGraphicsItem | parent=0
| ) |  |  |

Creates a new Plasma.IconWidget with text and an icon.

Parameters:

  | icon | the icon that will be displayed with this icon.
  | text | the text that will be displayed with this icon.
  | parent | The QGraphicsItem this icon is parented to.

QAction action | ( |  | self ) |

Returns:
  the currently associated action, if any.

activated | ( |  | self ) |

Indicates when the icon has been activated following the single or doubleclick settings

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

addIconAction | ( | self, |
|  | QAction | action
| ) |  |  |

Plasma.IconWidget allows the user to specify a number of actions (currently four) to be displayed around the widget. This method allows for a created QAction to be added to the Plasma.IconWidget.

Parameters:

  | action | the QAction to associate with this icon.

changed | ( |  | self ) |

Indicates that something about the icon may have changed (image, text, etc) only actually works for icons associated with an action

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

clicked | ( |  | self ) |

Indicates when the icon has been clicked.

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

doubleClicked | ( |  | self ) |

Indicates when the icon has been double-clicked

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

drawActionButtonBase | ( | self, |
|  | QPainter | painter,
|  | QSize | size,
|  | int | element
| ) |  |  |

Internal:

bool drawBackground | ( |  | self ) |

Returns:
  true if a background area is to be drawn for the icon

hoverEnterEvent | ( | self, |
|  | QGraphicsSceneHoverEvent | event
| ) |  |  |

hoverLeaveEvent | ( | self, |
|  | QGraphicsSceneHoverEvent | event
| ) |  |  |

QIcon icon | ( |  | self ) |

Returns:
  the icon associated with this icon.

QSizeF iconSize | ( |  | self ) |

Returns:
  the size of this Plasma.IconWidget's graphical icon.

QString infoText | ( |  | self ) |

Returns the meta text associated with this icon.

invertLayout | ( | self, |
|  | bool | invert
| ) |  |  |

inverts the layout of the icons if the orientation is horizontal, normally we get icon on the left with left-to-right languages

Parameters:

  | invert | if we want to invert the layout of icons

bool invertedLayout | ( |  | self ) |

Returns:
  if the layout of the icons should appear inverted or not

bool isDown | ( |  | self ) |

mouseDoubleClickEvent | ( | self, |
|  | QGraphicsSceneMouseEvent | event
| ) |  |  |

mouseMoveEvent | ( | self, |
|  | QGraphicsSceneMouseEvent | event
| ) |  |  |

mousePressEvent | ( | self, |
|  | QGraphicsSceneMouseEvent | event
| ) |  |  |

mouseReleaseEvent | ( | self, |
|  | QGraphicsSceneMouseEvent | event
| ) |  |  |

int numDisplayLines | ( |  | self ) |

Returns:
  the number of lines allowed to display

paint | ( | self, |
|  | QPainter | painter,
|  | QStyleOptionGraphicsItem | option,
|  | QWidget | widget=0
| ) |  |  |

pressed | ( | self, |
|  | bool | down
| ) |  |  |

Indicates when the icon has been pressed.

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

setAction | ( | self, |
|  | QAction | action
| ) |  |  |

Associate an action with this IconWidget this makes the IconWidget follow the state of the action, using its icon, text, etc. when the IconWidget is clicked, it will also trigger the action. Unlike addIconAction, there can be only one associated action.

setDrawBackground | ( | self, |
|  | bool | draw
| ) |  |  |

Sets whether or not to draw a background area for the icon

@arg draw true if a background should be drawn or not

setIcon | ( | self, |
|  | QIcon | icon
| ) |  |  |

Sets the graphical icon for this Plasma.IconWidget.

Parameters:

  | icon | the KIcon to associate with this icon.

setIcon | ( | self, |
|  | QString | icon
| ) |  |  |

Convenience method to set the icon of this Plasma.IconWidget using a QString path to the icon.

Parameters:

  | icon | the path to the icon to associate with this Plasma.IconWidget.

setInfoText | ( | self, |
|  | QString | text
| ) |  |  |

Sets the additional information to be displayed by this icon.

Parameters:

  | text | additional meta text associated with this icon.

setNumDisplayLines | ( | self, |
|  | int | numLines
| ) |  |  |

Parameters:

  | numLines | the number of lines to show in the display.

setOrientation | ( | self, |
|  | Qt.Orientation | orientation
| ) |  |  |

let set the orientation of the icon Qt.Vertical: text under the icon Qt.Horizontal text at a side of the icon depending by the direction of the language

Parameters:

  | orientation | the orientation we want

setPressed | ( | self, |
|  | bool | pressed=1
| ) |  |  |

Sets the appearance of the icon to pressed or restores the appearance to normal. This does not simulate a mouse button press.

Parameters:

  | pressed | whether to appear as pressed (true) or as normal (false)

setSvg | ( | self, |
|  | QString | svgFilePath,
|  | QString | svgIconElement=QString()
| ) |  |  |

Convenience method to set the svg image to use when given the filepath and name of svg.

Parameters:

  | svgFilePath | the svg filepath including name of the svg.
  | svgIconElement | the svg element to use when displaying the svg. Defaults to all of them.

setText | ( | self, |
|  | QString | text
| ) |  |  |

Sets the text associated with this icon.

Parameters:

  | text | the text to associate with this icon.

setUnpressed | ( |  | self ) |

Shortcut for setPressed(false)

QPainterPath shape | ( |  | self ) |

reimplemented from QGraphicsItem

QSizeF sizeFromIconSize | ( | self, |
|  | float | iconWidth
| ) |  |  |

Returns:
  optimal size given a size for the icon

Parameters:

  |  | iconWidth desired width of the icon

QString text | ( |  | self ) |

Returns the text associated with this icon.