problem with hack using multiple inheritance for plugins
massimo s.
devicerandom at gmail.com
Thu Jun 28 12:41:44 EDT 2007
On 28 Giu, 15:37, Peter Otten <__pete... at web.de> wrote:
> Post a self-contained example.
Now I'm even more confused. The self-contained example is below... and
it works, using only old-style declarations.
#!/usr/bin/env python
import wx
import cmd
global CLI_PLUGINS
global GUI_PLUGINS
class MyCmd(cmd.Cmd):
def do_hello(self,args):
print 'hello'
class PlugCmd:
def _plug_init(self):
print 'init plugcmd'
def do_wow(self,args):
print 'wow'
#----------------------
class MyFrame(wx.Frame):
def __init__(self,parent,id,title):
ID_FRAME=-1
wx.Frame.__init__(self,parent,ID_FRAME,title,size=(800,600),style=wx.DEFAULT_FRAME_STYLE|
wx.NO_FULL_REPAINT_ON_RESIZE)
print dir(self)
for item in GUI_PLUGINS:
item._plug_init(self)
class PlugFrame:
def _plug_init(self):
print 'init plugframe'
CLI_PLUGINS=[PlugCmd]
GUI_PLUGINS=[PlugFrame]
def main():
app=wx.PySimpleApp()
def make_cli_class(*bases):
#return type(MainWindow)("MainWindowPlugged", bases +
(MainWindow,), {})
return type(MyCmd)("CliPlugged", bases + (MyCmd,), {})
def make_gui_class(*bases):
#return type(MainWindow)("MainWindowPlugged", bases +
(MainWindow,), {})
return type(MyFrame)("MainWindowPlugged", bases +
(MyFrame,), {})
my_cli=make_cli_class(*CLI_PLUGINS)()
main_frame = make_gui_class(*GUI_PLUGINS)(None, -1, ('Test'))
main_frame.Show()
#run one loop or the other when testing
#app.MainLoop()
my_cli.cmdloop()
main()
More information about the Python-list
mailing list