This document will explain how to add a plugin can add a custom configuration panel to the plugin manager dialog to use for configuring plugin settings.
Adding a configuration panel is quite simple, a plugins __init__.py module just needs to implement the following interface function.
def GetConfigObject(): """Return an object derived from plugin.PluginConfigObject""" return MyPluginConfig()
This method needs to return an instance of a PluginConfigObject. This interface object is defined in plugin.py
class PluginConfigObject(object): """Plugin configuration object. Plugins that wish to provide a configuration panel should implement a subclass of this object in their __init__ module. The __init__ module must also have a function 'GetConfigObject' that returns an instance of this class. """ def GetConfigPanel(self, parent): """Get the configuration panel for this plugin @param parent: parent window for the panel @return: wxPanel """ raise NotImplementedError def GetBitmap(self): """Get the 32x32 bitmap to show in the config dialog @return: wx.Bitmap @note: Optional if not implemented default icon will be used """ return wx.NullBitmap def GetLabel(self): """Get the display label for the configuration @return: string """ raise NotImplementedError
Included below is an example implementation of adding a configuration panel. The following code just needs to exist in a plugins __init__.py module.
def GetConfigObject(): return ExamplePluginConfig() class ExamplePluginConfig(plugin.PluginConfigObject): """Plugin configuration object.""" def GetConfigPanel(self, parent): """Get the configuration panel for this plugin @param parent: parent window for the panel @return: wxPanel """ return ExampleConfigPanel(parent) def GetLabel(self): """Get the label for this config panel @return string """ return _("Example Plugin") class ExampleConfigPanel(wx.Panel): def __init__(self, parent, *args, **kwargs): wx.Panel.__init__(parent, *args, **kwargs) sizer = wx.BoxSizer(wx.HORIZONTAL) sizer.Add(wx.Button(parent, label="HELLO"), 0, wx.ALIGN_CENTER) self.SetSizer(sizer)