[wxPython] The impossible sizers of doom

Looking at the console window, it looks like OnPaint() is getting called
continuously. Does that seem right?

I was unable to get it to show anything other than gray panels the
moment I attempted to either resize or move the window.

···

----------
Keith J. Farmer
kfarmer@thuban.org
http://www.thuban.org

-----Original Message-----
From: Chris Barker [mailto:Chris.Barker@noaa.gov]
Sent: Monday, February 25, 2002 11:16

I forgot to enclose the code I promised in my last message:

Looking at the console window, it looks like OnPaint() is getting called
continuously. Does that seem right?

That happens on MSW if a wxPaintDC is not created for the window the event
was sent to.

Here's a little simpler version of the sample that doesn't have that
problem:

from wxPython.wx import *

ID_ABOUT = 101
ID_EXIT = 102

class MyFrame(wxFrame):
    def __init__(self, parent, ID, title):
        wxFrame.__init__(self, parent, ID, title,
                         wxDefaultPosition, wxSize(200, 150))

        self.panel1 = wxPanel(self,-1,wxDefaultPosition, (100,100),
wxSUNKEN_BORDER)
        self.panel2 = wxPanel(self,-1,wxDefaultPosition, (100,100),
wxSUNKEN_BORDER)

        self.panel1.SetBackgroundColour("BLUE")
        self.panel2.SetBackgroundColour("RED")

        box = wxBoxSizer(wxVERTICAL)
        box.Add(self.panel1, 1, wxEXPAND)
        box.Add(self.panel2, 1, wxEXPAND)
        box.Fit(self)

        self.SetAutoLayout(true)
        self.SetSizer(box)

class MyApp(wxApp):
    def OnInit(self):
        frame = MyFrame(NULL, -1, "Sizer Test")
        frame.Show(true)
        self.SetTopWindow(frame)
        return true

app = MyApp(0)
app.MainLoop()