KPushButton

KDE 4.2 PyKDE API Reference

- KDE's Python API

# KPushButton Class Reference

`from PyKDE4.kdeui import *`

Inherits: QPushButton → QAbstractButton → QWidget → QObject

## Detailed Description

A QPushButton with drag-support and KGuiItem support

This is nothing but a QPushButton with drag-support and KGuiItem support. You must call #setDragEnabled (true) and override the virtual method dragObject() to specify the QDragObject to be used.

Author:
  Carsten Pfeiffer <pfeiffer@kde.org>

## Methods
| __init__ (self, QWidget parent=0)
| __init__ (self, QString text, QWidget parent=0)
| __init__ (self, KIcon icon, QString text, QWidget parent=0)
| __init__ (self, KGuiItem item, QWidget parent=0)
QMenu | delayedMenu (self)
QDrag | dragObject (self)
KStandardGuiItem.StandardItem | guiItem (self)
bool | isDragEnabled (self)
| mouseMoveEvent (self, QMouseEvent a0)
| mousePressEvent (self, QMouseEvent a0)
| setDelayedMenu (self, QMenu delayed_menu)
| setDragEnabled (self, bool enable)
| setGuiItem (self, KGuiItem item)
| setGuiItem (self, KStandardGuiItem.StandardItem item)
| setIcon (self, KIcon icon)
| setIcon (self, QIcon pix)
| setText (self, QString text)
| startDrag (self)

## Method Documentation

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

Default constructor.

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

Constructor, that sets the button-text to text

__init__ | ( | self, |
|  | KIcon | icon,
|  | QString | text,
|  | QWidget | parent=0
| ) |  |  |

Constructor, that sets an icon and the button-text to text

__init__ | ( | self, |
|  | KGuiItem | item,
|  | QWidget | parent=0
| ) |  |  |

Constructor that takes a KGuiItem for the text, the icon, the tooltip and the what's this help

QMenu delayedMenu | ( |  | self ) |

returns a delayed popup menu since menu() isn't virtual

QDrag dragObject | ( |  | self ) |

Reimplement this and return the QDrag object that should be used for the drag. Remember to give it "this" as parent.

Default implementation returns 0, so that no drag is initiated.

KStandardGuiItem.StandardItem guiItem | ( |  | self ) |

Reads the standard KGuiItem for this button.

bool isDragEnabled | ( |  | self ) |

Returns:
  if drag support is enabled or not.

mouseMoveEvent | ( | self, |
|  | QMouseEvent | a0
| ) |  |  |

Reimplemented to add drag-support

mousePressEvent | ( | self, |
|  | QMouseEvent | a0
| ) |  |  |

Reimplemented to add drag-support

setDelayedMenu | ( | self, |
|  | QMenu | delayed_menu
| ) |  |  |

Sets a delayed popup menu for consistency, since menu() isn't virtual

setDragEnabled | ( | self, |
|  | bool | enable
| ) |  |  |

Enables/disables drag-support. Default is disabled.

setGuiItem | ( | self, |
|  | KGuiItem | item
| ) |  |  |

Sets the KGuiItem for this button.

setGuiItem | ( | self, |
|  | KStandardGuiItem.StandardItem | item
| ) |  |  |

Sets the standard KGuiItem for this button.

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

Sets the Icon Set for this button. It also takes into account hte KGlobalSettings.showIconsOnPushButtons() setting.

setIcon | ( | self, |
|  | QIcon | pix
| ) |  |  |

Sets the pixmap for this button. Rarely used. This one exists mostly for usage in Qt designer, with icons embedded into the ui file. But you should rather save them separately, and load them with KIcon("name") so that the icons are themeable.

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

Sets the text of the button

startDrag | ( |  | self ) |

Starts a drag (dragCopy() by default) using dragObject()