I found these posts while searching for a similar solution:
--------------------------------------------------------------------------
Sbaush <[hidden email] <http://wxpython-users.1045709.n5.nabble.com/user/SendEmail.jtp?type=node&node=2354527&i=0>> wrote:
> Maby thanks for your quick answer...
> So should be relatively simple write for example two macro-plugins like two
> directories (viewed in the menu-bar), and then a suite of sub-plugins stored
> in files (for example the voices of the sub-menu)
> My idea is to create two or more folders like this:
That that would be easy.
> src/plugin1/
>sub-pluign1.py
>sub-plugin2.py
That is fine, except that sub-plugin1, etc., should be named
sub_plugin1.py, etc., and there must be an __init__.py so that it can be
imported via: import plugin1.sub_plugin1 .
> So in the menubar i could have Plugin1 and Plugin2 like two buttons, and the
> sub-plugins like voices of the menu buttons.
> Have you understand my idea?
That is possible, but you need to define an interface for how plugins
interact with your menu bar, frames, etc.
- Josiah
-----------------------------------------------------------------------------------------
My question now is this:
How do I define an interface for how plugins interact with menu items, frames etc, etc?
Please can anyone share a sample code for this?
Thanks.
Austin
On Monday, March 26, 2007 9:33:10 PM UTC+1, Josiah Carlson wrote:
Sbaush <sba...@gmail.com <javascript:>> wrote:
> Is there a pattern that could help
> me in searching for new plugins and in loading plugins?
The following code will get a listing of .py files then import them.
You may want to wrap each import in a try/except to delete the module
from sys.modules if loading failed.
plugin_path = ...
plugin_name = ...
x = [i[:-3] for i in os.listdir(plugin_path)
if i.endswith('.py') and and i.count('.')== 1
and i != '__init__.py']
for plug_name in x:
gl = globals()
pl = gl[plug_name] = __import__('%s.%s'%(plugin_name,
plug_name))
#do whatever you need to do to the plugin pl here
- Josiah
--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+unsubscribe@googlegroups.com <mailto:wxpython-users+unsubscribe@googlegroups.com>.
For more options, visit https://groups.google.com/d/optout.