Stacking Panels

My memory may be hallucinating on me here…

I remember some time ago seeing some code for a panel stack, that is, a bunch of panels that take up the same space on screen, but can me moved to the top of the stack.

My Google-Fu is failing me here. Does anyone remember this?

I’m asking because I am building an editor for an XML data file. The file has about four levels of complex, repeatable children, and I want the editors for these children and grandchildren to be manageable, and to appear as needed without creating several layers of modal dialog boxes.

···


Josh English
Joshua.R.English@gmail.com
http://www.joshuarenglish.com

Is it WidgetStack from Andrea?
http://xoomer.virgilio.it/infinity77/main/WidgetStack.html

···

On Tue, May 15, 2012 at 1:03 PM, Josh English <joshua.r.english@gmail.com> wrote:

My memory may be hallucinating on me here...

I remember some time ago seeing some code for a panel stack, that is, a
bunch of panels that take up the same space on screen, but can me moved to
the top of the stack.

My Google-Fu is failing me here. Does anyone remember this?

Hi Josh,

···

On Tuesday, May 15, 2012 12:03:26 PM UTC-5, Josh English wrote:

My memory may be hallucinating on me here…

I remember some time ago seeing some code for a panel stack, that is, a bunch of panels that take up the same space on screen, but can me moved to the top of the stack.

My Google-Fu is failing me here. Does anyone remember this?

I’m asking because I am building an editor for an XML data file. The file has about four levels of complex, repeatable children, and I want the editors for these children and grandchildren to be manageable, and to appear as needed without creating several layers of modal dialog boxes.


Josh English
Joshua.R.English@gmail.com
http://www.joshuarenglish.com

I wrote an article on panel switching a while back that might work: wxPython: How to Switch Between Panels - Mouse Vs Python

My blog seems to be down right now though, so you might not be able to check that out for a few minutes.

  • Mike

You can do this be placing all the panels in a BoxSizer and only Show()ing one at a time, calling Hide() on all the others. Can put this in a single method with something like this

ShowLevel(level):

self.panel1.Show(level==1)

self.panel2.Show(level==2)

self.panel3.Show(level==3)

self.panel4.Show(level==4)

···

On 15 May 2012 20:55, Mike Driscoll kyosohma@gmail.com wrote:

Hi Josh,

On Tuesday, May 15, 2012 12:03:26 PM UTC-5, Josh English wrote:

My memory may be hallucinating on me here…

I remember some time ago seeing some code for a panel stack, that is, a bunch of panels that take up the same space on screen, but can me moved to the top of the stack.

My Google-Fu is failing me here. Does anyone remember this?

I’m asking because I am building an editor for an XML data file. The file has about four levels of complex, repeatable children, and I want the editors for these children and grandchildren to be manageable, and to appear as needed without creating several layers of modal dialog boxes.


Josh English
Joshua.R.English@gmail.com
http://www.joshuarenglish.com

I wrote an article on panel switching a while back that might work: http://www.blog.pythonlibrary.org/2010/06/16/wxpython-how-to-switch-between-panels/

My blog seems to be down right now though, so you might not be able to check that out for a few minutes.

  • Mike

To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com

or visit http://groups.google.com/group/wxPython-users?hl=en

That’s the one I was thinking of.

Sadly, it crashes on one of my platforms (PortablePython).

···

On Tue, May 15, 2012 at 12:30 PM, C M cmpython@gmail.com wrote:

On Tue, May 15, 2012 at 1:03 PM, Josh English > > joshua.r.english@gmail.com wrote:

My memory may be hallucinating on me here…

I remember some time ago seeing some code for a panel stack, that is, a

bunch of panels that take up the same space on screen, but can me moved to

the top of the stack.

My Google-Fu is failing me here. Does anyone remember this?

Is it WidgetStack from Andrea?

http://xoomer.virgilio.it/infinity77/main/WidgetStack.html

To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com

or visit http://groups.google.com/group/wxPython-users?hl=en


Josh English

Joshua.R.English@gmail.com
http://www.joshuarenglish.com

Mike and Paul,

Thanks. I read the article and liked it.

But…

upon further consideration of what I really need, I think what I really need a way to create and destroy my sub-editor panels dynamically. Because the objects being edited are passed back and forth through Validators, I need a good way to track which bit is being edited at any given time.

I would love to be able to create a panel, slide it over the current panel, but that’s GUI sugar I don’t think I can do just yet.

···

On Wed, May 16, 2012 at 3:06 PM, Josh English joshua.r.english@gmail.com wrote:

That’s the one I was thinking of.

Sadly, it crashes on one of my platforms (PortablePython).

On Tue, May 15, 2012 at 12:30 PM, C M cmpython@gmail.com wrote:

On Tue, May 15, 2012 at 1:03 PM, Josh English > > > > joshua.r.english@gmail.com wrote:

My memory may be hallucinating on me here…

I remember some time ago seeing some code for a panel stack, that is, a

bunch of panels that take up the same space on screen, but can me moved to

the top of the stack.

My Google-Fu is failing me here. Does anyone remember this?

Is it WidgetStack from Andrea?

http://xoomer.virgilio.it/infinity77/main/WidgetStack.html

To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com

or visit http://groups.google.com/group/wxPython-users?hl=en


Josh English

Joshua.R.English@gmail.com
http://www.joshuarenglish.com


Josh English
Joshua.R.English@gmail.com
http://www.joshuarenglish.com

You can add panels to sizers later after some time, if you stored the references in a list or a dictionary you could loop over them and call Show(True) on the one you want to show and Show(False) on the rest.

···

On 16 May 2012 23:12, Josh English joshua.r.english@gmail.com wrote:

Mike and Paul,

Thanks. I read the article and liked it.

But…

upon further consideration of what I really need, I think what I really need a way to create and destroy my sub-editor panels dynamically. Because the objects being edited are passed back and forth through Validators, I need a good way to track which bit is being edited at any given time.

I would love to be able to create a panel, slide it over the current panel, but that’s GUI sugar I don’t think I can do just yet.

Don’t think I explained it that well, but I put together a quick demo which should show you what I meant. There’s a bit of problem with the combo box if you show or remove with nothing selected in the combo but you can ignore that :slight_smile:

paneladder.py (2.5 KB)

···

On Wednesday, 16 May 2012 23:12:15 UTC+1, Josh English wrote:

Mike and Paul,

Thanks. I read the article and liked it.

But…

upon further consideration of what I really need, I think what I really need a way to create and destroy my sub-editor panels dynamically. Because the objects being edited are passed back and forth through Validators, I need a good way to track which bit is being edited at any given time.

I would love to be able to create a panel, slide it over the current panel, but that’s GUI sugar I don’t think I can do just yet.

Goog morning

I made some minor changes to your script

by comparing if the selected item is u’’ it’s

an empty unicode string.

I hope your problem is solved

Best Regards

Sebastián López Buritica

paneladder.py (2.81 KB)

···

2012/5/17 Paul poalman@gmail.com

On Wednesday, 16 May 2012 23:12:15 UTC+1, Josh English wrote:

Mike and Paul,

Thanks. I read the article and liked it.

But…

upon further consideration of what I really need, I think what I really need a way to create and destroy my sub-editor panels dynamically. Because the objects being edited are passed back and forth through Validators, I need a good way to track which bit is being edited at any given time.

I would love to be able to create a panel, slide it over the current panel, but that’s GUI sugar I don’t think I can do just yet.

Don’t think I explained it that well, but I put together a quick demo which should show you what I meant. There’s a bit of problem with the combo box if you show or remove with nothing selected in the combo but you can ignore that :slight_smile:

To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com

or visit http://groups.google.com/group/wxPython-users?hl=en


Sebastián López

Ingeniero Químico

Hi,

···

On Thursday, May 17, 2012 6:07:47 AM UTC-5, Paul wrote:

On Wednesday, 16 May 2012 23:12:15 UTC+1, Josh English wrote:

Mike and Paul,

Thanks. I read the article and liked it.

But…

upon further consideration of what I really need, I think what I really need a way to create and destroy my sub-editor panels dynamically. Because the objects being edited are passed back and forth through Validators, I need a good way to track which bit is being edited at any given time.

I would love to be able to create a panel, slide it over the current panel, but that’s GUI sugar I don’t think I can do just yet.

Don’t think I explained it that well, but I put together a quick demo which should show you what I meant. There’s a bit of problem with the combo box if you show or remove with nothing selected in the combo but you can ignore that :slight_smile:

I don’t really see that much difference between this and the article I wrote. However, if you need to pass data around between different classes, I highly recommend looking at pubsub. Here’s one tutorial I wrote: http://www.blog.pythonlibrary.org/2010/06/27/wxpython-and-pubsub-a-simple-tutorial/

  • Mike

The idea’s the same as in your tutorial, i did reply initially before checking it out though. The demo just shows how you can create and destroy panels dynamically.

···

On 17 May 2012 14:36, Mike Driscoll kyosohma@gmail.com wrote:

Hi,

On Thursday, May 17, 2012 6:07:47 AM UTC-5, Paul wrote:

On Wednesday, 16 May 2012 23:12:15 UTC+1, Josh English wrote:

Mike and Paul,

Thanks. I read the article and liked it.

But…

upon further consideration of what I really need, I think what I really need a way to create and destroy my sub-editor panels dynamically. Because the objects being edited are passed back and forth through Validators, I need a good way to track which bit is being edited at any given time.

I would love to be able to create a panel, slide it over the current panel, but that’s GUI sugar I don’t think I can do just yet.

Don’t think I explained it that well, but I put together a quick demo which should show you what I meant. There’s a bit of problem with the combo box if you show or remove with nothing selected in the combo but you can ignore that :slight_smile:

I don’t really see that much difference between this and the article I wrote. However, if you need to pass data around between different classes, I highly recommend looking at pubsub. Here’s one tutorial I wrote: http://www.blog.pythonlibrary.org/2010/06/27/wxpython-and-pubsub-a-simple-tutorial/

  • Mike

To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com

or visit http://groups.google.com/group/wxPython-users?hl=en

Hm thanks, I get the error though when calling GetValue() on the combo when it’s empty

wx._core.PyAssertionError: C++ assertion “IsValid(n)” failed at /BUILD/wxPython-src-2.8.12.1/src/mac/carbon/choice.cpp(242) in GetString(): wxChoice::GetString(): invalid index

maybe this is just a mac thing

···

On 17 May 2012 12:16, sebastián selobu@gmail.com wrote:

Goog morning

I made some minor changes to your script

by comparing if the selected item is u’’ it’s

an empty unicode string.

I hope your problem is solved

Best Regards

Sebastián López Buritica

Thanks, all.

I’m still fighting a conceptual problem that I probably don’t really need to be fighting with, yet I am.

Because my data structure is tree-like, I’m working on the assumption that my GUI must also be tree-like. That could mean using a TreeCtrl, but also in how panels relate to one another.

Right now I’m getting by with modal dialog boxes because they are easy and one modal dialog can call another modal dialog.

I’m also using Validators to transfer information between these dialogs and their parents.

Here’s the brick wall:

If I have four separate panels to edit my data, in four separate classes, then I imagine the workflow as:

ParentNode is edited by ParentEditor. Clicking on a list representing certain ChildNodes brings up the ChildNode in a ChildEditor. Should this be a brand new instance of the ChildEditor, or a global instance? If I make a new instance (which seems easiest with Validators) and show it on top of the ParentEditor … and here’s where it gets confusing. The Frame needs to be the parent of all of these panels to easily show and hide them. Then I also have to keep track of a logical parent for each panel as they are created.

And I have to be able to control this (in this application) to at least four levels of the data tree.

I’ll try to whip up a more coherent sample.

Thanks for listening to me blither.

···


Josh English
Joshua.R.English@gmail.com

http://www.joshuarenglish.com

And here it is. The second editor comes up normally, but the controls aren’t responsive. This seems strange. I’m hiding the old panel, showing the new, attaching it to the sizer and telling the sizer to Layout(). Still, no reaction when I click on the text field or double click on an item in the listbox.

xmldbEditorStack.py (7.01 KB)

···

On Fri, May 18, 2012 at 10:53 AM, Josh English joshua.r.english@gmail.com wrote:

Thanks, all.

I’ll try to whip up a more coherent sample.


Josh English
Joshua.R.English@gmail.com
http://www.joshuarenglish.com

Hi Josh,

Thanks, all.

I’ll try to whip up a more coherent sample.

And here it is. The second editor comes up normally, but the controls aren’t responsive. This seems strange. I’m hiding the old panel, showing the new, attaching it to the sizer and telling the sizer to Layout(). Still, no reaction when I click on the text field or double click on an item in the listbox.


Josh English
Joshua.R.English@gmail.com
http://www.joshuarenglish.com

The reason it doesn’t work is because you have parenting issues going on. You already have a panel as the main panel for the Frame class. However, when you load the OpportunityPanel, you try to make it a “top level” panel too (for lack of a better term). Thus, you have two panels vying for the same space. You should make OpportunityPanel a child of the top panel like you did with the ScenePanel. I tried changing your code so that your panel init in the frame went from something like

panel = wx.Panel()

to

self.panel = wx.Panel()

and then changed line 209 to be

newp = panelClass(self.panel, dataparent)

Then it worked on my system.

  • Mike
···

On Friday, May 18, 2012 3:00:48 PM UTC-5, Josh English wrote:

On Fri, May 18, 2012 at 10:53 AM, Josh English joshua.r.english@gmail.com wrote:

heh. I think I even understand this.

Fixed it with an ugly ugly thing in line 214:

newp = panelClass(dataparent.Parent, dataparent)

And it worked.

Thanks for the metaphorical boot to the head.

···

On Fri, May 18, 2012 at 1:59 PM, Mike Driscoll kyosohma@gmail.com wrote:

The reason it doesn’t work is because you have parenting issues going on. You already have a panel as the main panel for the Frame class. However, when you load the OpportunityPanel, you try to make it a “top level” panel too (for lack of a better term). Thus, you have two panels vying for the same space. You should make OpportunityPanel a child of the top panel like you did with the ScenePanel. I tried changing your code so that your panel init in the frame went from something like

panel = wx.Panel()

to

self.panel = wx.Panel()

and then changed line 209 to be

newp = panelClass(self.panel, dataparent)

Then it worked on my system.

  • Mike


Josh English
Joshua.R.English@gmail.com

http://www.joshuarenglish.com