Settings divided in tabs

Do you have questions about writing plugins or scripts in Python? Meet the coders here.
Post Reply
krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

Settings divided in tabs

Post by krambriw » Thu Mar 04, 2010 12:56 pm

Hi,

Has someone experience in how to divide/split settings in a configuration dialogue for a plug-in or action into a tabbed view?

Using as example wx.Notebook???

I have too many settings in the view and need to clean up/organise it better

Best regards, Walter

stottle
Plugin Developer
Posts: 636
Joined: Sun Apr 26, 2009 10:59 pm

Re: Settings divided in tabs

Post by stottle » Fri Mar 05, 2010 10:44 pm

You probably had a hard time finding info because you were searching the wrong terms. wxWidgets calls them notebooks, not tabs. Here's some info.

Brett

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

Re: Settings divided in tabs

Post by krambriw » Sat Mar 06, 2010 11:10 am

Brett, thanks, I did find that page in the meantime

Hope you can advice me further with my next steps

I have attached a simple working plug-in sample based on the one that is described at our forum in the developer documentation and with the addition of a wx.Notebook in the settings for the action

From here I would like to do the following:

- make it possible to use eg's own SpinIntCtrl and SpinNumCtrl on the notebook pages
- have action settings distributed on several notebook pages and return them back to the action class when changed

Any advice is very appreciated

Best regards & thanks for your help,
Walter
SimpleNoteBook.zip
(1.11 KiB) Downloaded 247 times

stottle
Plugin Developer
Posts: 636
Joined: Sun Apr 26, 2009 10:59 pm

Re: Settings divided in tabs

Post by stottle » Sat Mar 06, 2010 3:23 pm

Walter,

Sorry, I'm not an expert on wxWidgets. Here's the best I can offer.
krambriw wrote: - make it possible to use eg's own SpinIntCtrl and SpinNumCtrl on the notebook pages
- have action settings distributed on several notebook pages and return them back to the action class when changed
#1 I don't think is a problem, as eg's UI classes are just wrappers around the wxWidgets classes.
#2 is more tricky. The problem is that the notebook tabs aren't instantiated until they are opened. So any variables defined on them won't be assigned unless the user actually looks at the tab. Now since the plugin passes in all of the initial values, you should be ok using them (they are non-local variables). Just make sure the settings effect the non-local values and I think you'll be ok.

Brett

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

Re: Settings divided in tabs

Post by krambriw » Sat Mar 06, 2010 8:00 pm

#1 I don't think is a problem, as eg's UI classes are just wrappers around the wxWidgets classes
When I try to add something like p = self.SpinIntCtrl(....) in one of the wx.Panel classes I get an error message that it is not an attribute of the page object

Also p = eg.SpinIntCtrl(....) gives a lot of error messages
#2 is more tricky. The problem is that the notebook tabs aren't instantiated until they are opened. So any variables
Do you have a code sample? Shall I have the action variables in the init of the page? Like
def __init__(self, parent, action.Variable1, action.Variable2, etc)

I feel I'm not clever enough for this...

It would be so simple, and it would make sense, that the eg.ConfigPanel would support multiple tabs itself....

Best regards & thanks,
Walter

stottle
Plugin Developer
Posts: 636
Joined: Sun Apr 26, 2009 10:59 pm

Re: Settings divided in tabs

Post by stottle » Sat Mar 06, 2010 11:47 pm

Sorry, I can't provide much more help without building it myself. I'm not an expert in wxWidgets.
krambriw wrote:Also p = eg.SpinIntCtrl(....) gives a lot of error messages
This would be the form you need.
krambriw wrote:Do you have a code sample?
Check out EG's about dialog class, it uses a notebook.
krambriw wrote:Shall I have the action variables in the init of the page? Like
def __init__(self, parent, action.Variable1, action.Variable2, etc)
I'm not sure what you mean by action.Variable one.

A simple class might look like this:

Code: Select all

class MyAction(eg.ActionClass):
    name = "MyAction"
    description = "Does my action"

    def __call__(self, myString="Hello"):
        print myString
    def Configure(self, myString="Hello"):
        panel = eg.ConfigPanel(self)
        ....
        while panel.Affirmed():
            panel.SetResult(ctrl.GetValue())
In this case, ctrl is whichever control you have the let's the user set the value. The problem is that if that control is part of a tab that isn't opened, it won't be defined.

So instead, you need to bind the control to a function that sets (in my example) myString = ctrl.GetValue(). You know ctrl will exist, because the bound function won't be called unless the tab is open. And since myString isn't local, it will be available for panel.SetResult:

Code: Select all

        while panel.Affirmed():
            panel.SetResult(myString)
Get the idea?

Brett

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

Re: Settings divided in tabs

Post by krambriw » Sun Mar 07, 2010 9:35 am

Thanks Brett, I'm actually giving up on this trial, I could not make it work even after extensive attempts... :(

Another approach which I think would also be better is to see if one could modify the ConfigPanel.py to support multiple setting pages

It was fairly easy to add another page simply by adding this line

Code: Select all

        dialog.notebook.AddPage(self, "SettingsII")
However, next problem would be to define on what page the various settings should "land"

With something like this in my dreams

Code: Select all

panel = eg.ConfigPanel(3) #The number defines the number of setting pages to initiate
.
.
.
    panel(0).sizer.Add(sizer_0, 0, wx.EXPAND)
    panel(1).sizer.Add(sizer_1, 0, wx.EXPAND)
    panel(2).sizer.Add(sizer_2, 0, wx.EXPAND)



...but I believe this will be impossible now when Bitmonster says he left the project :(


Best regards, Walter

stottle
Plugin Developer
Posts: 636
Joined: Sun Apr 26, 2009 10:59 pm

Re: Settings divided in tabs

Post by stottle » Sun Mar 07, 2010 1:48 pm

You may not be aware, I am creating a fork of EventGhost. One of the changes is to switch from wxWidgets to PyQt. Couple nice things about PyQt
it has a nice UI (Qt Designer) for building your own UIs
the syntax is (in my opinion) cleaner. Bitmonster created a bunch of small wrapper classes about wx widgets - this isn't necessary with PyQt, I just use their classes. So there's no need to modify the core to build what you want

So I agree that adding notebooks to the EG core probably won't happen, there should be another option at some point.

Brett

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

Re: Settings divided in tabs

Post by krambriw » Tue Mar 09, 2010 4:12 pm

Hi Brett, sounds interesting

BTW I hope you preserve the backward compatibility. Would be nice (required) that existing eg plugins will work without modification

BestR Walter

Post Reply