KDE 4.5 PyKDE API Reference

- KDE's Python API

# PopupApplet Class Reference

`from PyKDE4.plasma import *`

Inherits: Plasma.Applet → QGraphicsWidget → QObject
Namespace: Plasma

## Detailed Description

Allows applets to automatically 'collapse' into an icon when put in an panel, and is a convenient base class for any applet that wishes to use extenders.

Applets that subclass this class should implement either widget() or graphicsWidget() to return a widget that will be displayed in the applet if the applet is in a Planar or MediaCenter form factor. If the applet is put in a panel, an icon will be displayed instead, which shows the widget in a popup when clicked.

If you use this class as a base class for your extender using applet, the extender will automatically be used for the popup; reimplementing graphicsWidget() is unnecessary in this case. If you need a popup that does not steal window focus when openend or used, set window flag Qt.X11BypassWindowManagerHint the widget returned by widget() or graphicsWidget().

## Methods
| __init__ (self, QObject parent, [QVariant] args)
| __init__ (self, QString packagePath, long appletId, [QVariant] args)
| dragEnterEvent (self, QGraphicsSceneDragDropEvent event)
| dragLeaveEvent (self, QGraphicsSceneDragDropEvent event)
| dropEvent (self, QGraphicsSceneDragDropEvent event)
bool | eventFilter (self, QObject watched, QEvent event)
QGraphicsWidget | graphicsWidget (self)
| hidePopup (self)
bool | isPassivePopup (self)
bool | isPopupShowing (self)
| mousePressEvent (self, QGraphicsSceneMouseEvent event)
| mouseReleaseEvent (self, QGraphicsSceneMouseEvent event)
| popupEvent (self, bool show)
QIcon | popupIcon (self)
Plasma.PopupPlacement | popupPlacement (self)
| setGraphicsWidget (self, QGraphicsWidget widget)
| setPassivePopup (self, bool passive)
| setPopupIcon (self, QIcon icon)
| setPopupIcon (self, QString iconName)
| setWidget (self, QWidget widget)
| showPopup (self, long displayTime=0)
QSizeF | sizeHint (self, Qt::SizeHint which, QSizeF constraint=QSizeF())
| togglePopup (self)
QWidget | widget (self)

## Method Documentation

__init__ | ( | self, |
|  | QObject | parent,
|  | [QVariant] | args
| ) |  |  |

__init__ | ( | self, |
|  | QString | packagePath,
|  | long | appletId,
|  | [QVariant] | args
| ) |  |  |

Internal:
  This constructor is to be used with the Package loading system.

Parameters:

  | parent | a QObject parent; you probably want to pass in 0
  | args | a list of strings containing two entries: the service id and the applet id

Since:
  4.3

dragEnterEvent | ( | self, |
|  | QGraphicsSceneDragDropEvent | event
| ) |  |  |

Reimplemented from QGraphicsLayoutItem

dragLeaveEvent | ( | self, |
|  | QGraphicsSceneDragDropEvent | event
| ) |  |  |

Reimplemented from QGraphicsLayoutItem

dropEvent | ( | self, |
|  | QGraphicsSceneDragDropEvent | event
| ) |  |  |

Reimplemented from QGraphicsLayoutItem

bool eventFilter | ( | self, |
|  | QObject | watched,
|  | QEvent | event
| ) |  |  |

Reimplemented from QGraphicsLayoutItem

QGraphicsWidget graphicsWidget | ( |  | self ) |

Implement either this function or widget().

Returns:
  the widget that will get shown in either a layout, in the applet or in a Dialog, depending on the form factor of the applet. If you set a popup icon you must set a minimum size to the widget. When the applet will be littlier than that it will show the icon

hidePopup | ( |  | self ) |

Hides the popup.

bool isPassivePopup | ( |  | self ) |

Returns:
  true if the dialog will be treated as a passive poup

bool isPopupShowing | ( |  | self ) |

Returns:
  true if the applet is popped up

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

Reimplemented from QGraphicsLayoutItem

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

Reimplemented from QGraphicsLayoutItem

popupEvent | ( | self, |
|  | bool | show
| ) |  |  |

This event handler can be reimplemented in a subclass to receive an event before the popup is shown or hidden. @arg show true if the popup is going to be shown, false if the popup is going to be hidden. Note that showing and hiding the popup on click is already done in PopupApplet.

QIcon popupIcon | ( |  | self ) |

Returns:
  the icon that is displayed when the applet is in a panel.

Plasma.PopupPlacement popupPlacement | ( |  | self ) |

Returns:
  the placement of the popup relating to the icon

setGraphicsWidget | ( | self, |
|  | QGraphicsWidget | widget
| ) |  |  |

setPassivePopup | ( | self, |
|  | bool | passive
| ) |  |  |

Sets whether or not the dialog popup that gets created should be a "passive" popup that does not steal focus from other windows or not.

@arg passive true if the dialog should be treated as a passive popup

setPopupIcon | ( | self, |
|  | QIcon | icon
| ) |  |  |

@arg icon the icon that has to be displayed when the applet is in a panel. Passing in an empty QString() means that the popup applet itself will provide an interface for when the PopupApplet is not showing the widget() or graphicsWidget() directly.

setPopupIcon | ( | self, |
|  | QString | iconName
| ) |  |  |

@arg icon the icon that has to be displayed when the applet is in a panel. Passing in an empty QString() means that the popup applet itself will provide an interface for when the PopupApplet is not showing the widget() or graphicsWidget() directly.

setWidget | ( | self, |
|  | QWidget | widget
| ) |  |  |

showPopup | ( | self, |
|  | long | displayTime=0
| ) |  |  |

Shows the dialog showing the widget if the applet is in a panel. @arg displayTime the time in ms that the popup should be displayed, defaults to 0 which means always (until the user closes it again, that is).

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

Reimplemented from QGraphicsLayoutItem

togglePopup | ( |  | self ) |

Toggles the popup.

QWidget widget | ( |  | self ) |

Implement either this function or graphicsWidget().

Returns:
  the widget that will get shown in either a layout, in the applet or in a Dialog, depending on the form factor of the applet.