[PATCH] Support for arbitrary main script names in Python plasmoids

Luca Beltrame einar at heavensinferno.net
Thu Feb 11 19:48:33 CET 2010


In data giovedì 11 febbraio 2010 19:37:55, Richard Dale ha scritto:

> __dict__, but simply derives the main class name from the main script
> name. So I wasn't sure is you should specifiy a main *class* name in

This is what is done with my change, at the moment (I used __dict__ because I 
thought it was the best solution - suggestions welcome in case as I'm not that 
experienced). Earlier, the main script name was forced to be called "main" or 
it would cause errors. 

> For Python, what if there are several classes in the the python main
> script file - how do you tell which one is for the applet you want to
> instantiate?

You use the one that's called by CreateApplet, which needs to be put in the 
main script file:

class FooApplet(plasmascript.Applet):
    ...

def CreateApplet(parent):
    return FooApplet(parent)

and the relevant bit is then called in the initialization:

self.pyapplet = self.module.__dict__[basename].CreateApplet(None)

so CreateApplet should *always* return the right applet and must be in the 
main script file.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://mail.kde.org/pipermail/plasma-devel/attachments/20100211/12a978d4/attachment.sig 


More information about the Plasma-devel mailing list