Resize a window smoothly (animated)

I was wondering if there's a way to resize a window as a gradual animated
process. I have an action which shows extra content and changes the
size of a window- which works fine but I was wondering if there was a way
to get the window to gradually open wider or taller. This is pretty
common within mac applications and I've seen it in a few places in
windows and wondered if this is possible cross platform, or alt east on
some platforms through wx. I've tried searching but not come up with
much mainly because I don't know exactly what the name of this is!

Cheers!
Paul

What widget do you use? If you have a AuiManager you can use AUI_MGR_LIVE_RESIZE as a flag, but its on all widgets something else (like wx.SP_LIVE_UPDATE at a splitterwindow)

Alex

Alex Hefner <H._Alex <at> web.de> writes:

What widget do you use? If you have a AuiManager you can use

AUI_MGR_LIVE_RESIZE as a flag, but its on all widgets something
else (like wx.SP_LIVE_UPDATE at a splitterwindow)Alex

I currently have content on panels in boxsizers so that I can hide and
show the panels when I want to display something different or extra
bits. Do you know how I can get it to work with this setup or of theres
something else I should use instead?

I dont know if this is a good solution but i think you can make it like this:

toplevelwindow

self.Bind(wx.EVT_SIZING,self.sizing)

def sizing(self,event):
self.SetSize(event.Size)

I hope this is what you look for

Alex

···

Am Donnerstag, 10. November 2011 12:05:06 UTC+1 schrieb Paul:

Alex Hefner <H._Alex web.de> writes:

What widget do you use? If you have a AuiManager you can use
AUI_MGR_LIVE_RESIZE as a flag, but its on all widgets something
else (like wx.SP_LIVE_UPDATE at a splitterwindow)Alex

I currently have content on panels in boxsizers so that I can hide and
show the panels when I want to display something different or extra
bits. Do you know how I can get it to work with this setup or of theres
something else I should use instead?

Alex Hefner <H._Alex <at> web.de> writes:

Alex Hefner <H._Alex <at> web.de> writes:> > > What widget do

you use? If you have a AuiManager you can use AUI_MGR_LIVE_RESIZE
as a flag, but its on all widgets something else (like
wx.SP_LIVE_UPDATE at a splitterwindow)Alex

I currently have content on panels in boxsizers so that I can hide

and show the panels when I want to display something different or
extra bits. Do you know how I can get it to work with this setup or of
theres something else I should use instead?

I dont know if this is a good solution but i think you can make it

like this:# toplevelwindowself.Bind(wx.EVT_SIZING,self.sizing)def
sizing(self,event): self.SetSize(event.Size)I hope this is what you
look forAlex

Ahh, I can change the size of the window ok with

self.p.SetSizer(self.sizer)
self.sizer.Fit(self)
self.Layout()

where self is the Frame, self.p is the panel that covers the whole
frame which other panels are children of and sizer is the main sizer
that all other bits and sizers are inside of

What I was wondering is if I could make the window size gradually
slide bigger or smaller to get to this new size. I presume there's a
nicer way to do it than to SetSize multiple times to make an animated
effect.

···

Am Donnerstag, 10. November 2011 12:05:06 UTC+1 schrieb Paul:

I dont think its a good idea either, but i dont know another.
Maybe someone else knows a better solution for this problem.

Alex

···

Am Donnerstag, 10. November 2011 13:17:36 UTC+1 schrieb Paul:

Alex Hefner <H._Alex web.de> writes:

Am Donnerstag, 10. November 2011 12:05:06 UTC+1 schrieb Paul:
Alex Hefner <H._Alex web.de> writes:> > > What widget do
you use? If you have a AuiManager you can use AUI_MGR_LIVE_RESIZE
as a flag, but its on all widgets something else (like
wx.SP_LIVE_UPDATE at a splitterwindow)Alex

I currently have content on panels in boxsizers so that I can hide
and show the panels when I want to display something different or
extra bits. Do you know how I can get it to work with this setup or of
theres something else I should use instead?

I dont know if this is a good solution but i think you can make it
like this:# toplevelwindowself.Bind(wx.EVT_SIZING,self.sizing)def
sizing(self,event): self.SetSize(event.Size)I hope this is what you
look forAlex

Ahh, I can change the size of the window ok with

self.p.SetSizer(self.sizer)
self.sizer.Fit(self)
self.Layout()

where self is the Frame, self.p is the panel that covers the whole
frame which other panels are children of and sizer is the main sizer
that all other bits and sizers are inside of

What I was wondering is if I could make the window size gradually
slide bigger or smaller to get to this new size. I presume there’s a
nicer way to do it than to SetSize multiple times to make an animated
effect.

Hi,

···

On 10 November 2011 13:17, Paul wrote:

Alex Hefner <H._Alex web.de> writes:

Am Donnerstag, 10. November 2011 12:05:06 UTC+1 schrieb Paul:

Alex Hefner <H._Alex web.de> writes:> > > What widget do

you use? If you have a AuiManager you can use AUI_MGR_LIVE_RESIZE

as a flag, but its on all widgets something else (like

wx.SP_LIVE_UPDATE at a splitterwindow)Alex

I currently have content on panels in boxsizers so that I can hide

and show the panels when I want to display something different or

extra bits. Do you know how I can get it to work with this setup or of

theres something else I should use instead?

I dont know if this is a good solution but i think you can make it

like this:# toplevelwindowself.Bind(wx.EVT_SIZING,self.sizing)def

sizing(self,event): self.SetSize(event.Size)I hope this is what you

look forAlex

Ahh, I can change the size of the window ok with

self.p.SetSizer(self.sizer)

self.sizer.Fit(self)

self.Layout()

where self is the Frame, self.p is the panel that covers the whole

frame which other panels are children of and sizer is the main sizer

that all other bits and sizers are inside of

What I was wondering is if I could make the window size gradually

slide bigger or smaller to get to this new size. I presume there’s a

nicer way to do it than to SetSize multiple times to make an animated

effect.

There was once an implementation of a “smoothly” expanding/contracting sizer, called SmoothSizer (IIRC). You can try and google for it.

Andrea.

“Imagination Is The Only Weapon In The War Against Reality.”
http://xoomer.alice.it/infinity77/

Here is how I've done it before when showing a window. It should be adaptable to resizing an already shown window fairly easily.

     def Show(self, show=True):
         # Show the window with a quick bit of animation
         if not show:
             return self.Hide()

         steps = 10
         aniLength = 150
         self._aniTime = aniLength / steps
         self._endSize = sz = self.GetSize()
         self._step = wx.Size(sz.width/steps, sz.height/steps)
         wx.CallLater(self._aniTime, self._showNextStep)
         self.SetSize((1,1))

         return wx.Frame.Show(self, show)

     def _showNextStep(self):
         sz = self.GetSize()
         sz += self._step
         if sz.width > self._endSize.width or sz.height > self._endSize.height:
             sz = self._endSize
         self.SetSize(sz)
         if sz != self._endSize:
             wx.CallLater(self._aniTime, self._showNextStep)

In other cases I've done things like vary the step size based on how much further there is to go, or to vary the delay between steps. Things like that can add nice effects.

···

On 11/10/11 1:59 AM, Paul wrote:

I was wondering if there's a way to resize a window as a gradual animated
process. I have an action which shows extra content and changes the
size of a window- which works fine but I was wondering if there was a way
to get the window to gradually open wider or taller. This is pretty
common within mac applications and I've seen it in a few places in
windows and wondered if this is possible cross platform, or alt east on
some platforms through wx. I've tried searching but not come up with
much mainly because I don't know exactly what the name of this is!

Cheers!
Paul

--
Robin Dunn
Software Craftsman