Stacking windows

I need to stack two windows and programmatically select the one that is
visible. In response to my first posting, several people suggested that I
could use a Notebook, Choicebook, or Listbook. All of these provide a
visible means of selecting the visible window, which I do not want. Is
there a way to turn off the visible selection means? I see styles for
deciding where to position the selection means but not for eliminating
them.

If there is no way to turn off the visible selection means in the various
books, another approach that might work would be to create the second
window (a ListCtrl) and give it the same size and position as the first.
Then I would use Show() to control which one is visible. However, I don't
see a good way to use a sizer to control the layout. I am thinking that I
would have to lay out the controls first without the overlay window and
then create, size, and position the overlay afterward based on the position
of its companion. This approach seems inelegant, at least.

A more elegant solution along this line would be to create a stack class
that manages the two (or more) windows. However, I would need to be able
to add a stack instance to a sizer and have the stack do the right thing
for the sizer and for the stack's managed windows. Perhaps the first
requirement would be met by having the stack class inherit from the right
class (Window? Control?). Before I pursue this line, I would appreciate
feedback on whether a book could be made to work as that approach would be
simple. Failing that, does this other idea make sense?

···

--
Jeffrey Barish

Jeffrey Barish wrote:

I need to stack two windows and programmatically select the one that is
visible.

This isn't very hard, and yes, you can use sizers.

A more elegant solution along this line would be to create a stack class
that manages the two (or more) windows. However, I would need to be able
to add a stack instance to a sizer and have the stack do the right thing
for the sizer and for the stack's managed windows. Perhaps the first
requirement would be met by having the stack class inherit from the right
class (Window? Control?).

wx.Panel

> Before I pursue this line, I would appreciate

feedback on whether a book could be made to work as that approach would be
simple. Failing that, does this other idea make sense?

I'd take a look at Andrea's new notebook class. I think it's all written in Python, and you could hack the code to not show the tabs.

I've also enclosed a simple example, but it doesn't use Sizers. You may be able to build from there. Sizers have a method something like Hide() and Show(), look in the docs.

I've got another app that does it with Sizers, but it depends on some other modules of mine, I'll send it to you if you want.

-Chris

ChangePanel.py (2.4 KB)

···

--
Christopher Barker, Ph.D.
Oceanographer
                                         
NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@noaa.gov

Christopher Barker wrote:

Jeffrey Barish wrote:

I need to stack two windows and programmatically select the one that is
visible.

This isn't very hard, and yes, you can use sizers.

A more elegant solution along this line would be to create a stack class
that manages the two (or more) windows. However, I would need to be able
to add a stack instance to a sizer and have the stack do the right thing
for the sizer and for the stack's managed windows. Perhaps the first
requirement would be met by having the stack class inherit from the right
class (Window? Control?).

Here's a template for what I had in mind. I get a TypeError regardless of
what WinStack inherits from. How do I define the class so that it is
possible to pass it to the sizer's Add function? Is there a way for me to
specify that the WinStack class should respond to sizing requests by
passing them to the first window in windowList? If I can get the initial
sizing to work, then I would create another method to set the size and
position of the second window to match the size and position of the first
one (although I would prefer that it happen automatically as part of the
sizing operation).

Are there examples of how to derive a class from wxSizer (or wxPySizer)(if
that is what I need to do)? I may use Andrea's NotebookCtrl, but it has
way more functionality than I need and it seems as if it should be easy to
get this WinStack class to work.

wx-test6c.py (2.27 KB)

···

--
Jeffrey Barish

Jeffrey Barish wrote:

Here's a template for what I had in mind. I get a TypeError regardless of
what WinStack inherits from.

WinStack should inherit from wx.Panel, Panels are windows that you put other Windows on. However, you problem is that you didn't call the constructor of the superclass:

class WinStack(wx.Panel):
     '''Class for two stacking frames.'''

     def __init__(self, *args, **kwargs):
         wx.Panel.__init__(self, *args, **kwargs)
         self.windowList =
         self.currentWin = None

And you need to have a parent for a window:
         self.winstack = WinStack(self)

It still doesn't work right, but it doesn't crash either.

What you probably want to do is put a Sizer on WinStack, and manage it there.

I've enclosed a little app I wrote that does much of what you want, though I didn't encapsulate the swapable Windows -- that is a good idea though.

-Chris

   How do I define the class so that it is

Converter (7.17 KB)

UnitConversion.py (11.3 KB)

···

possible to pass it to the sizer's Add function? Is there a way for me to
specify that the WinStack class should respond to sizing requests by
passing them to the first window in windowList? If I can get the initial
sizing to work, then I would create another method to set the size and
position of the second window to match the size and position of the first
one (although I would prefer that it happen automatically as part of the
sizing operation).

Are there examples of how to derive a class from wxSizer (or wxPySizer)(if
that is what I need to do)? I may use Andrea's NotebookCtrl, but it has
way more functionality than I need and it seems as if it should be easy to
get this WinStack class to work.

------------------------------------------------------------------------

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

--
Christopher Barker, Ph.D.
Oceanographer
                                         
NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@noaa.gov