getting wxGLCanvas to fill a wxPanel, which fills a wxFrame

Sorry to bother folks with what seems a silly question, but my mind is going in
circles trying to figure out what I'm doing wrong here. I have a wxFrame.
This contains a wxPanel. The panel contains a wxGLcanvas. I want the
wxGLCanvas to resize with the frame, and to always fill it. As it is, it ends
up being a puny 10x10 pixels in the upper left.

If I plop the wxGLCanvas directly into the wxFrame, everything works
splendidly. The reason I want the wxPanel is along the lines of the last Q on
the Gtk FAQ... so I can bind keys to all of the contents of the frame (the
frame in Gtk does not receive key events).

I tried using a wxGridSizer for the Panel, and placed the wxEXPAND style
wherever I could think of, but nothing I do seems to get the wxGLCanvas to
budge and resize. Argh! Any help would be most appreciated.

···

--
Hanlon's Razor:
  Never attribute to malice that which is adequately explained by stupidity.

Here's the boilerplate for using sizers:

        sizer = wxBoxSizer( wxVERTICAL )
        sizer.Add( self.canvas, 1, wxEXPAND )
        self.SetSizer( sizer )
        self.SetAutoLayout(true)

Where self would be your wxPanel. (You can just use panel.SetSizer( sizer) and the like if you don't feel like sub-classing the wxPanel class). For safety, calling self.Layout() at the end is a good idea (it avoids problems if/when your code is transfered to a dialog).

HTH,
Mike

Maciej Kalisiak wrote:

···

Sorry to bother folks with what seems a silly question, but my mind is going in
circles trying to figure out what I'm doing wrong here. I have a wxFrame.
This contains a wxPanel. The panel contains a wxGLcanvas. I want the
wxGLCanvas to resize with the frame, and to always fill it. As it is, it ends
up being a puny 10x10 pixels in the upper left.

If I plop the wxGLCanvas directly into the wxFrame, everything works
splendidly. The reason I want the wxPanel is along the lines of the last Q on
the Gtk FAQ... so I can bind keys to all of the contents of the frame (the
frame in Gtk does not receive key events).

I tried using a wxGridSizer for the Panel, and placed the wxEXPAND style
wherever I could think of, but nothing I do seems to get the wxGLCanvas to
budge and resize. Argh! Any help would be most appreciated.

--
_______________________________________
  Mike C. Fletcher
  Designer, VR Plumber, Coder
  http://members.rogers.com/mcfletch/

Mike C. Fletcher wrote:

Here's the boilerplate for using sizers:

       sizer = wxBoxSizer( wxVERTICAL )
       sizer.Add( self.canvas, 1, wxEXPAND )
       self.SetSizer( sizer )
       self.SetAutoLayout(true)

FYI, since 2.4.0 (or maybe some 2.3.x, I don't remember) calling SetAutoLayout is redundant as SetSizer calls it now.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!