Python plug-in Frameworks like Eclipse RCP...

Diez B. Roggisch deetsNOSPAM at web.de
Sat Apr 2 08:17:31 EST 2005


Jim Hargrave wrote:

> Hum, maybe my question was too specific. What I would really like to
> know is what is the best way to implement a Python application with a
> pluggable architecture. In particular, I would like to use wxPython and
> have plug ins automatically register themselves with the GUI by adding
> themselves to the mean or adding a tab. Again this is much like Eclipse
> RCP - but forget that part :-)


This is close to beeing trivial in python - just utilize __import__ to
dynamically load modules that shall act as plugins. These modules then only
have to follow a sort of protocol - lets say you have a module called

pluginloader.py

that has a register-function. The loaded module could import pluginloader
and register itself, or a class defined in itself. Like this

---------plugin_example.py-------------

import pluginloader


class ExamplePlugin(pluginloader.PluginBase):
     def __init__(self,...):
         ....



pluginloader.register(ExamplePlugin())

------------------------



-- 
Regards,

Diez B. Roggisch



More information about the Python-list mailing list