I need some help with sizers/wxPanel

All I want a simple window with a button on the bottom-right. The problem is the fact that the panel doesn't appear...(I made it red so I wouldn't miss it) :smiley:
What am I missing? where can I find more about the layout of components, about the relationship between wxPanel and the components that it holds and where do the sizers fit in all this mess?

Relevant bits:

class MainFrame(wxFrame):
     def __init__(self, parent, id, title):
         wxFrame.__init__(self, parent, -1, title, style=wxDEFAULT_FRAME_STYLE|wxNO_FULL_REPAINT_ON_RESIZE)
         self.ie = wxIEHtmlWin(self, -1, style = wxNO_FULL_REPAINT_ON_RESIZE)
         self.panel = ColoredPanel(self, wxRED)
         self.exit = wxButton(self.panel, -1, "Exit")

         box = wxBoxSizer(wxVERTICAL)
         box.Add(self.ie,1, wxEXPAND|wxALL)
         box.Add(self.panel,0, wxALIGN_BOTTOM|wxALIGN_RIGHT)
         self.SetSizer(box)
         self.SetAutoLayout(True)
         EVT_SIZE(self, self.OnSize)
         self.Show(1)

     def OnSize(self, evt):
         self.Layout()

class ColoredPanel(wxPanel):
     def __init__(self, parent, color):
         wxPanel.__init__(self, parent, -1, style = wxSIMPLE_BORDER)
         self.SetBackgroundColour(color)

Peter Damoc wrote:

All I want a simple window with a button on the bottom-right. The problem is the fact that the panel doesn't appear...(I made it red so I wouldn't miss it) :smiley:
What am I missing? where can I find more about the layout of components, about the relationship between wxPanel and the components that it holds and where do the sizers fit in all this mess?

A) When you post code, try to post a compete mini application, that way it's easy for us to test and modify your code.

B) Try not to use platfrom specific widgets (wxIEHTMLWin), so folks using other platfroms can help you

C) read:
http://wiki.wxpython.org/index.cgi/UsingSizers

and

http://wiki.wxpython.org/index.cgi/wxDesigner_20Sizer_20Tutorial

D) The very short version:

a wx.Panel is is a wx.Window that is used to hold collections of other controls. It is the parent of those controls and handles tab traversal, and probably other handy features.

a wx.Sizer is a object (NOT a wx.Window) that handles the sizing and positioning of controls. They are not the parents of controls, and they do not handle tab traversal or anything else.

E) As for your code:

1) I translated to the new style:

import wx

as that's what we all should be doing now.

2) I put a regular panel in, instead of a wxIEHtmlWin, as I am running Linux.

3) If you want just the wxIEHtmlWin and a button, you don't need another panel. If the plan is to put more buttons there, and have the panel have some use other than what it's doing here, then you probably want to put the button on the panel in a derived class, like your ColoredPanel.

4) You shouldn't need the ONSize handler, that should be covered by the SetSizer() call.

5) You use the wx.ALL flag, which spedcifies that you wqnt a border all the way around, but you didn't specify a border width

6) You havn't done any sizing of the button on the panel, so the panel is by default small, (20X20) on my system, but maybe even 0X0 on another, which may be why you don't see it.

Enclosed are two versions:

SimpleSizer.py : Just the panel and a button on the frame

SimpleSizer2.py: two panels on the frame, one with a button. This makes little sense if you have just the one button, but if you put multiple controls on it, it might.

-Chris

SimpleSizer.py (1022 Bytes)

SimpleSizer2.py (1.78 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

Chris,
First let me say "domo arigato gozaimas" :smiley: Your reply was more than I imagined. Thanks!

Now about the wxIEHTMLWin, what I'm trying to do is some kind of presentation app, like a "promo" app and I need to have a movie displayed in that app. The user must be able to control the movie (start/stop+ slider) and the only thing I could think of was a webpage with MediaPlayer controls... the movies are divx encoded. Is there another way I can accomplish my task?

Thanks,
Peter.