Notice: This forum has been recovered from an old backup, so some content, links, and dates may be outdated. The forum is currently read-only while we restore sign-in and registration functionality. Details

If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.

Configuredialog

Do you have questions about writing plugins or scripts in Python? Meet the coders here.
Post Reply
Aquila
Experienced User
Posts: 88
Joined: Wed Jan 28, 2015 2:49 am

Configuredialog

Post by Aquila »

Hi!

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())
User avatar
Pako
Plugin Developer
Posts: 2294
Joined: Sat Nov 11, 2006 1:31 pm
Location: Czech Republic
Contact:

Re: Configuredialog

Post by Pako »

Aquila wrote: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.
I understand your feelings, but you'll probably have to put up with it.
I know that some things are poorly documented. But who should rectify it according to your opinion?
Maybe you voluntarily take on this task? Surely nobody would be against it.

I agree with you, that the configuration dialog is quite ugly, when you use commands like panel.AddLine().
It was probably the intention of the author of the program (Bitmonster) to simplify the development work.
Unfortunately, it has a negative impact just on the look of a dialogue.
But it is not mandatory to work this way!
You can see (if you will look at my plugins) that I'm working (with a few exceptions) very differently,
so the look is totally under my control. The advantage is that wx library is very well documented.
Aquila wrote: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.)
I can help you with this problem.
In the next version EventGhost it will work properly.
I once had a very similar problem (it was wx.CheckListBox).
And I know how Bitmonster then fixed this bug.

Pako
Aquila
Experienced User
Posts: 88
Joined: Wed Jan 28, 2015 2:49 am

Re: Configuredialog

Post by Aquila »

Pako wrote:I understand your feelings, but you'll probably have to put up with it.
I know that some things are poorly documented. But who should rectify it according to your opinion?
Maybe you voluntarily take on this task? Surely nobody would be against it.
If I ever understand it, I will try to make a small guide. I was just wondering if I had overlooked something. I will publish my plugin as soon as it is ok. And if I manage I will try to write a small piece about how a newbe made a working plugin. So the next guy/gal won't have too google as much as me. :p
Pako wrote:I agree with you, that the configuration dialog is quite ugly, when you use commands like panel.AddLine().
It was probably the intention of the author of the program (Bitmonster) to simplify the development work.
Unfortunately, it has a negative impact just on the look of a dialogue.
But it is not mandatory to work this way!
You can see (if you will look at my plugins) that I'm working (with a few exceptions) very differently,
so the look is totally under my control. The advantage is that wx library is very well documented.
I see the advantages of the easy use of the panel.AddLine(), I can make a plugin work without much hassel. I think I will leave the looks for a future update. But wx seems better, but requiering more work.
Pako wrote:
Aquila wrote: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.)
I can help you with this problem.
In the next version EventGhost it will work properly.
I once had a very similar problem (it was wx.CheckListBox).
And I know how Bitmonster then fixed this bug.
Ok, then I will overlook this for now.

Thanks!
Post Reply