Notice: This forum has been recovered from an old backup, so some content, links, and dates may be outdated. The forum is currently read-only while we restore sign-in and registration functionality. Details

If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.

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

Do you have questions about writing plugins or scripts in Python? Meet the coders here.
Post Reply
masterjoe
Posts: 20
Joined: Thu Oct 15, 2015 11:20 am

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

Post 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
User avatar
kgschlosser
Site Admin
Posts: 5190
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

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

Post 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
If you like the work I have been doing then feel free to Image
masterjoe
Posts: 20
Joined: Thu Oct 15, 2015 11:20 am

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

Post 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.
User avatar
kgschlosser
Site Admin
Posts: 5190
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

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

Post 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
If you like the work I have been doing then feel free to Image
Post Reply