Stacking Panels

classic Classic list List threaded Threaded
16 messages Options
Reply | Threaded
Open this post in threaded view
|

Stacking Panels

Josh English
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
[hidden email]
http://www.joshuarenglish.com

--
To unsubscribe, send email to [hidden email]
or visit http://groups.google.com/group/wxPython-users?hl=en
C M
Reply | Threaded
Open this post in threaded view
|

Re: Stacking Panels

C M
On Tue, May 15, 2012 at 1:03 PM, Josh English
<[hidden email]> 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 [hidden email]
or visit http://groups.google.com/group/wxPython-users?hl=en
Reply | Threaded
Open this post in threaded view
|

Re: Stacking Panels

Mike Driscoll
In reply to this post by Josh English
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
[hidden email]
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 [hidden email]
or visit http://groups.google.com/group/wxPython-users?hl=en
Reply | Threaded
Open this post in threaded view
|

Re: Stacking Panels

Paul Wiseman
On 15 May 2012 20:55, Mike Driscoll <[hidden email]> 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
[hidden email]
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 [hidden email]
or visit http://groups.google.com/group/wxPython-users?hl=en


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)

--
To unsubscribe, send email to [hidden email]
or visit http://groups.google.com/group/wxPython-users?hl=en
Reply | Threaded
Open this post in threaded view
|

Re: Stacking Panels

Josh English
In reply to this post by C M
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 <[hidden email]> wrote:
On Tue, May 15, 2012 at 1:03 PM, Josh English
<[hidden email]> 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 [hidden email]
or visit http://groups.google.com/group/wxPython-users?hl=en



--
Josh English
[hidden email]
http://www.joshuarenglish.com

--
To unsubscribe, send email to [hidden email]
or visit http://groups.google.com/group/wxPython-users?hl=en
Reply | Threaded
Open this post in threaded view
|

Re: Stacking Panels

Josh English
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 <[hidden email]> 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 <[hidden email]> wrote:
On Tue, May 15, 2012 at 1:03 PM, Josh English
<[hidden email]> 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 [hidden email]
or visit http://groups.google.com/group/wxPython-users?hl=en






--
Josh English
[hidden email]
http://www.joshuarenglish.com

--
To unsubscribe, send email to [hidden email]
or visit http://groups.google.com/group/wxPython-users?hl=en
Reply | Threaded
Open this post in threaded view
|

Re: Stacking Panels

Paul Wiseman
On 16 May 2012 23:12, Josh English <[hidden email]> 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.


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.

--
To unsubscribe, send email to [hidden email]
or visit http://groups.google.com/group/wxPython-users?hl=en
Reply | Threaded
Open this post in threaded view
|

Re: Stacking Panels

Paul Wiseman
In reply to this post by Josh English
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 :) 

--
To unsubscribe, send email to [hidden email]
or visit http://groups.google.com/group/wxPython-users?hl=en

paneladder.py (2K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Stacking Panels

sebastian lópez
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 <Colombia>

2012/5/17 Paul <[hidden email]>
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 :) 

--
To unsubscribe, send email to [hidden email]
or visit http://groups.google.com/group/wxPython-users?hl=en



--
Sebastián López
Ingeniero Químico


--
To unsubscribe, send email to [hidden email]
or visit http://groups.google.com/group/wxPython-users?hl=en

paneladder.py (3K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Stacking Panels

Mike Driscoll
In reply to this post by Paul Wiseman
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 :) 


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 [hidden email]
or visit http://groups.google.com/group/wxPython-users?hl=en
Reply | Threaded
Open this post in threaded view
|

Re: Stacking Panels

Paul Wiseman
On 17 May 2012 14:36, Mike Driscoll <[hidden email]> 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 :) 


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 [hidden email]
or visit http://groups.google.com/group/wxPython-users?hl=en

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.

--
To unsubscribe, send email to [hidden email]
or visit http://groups.google.com/group/wxPython-users?hl=en
Reply | Threaded
Open this post in threaded view
|

Re: Stacking Panels

Paul Wiseman
In reply to this post by sebastian lópez
On 17 May 2012 12:16, sebastián <[hidden email]> 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 <Colombia>

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

--
To unsubscribe, send email to [hidden email]
or visit http://groups.google.com/group/wxPython-users?hl=en
Reply | Threaded
Open this post in threaded view
|

Re: Stacking Panels

Josh English
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
[hidden email]
http://www.joshuarenglish.com

--
To unsubscribe, send email to [hidden email]
or visit http://groups.google.com/group/wxPython-users?hl=en
Reply | Threaded
Open this post in threaded view
|

Re: Stacking Panels

Josh English
On Fri, May 18, 2012 at 10:53 AM, Josh English <[hidden email]> wrote:
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
[hidden email]
http://www.joshuarenglish.com

--
To unsubscribe, send email to [hidden email]
or visit http://groups.google.com/group/wxPython-users?hl=en

xmldbEditorStack.py (9K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Stacking Panels

Mike Driscoll
Hi Josh,

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 <[hidden email]> wrote:
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
[hidden email]
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

--
To unsubscribe, send email to [hidden email]
or visit http://groups.google.com/group/wxPython-users?hl=en
Reply | Threaded
Open this post in threaded view
|

Re: Stacking Panels

Josh English


On Fri, May 18, 2012 at 1:59 PM, Mike Driscoll <[hidden email]> 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

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.

--
Josh English
[hidden email]
http://www.joshuarenglish.com

--
To unsubscribe, send email to [hidden email]
or visit http://groups.google.com/group/wxPython-users?hl=en