[PATCH] Support for PopupApplets in Python

Richard Dale richard.j.dale at gmail.com
Sun Feb 28 23:07:51 CET 2010


On Sun, Feb 28, 2010 at 8:26 PM, Simon Edwards <simon at simonzone.com> wrote:
> Richard Dale wrote:
>> On Sat, Feb 27, 2010 at 4:42 PM, Luca Beltrame <einar at heavensinferno.net> wrote:
>>> In data sabato 27 febbraio 2010 15:13:23, Petri Damstén ha scritto:
>>>> Python popup applet with extenders:
>>>> http://websvn.kde.org/trunk/KDE/kdeexamples/plasma/python/applets/pyhello/
>>> Thanks, then my patch is completely unnecessary, as the standard __getattr__
>>> method is enough.
>>> I'll probably use your example, dissect it a bit , then write a tutorial on
>>> Techbase so that things are more clear for people new to applet development (I
>>> admit I managed to miss this example...)
>> But shouldn't there still be Python plasma scripting PopupApplet and
>> Containment classes? Is the C++ instance correctly wrapped as a
>> Plasma::PopupApplet or Plasma::Container, as opposed to a vanilla
>> Plasma::Applet?
>
> If I remember correctly, (it has been a while since I've looked), the
> Python code doesn't create the instance of the Applet itself. Plasma
> does this by itself, but the plasmoid developer has to provide their own
> AppletScript object which acts a proxy. There is no PopupAppletScript in
> plasma libs. So I guess the needed code exists already in libplasma in
> the related scripting classes.
I was meaning that the python code should create a subclass of
PopupApplet. For instance, the
kdeexamples/plasma/python/applets/pyhello is a popup applet, but
currently it is a subclass of Applet:

class Hello(Applet):
    def __init__(self, parent, args = None):
        Applet.__init__(self, parent)
        self.frame = None

In Ruby I added Popup and Containment classes, which currently don't
do anything:

  class Containment < Applet
    def initialize(parent, args = nil)
      super(parent, args)
    end
  end

  class PopupApplet < Applet
    def initialize(parent, args = nil)
      super(parent, args)
    end
  end

Strictly speaking they aren't needed because method calls are just
forwarded to the Ruby instance that wraps the C++ instance created by
the Plasma runtime, just as happens in Python. But I added them
because I think it makes the application code clearer, and maybe in
the future there will actually be some code in the PopupApplet and
Containment classes that isn't in the Applet class. Then any current
Ruby popup applets and containments will be forward compatible without
source changes being needed.

-- Richard


More information about the Plasma-devel mailing list