Python PopupApplet and ScriptEngines

Richard Dale richard.j.dale at gmail.com
Sat Feb 20 16:56:58 CET 2010


On Sat, Feb 20, 2010 at 11:18 AM, Luca Beltrame
<einar at heavensinferno.net> wrote:
> Hello,
>
> AFAIK, there is no PopupApplet for Python scriptengines yet, and I'd like to
> hack in this functionality.
> Currently the applets in Python use "plasmascript" to work, so I assume this
> would be the place to add support in. So, here come the questions:
>
> 1. Is there documentation on how a "proper" PopupApplet should be?
You need to study the popopapplet.h header file and look at examples.

> 2. To those familiar with the design of the Python binding, is creating a
> "plasmascript.PopupApplet" the way to go?
Yes, at minimum the class needs to have setter and getter methods for
widget and graphicsWidget. See these methods in popupapplet.h:

    /**
     * Implement either this function or graphicsWidget().
     * @return 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.
     */
    virtual QWidget *widget();
    void setWidget(QWidget * widget);

    /**
     * Implement either this function or widget().
     * @return 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.
     */
    virtual QGraphicsWidget *graphicsWidget();
    void setGraphicsWidget(QGraphicsWidget * widget);

Also add methods to the plasmascript PopupApplet class to forward
method calls to the underlying wrapped C++ instance of the
Plasma::PopupApplet.

Popup applets make use of extender items, and you need to make sure
that the python applet code connects to the
extenderItemRestored(Plasma::ExtenderItem*) signal in Plasma::Applet,
and invokes a slot called something like
initExtenderItem(Plasma::ExtenderItem*) in the plasmascripting Applet
class. Note that this isn't PopupApplet specific, but I believe
extender items are used quite frequently in conjunction with popup
applets.

> 3. Is there any documentation on how "plasmascript" was conceived and
> designed?
Blogs, reading headers and looking at examples will tell you most things.


More information about the Plasma-devel mailing list