frame update

Hello,
In a frame I remove a sizer and destroy the widgets added to it,
and then I create new widgets, a new sizer, and add the new widgets to it.

That is followed by:

self.sizer.Fit(self)
self.sizer.SetSizeHints(self)
self.sizer.Layout()
self.Refresh()
self.Update()

It works, but my impression is that i can do with less.
It looks like the Layout one is essential, but otherwise,
which ones can i skip ?
which ones should I keep because of hidden features ?
What are their differences, especially between the last three ?
e

···


Egbert Bouwman [GMail]

Hi,

···

On Tue, Feb 22, 2011 at 4:15 PM, Egbert Bouwman egbert.bouwman@gmail.com wrote:

Hello,
In a frame I remove a sizer and destroy the widgets added to it,
and then I create new widgets, a new sizer, and add the new widgets to it.

That is followed by:

self.sizer.Fit(self)
self.sizer.SetSizeHints(self)

self.sizer.Layout()
self.Refresh()
self.Update()

It works, but my impression is that i can do with less.
It looks like the Layout one is essential, but otherwise,
which ones can i skip ?
which ones should I keep because of hidden features ?

What are their differences, especially between the last three ?
e

Egbert Bouwman [GMail]

I don’t see any reason to destroy the sizer. In my experience, deleting the items from the sizer using the sizer’s Remove() method is fine. After I delete or add widgets, I then call the widget’s parent’s Layout() method. So if all the widget’s parent is myPanel, then I call myPanel.Layout(). That’s it.

Mike Driscoll

Blog: http://blog.pythonlibrary.org

It depends a little on what you want to do:

  * If you want the frame to adjust its size to the new min-size of the items in the sizer then you want to keep the Fit, although I prefer self.Fit().

  * If you want the frame to not be resizable by the user to smaller than the min-size requested by the sizer then you want to keep the SetSizeHints.

* If the above are not true then you need to keep the Layout. Otherwise if there is anything that will cause the frame to change size (like the Fit) then you can not do the Layout because one will be done in the frame's EVT_SIZE handler.

Refresh will trigger a EVT_PAINT event to be sent to the window. It is almost certainly not needed here because the system will automatically send any paint events needed to draw the new widgets or any newly exposed space on the frame.

Update will cause any pending paint events to be handled immediately instead of when the paint event would normally be delivered.

···

On 2/22/11 2:15 PM, Egbert Bouwman wrote:

Hello,
In a frame I remove a sizer and destroy the widgets added to it,
and then I create new widgets, a new sizer, and add the new widgets to it.

That is followed by:

self.sizer.Fit(self)
self.sizer.SetSizeHints(self)
self.sizer.Layout()
self.Refresh()
self.Update()

It works, but my impression is that i can do with less.
It looks like the Layout one is essential, but otherwise,
which ones can i skip ?
which ones should I keep because of hidden features ?
What are their differences, especially between the last three ?
e

--
Robin Dunn
Software Craftsman