Opened 5 years ago

Last modified 5 years ago

#10748 confirmed enhancement

Freeze/Thaw logic on wxMSW

Reported by: Infinity77 Owned by:
Priority: low Milestone:
Component: wxMSW Version: 2.8.x
Keywords: Freeze, Thaw, TLW Cc:
Blocked By: Blocking:
Patch: no

Description

Hello,

in order to reduce flicker when adding a bunch of controls to a frame or TLW, the standard practice is to call:

frame.Freeze()
Add_Lots_Of_Controls()
frame.Thaw()

However, if for some reason the creation of the controls is slow (many tabs in a notebook, a panel with many complex widgets on it and so on), the controls end up being seen even though the parent is frozen. Usually you can see a small blinking square/rectangle in the top-left area of a frozen TLW while the widgets are created.

The general consensus on the wxPython mailing list is that, between the call to Freeze and the call to Thaw no drawing, no painting, no visible layouting, no glitches, no nothing should be visible in the client area of the window for which Freeze and Thaw have been invoked. It looks like nothing special is being done for new windows that are created with frozen parents.

Quoting Robin:

One way to work around that is to create the new windows hidden, which I think is able to be done using 2-phase create like this:

       p = wx.PrePanel()
       p.Hide()
       p.Create(parent, ...)

Then do p.Show() later when you are ready to thaw everything.

I agree though that it would make sense that a new widget created with a frozen parent should start out in a frozen state.

I am not sure if this applies to wxMSW only, please someone correct my tags if this is not so.

Thank you.

Andrea.

Change History (4)

comment:1 Changed 5 years ago by vadz

  • Priority changed from normal to low
  • Status changed from new to confirmed
  • Type changed from defect to enhancement

Yes, it would be better to create the controls hidden if their parent is frozen. But the trouble is that we'd need to determine whether they need to be shown or not when the parent is thawed. And it's very easy to create a (hidden) child panel in the frame and create all controls as its children even right now so I don't consider this to be a big problem.

I also don't think this is MSW-specific but I didn't test this under other platforms.

comment:2 follow-up: Changed 5 years ago by wxsite

Is it possible to create the controls in a frozen state if the parent is frozen?

comment:3 in reply to: ↑ 2 Changed 5 years ago by vadz

Replying to wxsite:

Is it possible to create the controls in a frozen state if the parent is frozen?

I guess it is but I don't think it's going to help much, while the controls contents won't flicker the controls themselves still would (especially if they are being (re)laid out). But I didn't test this, maybe doing this would indeed be enough to fix the problem in practice.

comment:4 Changed 5 years ago by jdog

#11569 is related, or same.

Note: See TracTickets for help on using tickets.