Page 1 of 1

Plugin name is "Plugin: " when using multiple base classes

Posted: Thu Apr 07, 2016 4:32 pm
by masterjoe
Hi there,

I have already written several (smaller) Python plugins and this is the first time I stumbled over this issue. I now have a plugin class which is derived from TWO base classes because I require the additional functionality of the additional base class internally.
However when deriving from more than only eg.PluginBase it seems that the item's name in the plugin tree is corrupted.

So in short:
- my plugin class XYZ is derived from eg.PluginBase and another base class
- in the "add plugin" dialog the name of my plugin is displayed correctly as stated in the eg.RegisterPlugin() call
- when the plugin is added to the tree the item's name is not "Plugin: XYZ" but "Plugin: "

How to fix that? If this bug related to Eventghost's way of finding plugins inside __init__.py files?

Thanks.
Oli

Re: Plugin name is "Plugin: " when using multiple base class

Posted: Thu Apr 07, 2016 9:41 pm
by kgschlosser
you don't have to put the eg.PluginBase in there.

just leave it blank. and then in the init of the class with the pluginbase you idk the term.

but here is an example


self.myextraclass = myextraclass()

if your init of that extra class has variable you have to supply them when you call the class for the first time. and always make sure you do have 1 in there


it should like like this

Code: Select all

class MyExtraClass():

    def __init__(self, plugin):
        self.plugin = plugin
and you call it like so

Code: Select all

self.MyExtraClass = MyExtraClass(self)
that way you have a means to get back to the pluginbase class if you need to access a function or a variable. and you would access it by doing

self.plugin.somedef(blah, blah, blah)

K

Re: Plugin name is "Plugin: " when using multiple base class

Posted: Fri Apr 08, 2016 8:38 am
by masterjoe
Well that's not so easy... First of the new plugin is not just 50 lines but 13.000 lines of source code and the plugin class is also passed to exec script commands where I want the plugin to possess another larger interface that I have defined myself.
Also I don't think that it's possible at all not deriving any Eventghost plugin class from eg.Pluginbase!? Because Eventghost will most probably need to access members of eg.Pluginbase that won't be at the same position in the dict of the plugin class when not deriving from it! I think this solution doesn't work! See here: http://www.eventghost.org/docs/writing_plugins.html

For me currently the only solution would be to create a wrapper class for the current plugin that is then derived from eg.PluginBase so that the wrapper and the actual plugin are both just derived from a single base class. But if possible I would not want to do it this way...

For me the question remains why Eventghost trashes the plugin's name in the item tree when there are two base classes for the plugin? Because otherwise the plugin works normally.

Anyone?

Thanks.

Re: Plugin name is "Plugin: " when using multiple base class

Posted: Wed Apr 13, 2016 7:13 pm
by kgschlosser
that link does not show multiple PluginBase

it shows one PluginBase and then all ActionBase

the PluginBase is what is used to call anything and everything in your plugin.

you can use the ActionBase to add actions to the EG tree that people can use to trigger your plugin. i am guessing you need to use one of those to trigger one of your other classes so maybe the only real purpose of the PluginBase would be to define the actions and then those make whatever call is needed to whatever base class you want to use.

i'm trying to grasp what you are trying to accomplish. if you could put some code examples of what you are trying to do.

K