KDE 4.6 PyKDE API Reference

- KDE's Python API

# Label Class Reference

`from PyKDE4.plasma import *`

Inherits: QGraphicsProxyWidget → QGraphicsWidget → QObject
Namespace: Plasma

## Detailed Description

Label plasma/widgets/label.h <Plasma/Widgets/Label>

Provides a plasma-themed QLabel.

## Signals

| linkActivated (QString link)
| linkHovered (QString link)

## Methods

| __init__ (self, QGraphicsWidget parent=0)
Qt::Alignment | alignment (self)
| changeEvent (self, QEvent event)
| contextMenuEvent (self, QGraphicsSceneContextMenuEvent event)
| dataUpdated (self, QString sourceName, {QString:QVariant} data)
bool | event (self, QEvent event)
bool | hasScaledContents (self)
QString | image (self)
QVariant | itemChange (self, QGraphicsItem.GraphicsItemChange change, QVariant value)
| mouseMoveEvent (self, QGraphicsSceneMouseEvent event)
| mousePressEvent (self, QGraphicsSceneMouseEvent event)
QLabel | nativeWidget (self)
| paint (self, QPainter painter, QStyleOptionGraphicsItem option, QWidget widget)
| resizeEvent (self, QGraphicsSceneResizeEvent event)
| setAlignment (self, Qt::Alignment alignment)
| setImage (self, QString path)
| setScaledContents (self, bool scaled)
| setStyleSheet (self, QString stylesheet)
| setText (self, QString text)
| setTextSelectable (self, bool enable)
| setWordWrap (self, bool wrap)
QSizeF | sizeHint (self, Qt::SizeHint which, QSizeF constraint)
QString | styleSheet (self)
QString | text (self)
bool | textSelectable (self)
bool | wordWrap (self)

## Signal Documentation

linkActivated | ( | QString | link
| ) |  |  |

Signal syntax:
  `QObject.connect(source, SIGNAL("linkActivated(const QString&)"), target_slot)`

linkHovered | ( | QString | link
| ) |  |  |

Signal syntax:
  `QObject.connect(source, SIGNAL("linkHovered(const QString&)"), target_slot)`

## Method Documentation

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

Constructs a label with word wrap on by default

@arg parent the parent of this widget

Qt::Alignment alignment | ( |  | self ) |

Returns:
  the alignment for the text used in the labels

changeEvent | ( | self, |
|  | QEvent | event
| ) |  |  |

contextMenuEvent | ( | self, |
|  | QGraphicsSceneContextMenuEvent | event
| ) |  |  |

dataUpdated | ( | self, |
|  | QString | sourceName,
|  | {QString:QVariant} | data
| ) |  |  |

bool event | ( | self, |
|  | QEvent | event
| ) |  |  |

bool hasScaledContents | ( |  | self ) |

Returns:
  true if the contents are scaled to the label size

QString image | ( |  | self ) |

Returns:
  the image path being displayed currently, or an empty string if none.

QVariant itemChange | ( | self, |
|  | QGraphicsItem.GraphicsItemChange | change,
|  | QVariant | value
| ) |  |  |

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

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

QLabel nativeWidget | ( |  | self ) |

Returns:
  the native widget wrapped by this Label

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

resizeEvent | ( | self, |
|  | QGraphicsSceneResizeEvent | event
| ) |  |  |

setAlignment | ( | self, |
|  | Qt::Alignment | alignment
| ) |  |  |

Sets the alignment for the text

@arg the desired alignment

setImage | ( | self, |
|  | QString | path
| ) |  |  |

Sets the path to an image to display.

@arg path the path to the image; if a relative path, then a themed image will be loaded.

setScaledContents | ( | self, |
|  | bool | scaled
| ) |  |  |

Scale or not the contents of the label to the label size

@arg scale

setStyleSheet | ( | self, |
|  | QString | stylesheet
| ) |  |  |

Sets the stylesheet used to control the visual display of this Label

@arg stylesheet a CSS string

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

Sets the display text for this Label

@arg text the text to display; should be translated.

setTextSelectable | ( | self, |
|  | bool | enable
| ) |  |  |

Set if the text on the label can be selected with the mouse

@arg enable true if we want to manage text selection with the mouse

Since:
  4.4

setWordWrap | ( | self, |
|  | bool | wrap
| ) |  |  |

Sets if the text of the label can wrap in multiple lines

@arg wrap multiple lines or not

Since:
  4.5

QSizeF sizeHint | ( | self, |
|  | Qt::SizeHint | which,
|  | QSizeF | constraint
| ) |  |  |

QString styleSheet | ( |  | self ) |

Returns:
  the stylesheet currently used with this widget

QString text | ( |  | self ) |

Returns:
  the display text

bool textSelectable | ( |  | self ) |

Returns:
  true if the text is selectable with the mouse

Since:
  4.4

bool wordWrap | ( |  | self ) |

Returns:
  true if the label text can wrap in multiple lines if too long

Since:
  4.5