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

Richard Dale richard.j.dale at gmail.com
Thu Feb 11 19:37:55 CET 2010


On Thu, Feb 11, 2010 at 6:02 PM, Luca Beltrame <einar at heavensinferno.net> wrote:
> Hello,
>
> currently if you use Python plasmoids the main script *must* be named
> "main.py" because it is hardcoded into pyappletscripts.py. When using a
> different mainscript in the .desktop file (like Plasmate does) this will
> ensure the plasmoid will not run (you get a NameError exception).
Well currently in Plasmate there is not way to specifiy the main
script (or main class).

The Ruby plasmoid implementation doesn't use the Ruby equivalent of
__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
Plasmate like FooBar which would give a main script name of
foo_bar.rb. Or whether you should give a main script name of
foo_bar.rb the Plasmate form from which the class 'FooBar' is then
derived.

Currently in Plasmate the name of the applet is used to derive both
the module (like a namespace), and the name of the class, which I
think is wrong. For example, if you call your applet FooBar you get:

module FooBar
  class FooBar< PlasmaScripting::Applet
...

I would rather the class was called 'Main' if you don't specifiy a main script.

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?


> The attached patch fixes this by retrieving the mainscript file, stripping it
> to its name and then using Python introspection (__dict__) to pass the right
> module name to the CreateApplet call.
>
> After applying, old plasmoids (using main.py) and new ones (using *any name*)
> seem to work correctly.
>
> OK to commit? Should this also be backported?
>
> _______________________________________________
> Plasma-devel mailing list
> Plasma-devel at kde.org
> https://mail.kde.org/mailman/listinfo/plasma-devel
>
>


More information about the Plasma-devel mailing list