I'm trying my way with developing a plugin, first real try with both EG and Python. So please excuse any newbe mistakes. (Also, English is not my primary language.)
After a lot of trial and error, I have been starting to come to grips with how plugins work. (The wiki and documentation leave you with a lot of questions.) I can get my plugin to do what I want, but the configuration dialog for my actions (and config for the plugin itself) looks like a mess. (It actualy works, but only if you now what I have put in there.)
Problem number one:
I can't seem to find any good documentation for the eg.ConfigPanel(). I've been looking at other plugins, and that have given me some clues. But I totaly don't understand what my code does, and most importantly does not. Looking at other plugins I gather that many use wx, and I have manged to integrate this to my plugin. But it looks like a trainwreck.
Problem number two:
The "Apply" button does not enable when I change a slider in the configdialog, other changes enable the "Apply" button. Pressing "OK" saves the changes correctly anyways. But if I'm to publish my work, I want to have this correctly. (I've cheated in the code under, and used the "SetIsDirty()". This forces the "Apply" button to be enabled, but I want it done correctly.)
Her is part of my code to try to explain what I'm doing.
P.S.: The plugin I'm making is for the "Philips Hue", and it's working like a charm except for the looks and feels of the configsdialogs.
Code: Select all
class ChangeBrightness(eg.ActionBase):
name = "Change brightness"
description = "Changes brightness for a specified light."
def __call__(self, light, brightness):
self.plugin.b.set_light(light, 'bri', brightness)
def Configure(self, light=1, brightness=255):
panel = eg.ConfigPanel(self)
helpString = "Change brightness of specified light"
helpLabel=panel.StaticText(helpString)
lights = self.plugin.b.lights
lightChoices = []
for l in lights:
lightChoices.append(l.name)
selectLight = panel.Choice(light-1, choices=lightChoices)
brightCtrl = wx.Slider(
panel,
-1,
brightness,
0,
255,
(10, 10),
(200, 50),
wx.SL_HORIZONTAL | wx.SL_LABELS
)
panel.AddLine(helpLabel)
panel.AddLine("Light: ", selectLight)
panel.AddLine(brightCtrl)
panel.SetIsDirty()
while panel.Affirmed():
panel.SetResult(selectLight.GetValue()+1, brightCtrl.GetValue())