I appear to have still a small problem with using the plugins.
Loading the plugin which is defined on a wx.Panel seems to work.
Unfortunately, the buttons which are located on the plugin panel don’t seem to capture the button events.
I.e., clicking on them doesn’t do anything, while it is expected that the button clicks write something in the logWindow.
See below for a code excerpt example.
LoadPlugin function in main.py, MainFrame class:
···
====================================
def LoadPlugin(self, pluginFilename):
print “Selected plugin: “, pluginFilename
plugin = pluginFilename.replace(”.py”,"")
mod = import(“TomsPlugins.”+plugin, globals(), locals(), plugin)
newPanel = mod.PluginPanel2(self.frame)
self.panelSizer.Add(newPanel.GetPanel())
self.frame.Fit()
In the plugin2.py file:
===============
class PluginPanel:
def init(self, parent):
#Load the panel from XRC
panelResource = xrc.XmlResource(“C:/TomsPlugins/plugin2.xrc”)
#Attach the panel to the parent frame
self.pluginPanel = panelResource.LoadPanel(parent, ‘mainPanel’)
#Reference the widgets from the xrc resource
self.button1 = GetControl(self.pluginPanel, “button1”)
self.button2 = GetControl(self.pluginPanel, “button2”)
self.logWindow = GetControl(self.pluginPanel, “logWindow”)
#Bind the widgets on the panel
self.button1.Bind(wx.EVT_BUTTON, self.OnButton1)
self.button2.Bind(wx.EVT_BUTTON, self.OnButton2)
def OnButton1(self, evt):
self.logWindow.WriteText(“Button 1\n”)
def OnButton2(self, evt):
self.logWindow.WriteText(“Button 2\n”)
def GetPanel(self):
return self.pluginPanel
Best regards,
Tom.