Flicker when rebuilding widget

Hello,

I have a widget which, during the runtime of the program, destroys all
its children and rebuilds new children. I noticed that there's a lot
of flicker when it does that, as if wxPython is showing me all the
intermediate steps, instead of freezing the old state until the new
state is ready.

Is there any way to avoid that?

Thanks,
Ram.

You said the magic word.

wx.Freeze()

... Do stuff.

wx.Thaw()

I think those are the right commands.

Josh

···

On Mon, Sep 27, 2010 at 3:27 PM, cool-RR <ram.rachum@gmail.com> wrote:

Hello,

I have a widget which, during the runtime of the program, destroys all
its children and rebuilds new children. I noticed that there's a lot
of flicker when it does that, as if wxPython is showing me all the
intermediate steps, instead of freezing the old state until the new
state is ready.

Is there any way to avoid that?

Thanks,
Ram.

--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

--
Josh English
Joshua.R.English@gmail.com

Yes! Awesome.

That's the true Python spirit. You have some functionality that you
need, you think of the word that will describe it most succinctly,
"freeze" in this case, and then find out it was a method on your
object all along :slight_smile:

Ram.

···

On Sep 28, 12:37 am, Josh English <joshua.r.engl...@gmail.com> wrote:

You said the magic word.

wx.Freeze()

... Do stuff.

wx.Thaw()

I think those are the right commands.

Josh

On Mon, Sep 27, 2010 at 3:27 PM, cool-RR <ram.rac...@gmail.com> wrote:
> Hello,

> I have a widget which, during the runtime of the program, destroys all
> its children and rebuilds new children. I noticed that there's a lot
> of flicker when it does that, as if wxPython is showing me all the
> intermediate steps, instead of freezing the old state until the new
> state is ready.

> Is there any way to avoid that?

> Thanks,
> Ram.

I have now tried to apply the Freeze/Thaw stuff to another, more
important place in my program: In the main Frame, which is managed by
PyAUI. Every time I start my program, all the widgets appear in one
ugly corner in the upper left of the screen. So I thought that to
prevent this I could Freeze before I build them and Thaw after they're
done. But it doesn't seem to work. I even tried to Freeze the frame
before building and then not to Thaw it at all, but the widgets still
become visible.

What's happening?

Ram.

···

On Sep 28, 12:44 am, cool-RR <ram.rac...@gmail.com> wrote:

On Sep 28, 12:37 am, Josh English <joshua.r.engl...@gmail.com> wrote:
> You said the magic word.

> wx.Freeze()

> ... Do stuff.

> wx.Thaw()

> I think those are the right commands.

> Josh

> On Mon, Sep 27, 2010 at 3:27 PM, cool-RR <ram.rac...@gmail.com> wrote:
> > Hello,

> > I have a widget which, during the runtime of the program, destroys all
> > its children and rebuilds new children. I noticed that there's a lot
> > of flicker when it does that, as if wxPython is showing me all the
> > intermediate steps, instead of freezing the old state until the new
> > state is ready.

> > Is there any way to avoid that?

> > Thanks,
> > Ram.

Yes! Awesome.

That's the true Python spirit. You have some functionality that you
need, you think of the word that will describe it most succinctly,
"freeze" in this case, and then find out it was a method on your
object all along :slight_smile:

Ram.

In wx all widgets except for top-level windows (like frames or dialogs) are created in the visible state, and since you are not specifying a position and the sizer has not yet done its magic, you can momentarily see all the widgets at position (0,0) as they are being created. One way to workaround this is to hide the parent while you are adding all the child controls, then set the size of the parent to be at least close to what the size will be when the next real layout is done and then Show() the panel and do whatever else you were going to do with it. Or, if it's going to be a notebook page you can decide to leave it hidden and let the notebook show and size it when that new page is selected.

···

On 9/27/10 3:56 PM, cool-RR wrote:

I have now tried to apply the Freeze/Thaw stuff to another, more
important place in my program: In the main Frame, which is managed by
PyAUI. Every time I start my program, all the widgets appear in one
ugly corner in the upper left of the screen. So I thought that to
prevent this I could Freeze before I build them and Thaw after they're
done. But it doesn't seem to work. I even tried to Freeze the frame
before building and then not to Thaw it at all, but the widgets still
become visible.

What's happening?

--
Robin Dunn
Software Craftsman

It seems I solved it completely by simply hiding all the widgets
before building them. I'm not even sure where Show is being called,
possibly by PyAUI. I'm not using Freeze/Thaw either. But anyway, now
the flicker is completely solved.

Thanks!

Ram.

···

On Sep 28, 1:09 am, Robin Dunn <ro...@alldunn.com> wrote:

On 9/27/10 3:56 PM, cool-RR wrote:

> I have now tried to apply the Freeze/Thaw stuff to another, more
> important place in my program: In the main Frame, which is managed by
> PyAUI. Every time I start my program, all the widgets appear in one
> ugly corner in the upper left of the screen. So I thought that to
> prevent this I could Freeze before I build them and Thaw after they're
> done. But it doesn't seem to work. I even tried to Freeze the frame
> before building and then not to Thaw it at all, but the widgets still
> become visible.

> What's happening?

In wx all widgets except for top-level windows (like frames or dialogs)
are created in the visible state, and since you are not specifying a
position and the sizer has not yet done its magic, you can momentarily
see all the widgets at position (0,0) as they are being created. One
way to workaround this is to hide the parent while you are adding all
the child controls, then set the size of the parent to be at least close
to what the size will be when the next real layout is done and then
Show() the panel and do whatever else you were going to do with it. Or,
if it's going to be a notebook page you can decide to leave it hidden
and let the notebook show and size it when that new page is selected.

--
Robin Dunn