[wxPython-users] Re: how do I start PyCrust?
Robin Dunn
robin at alldunn.com
Fri Jun 8 11:26:28 PDT 2007
7stud wrote:
> Robin Dunn <robin <at> alldunn.com> writes:
>
>> Try calling app.frame.SendSizeEvent().
>
> Ok. I closed out the pycrust and program windows, and I did another pywrap,
> and this time instead of typing:
>
>>>> app.frame.panel.Refresh()
>
> I typed in:
>
>>>> app.frame.SendSizeEvent()
>
> and that caused the whole window to turn blue. Now my question is this: why
> does "wxPython in Action" say to do a Refresh() instead of a SendSizeEvent()?
Because a few things have changed since that chapter was written, and
there is also a bit of differences between platforms here.
>
>> It's not a painting problem, it is a sizing problem. You're leaving
>>
> panel at the default (very small) size, and the frame's auto size magic
>> only happens when the frame gets a size event.
>
> I don't know what that means or what "auto size magic" is.
The magic is the fact that if frames have a single child window they
will automatically resize it to fill the client area of the frame. That
happens in the frame's default EVT_SIZE handler.
> I did try using
> SetMinSize() on the panel before making by original post because in my limited
> experience when nothing is in a panel, it shrinks to 0.
Only if it is in a sizer.
>
>> But since the frame is
>> already shown it doesn't get a size event at this point in time.
>
> Right. So are you saying the only way to make a window redraw itself once
> it's displayed is with a size event(assuming it doesn't get covered and
> uncovered by another window)? In other words, Refresh() doesn't and shouldn't
> work?
No. Refresh is working fine. It's just that in your example the panel
has no size so you when it is refreshed there is nothing to see. Try
calling the panel's GetSize() to see what I mean. Then in another test
run create the panel with an explicit size and then you'll see the
colour when you set it.
panel = wx.Panel(app.frame, size=(100,100))
> Also, why is it that after the panel is repainted blue, I am able to
> use SetBackgroundColour() to change the panel to the color red without having
> to do a SendSizeEvent()?
Because by that point in time the panel has been resized so it fills the
frame and so you are able to see it.
--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!
More information about the wxpython-users
mailing list