Dependent/variable configure dialog

Do you have questions about writing plugins or scripts in Python? Meet the coders here.
Post Reply
KB_
Posts: 4
Joined: Tue Oct 13, 2015 11:11 pm

Dependent/variable configure dialog

Post by KB_ » Wed Oct 21, 2015 9:12 pm

Hi everybody,

It would be great if someone could help me with a configure dialog I am trying to write. I am not at all familiar with wx, so please forgive me any dumm questions or wrong names.
I tried googling it, but do not even know what to search for.

What I am trying to do:
I would like to have a configure() dialog for an action, which has two Choice controls.
The first choice control would have the choices "a" and "b".
For the second choice control, I want it to display its choices dependent on the value selected in the first choice control.

As an example:
If "a" is selected in the first choice control, then the second choice control would display "a1" and "a2".
If "b" is selected in the first choice control, then the second choice control would display "b1" and "b2".

I started coding the configure dialog (without this dependency). Basically I would want sth along the lines of this (the choices_dict[key_idx] part is Pseudo Code):

Code: Select all

def Configure(self, key_idx=0, value_idx=0):

    keys = ('a', 'b')
    choices_dict = {'a': ('a1', 'a2'), 'b': ('b1', 'b2')}

    panel = eg.ConfigPanel()
    keyCtrl = panel.Choice(key_idx, choices=keys)
    valueCtrl = panel.Choice(value_idx, choices=choices_dict[key_idx])

    panel.AddLine(keyCtrl, valueCtrl)
    while panel.Affirmed():
        panel.SetResult(keyCtrl.GetValue(),
                        valueCtrl.GetValue())
Any help is much appreciated.

Thanks :-)
KB

krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

Re: Dependent/variable configure dialog

Post by krambriw » Thu Oct 22, 2015 5:28 am

I think this will answer all you need

http://eventghost.net/forum/viewtopic.php?f=10&t=3269

KB_
Posts: 4
Joined: Tue Oct 13, 2015 11:11 pm

Re: Dependent/variable configure dialog

Post by KB_ » Fri Oct 23, 2015 2:24 pm

Perfect, that's exactly what I need.
Thanks a lot! :-)

Post Reply