KDE 4.9 PyKDE API Reference

- KDE's Python API

# PushButton Class Reference

`from PyKDE4.plasma import *`

Inherits: QGraphicsProxyWidget → QGraphicsWidget → QObject
Namespace: Plasma

## Detailed Description

PushButton plasma/widgets/pushbutton.h <Plasma/Widgets/PushButton>

Provides a plasma-themed KPushButton.

## Signals
| clicked ()
| pressed ()
| released ()
| toggled (bool a0)
## Methods
| __init__ (self, QGraphicsWidget parent=0)
QAction | action (self)
| changeEvent (self, QEvent event)
| click (self)
| hoverEnterEvent (self, QGraphicsSceneHoverEvent event)
| hoverLeaveEvent (self, QGraphicsSceneHoverEvent event)
QIcon | icon (self)
QString | image (self)
bool | isCheckable (self)
bool | isChecked (self)
bool | isDown (self)
KPushButton | nativeWidget (self)
| paint (self, QPainter painter, QStyleOptionGraphicsItem option, QWidget widget=0)
| resizeEvent (self, QGraphicsSceneResizeEvent event)
| setAction (self, QAction action)
| setCheckable (self, bool checkable)
| setChecked (self, bool checked)
| setIcon (self, QIcon icon)
| setIcon (self, KIcon icon)
| setImage (self, QString path)
| setImage (self, QString path, QString elementid)
| setStyleSheet (self, QString stylesheet)
| setText (self, QString text)
QSizeF | sizeHint (self, Qt::SizeHint which, QSizeF constraint)
QString | styleSheet (self)
QString | text (self)

## Signal Documentation

clicked | ( |  | ) |

Emitted when the button is pressed then released, completing a click

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

pressed | ( |  | ) |

Emitted when the button is pressed down; usually the clicked() signal will suffice, however.

Since:
  4.4

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

released | ( |  | ) |

Emitted when the button is released; usually the clicked() signal will suffice, however.

Since:
  4.4

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

toggled | ( | bool | a0
| ) |  |  |

Emitted when the button changes state from up to down

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

## Method Documentation

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

QAction action | ( |  | self ) |

Returns:
  the currently associated action, if any.

Since:
  4.3

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

click | ( |  | self ) |

Performs a visual click and emits the associated signals

Since:
  4.6

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

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

QIcon icon | ( |  | self ) |

Returns:
  the icon of this button

Since:
  4.3

QString image | ( |  | self ) |

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

bool isCheckable | ( |  | self ) |

Returns:
  true if the button is checkable

See also:
  setCheckable

Since:
  4.4

bool isChecked | ( |  | self ) |

Returns:
  true if the button is checked; requires setIsCheckable(true) to be called

Since:
  4.3

bool isDown | ( |  | self ) |

Returns:
  true if the button is pressed down

Since:
  4.4

KPushButton nativeWidget | ( |  | self ) |

Returns:
  the native widget wrapped by this PushButton

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

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

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

Associate an action with this IconWidget this makes the button follow the state of the action, using its icon, text, etc. when the button is clicked, it will also trigger the action.

Since:
  4.3

setCheckable | ( | self, |
|  | bool | checkable
| ) |  |  |

Sets whether or not this button can be toggled on/off

Since:
  4.3

setChecked | ( | self, |
|  | bool | checked
| ) |  |  |

Sets whether or not this button is checked. Implies setIsCheckable(true).

Since:
  4.3

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

sets the icon for this push button using a KIcon

Parameters:

  | icon | the icon to use

Since:
  4.4

setIcon | ( | self, |
|  | KIcon | icon
| ) |  |  |

sets the icon for this push button using a KIcon

Parameters:

  | icon | the icon to use

Since:
  4.4

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

Sets the path to an svg image to display and the id of the used svg element, if necessary.

Parameters:

  | path | the path to the image; if a relative path, then a themed image will be loaded.
  | elementid | the id of a svg element.

Since:
  4.4

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

Sets the path to an svg image to display and the id of the used svg element, if necessary.

Parameters:

  | path | the path to the image; if a relative path, then a themed image will be loaded.
  | elementid | the id of a svg element.

Since:
  4.4

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

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

Parameters:

  | stylesheet | a CSS string

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

Sets the display text for this PushButton

Parameters:

  | text | the text to display; should be translated.

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