Is there a way to catch just the last wx.EVT_SIZE?

I have a case in which it is expensive to redraw a window, so I don’t want to do that repeatedly as the window is sized by the user…but I do want to redraw right at the end. So basically, I want to ignore all of the size events for the window except for the very last one.

I keep thinking that I’ve missed something obvious or something in the docs, but just can’t seem to figure out what the proper thing to do here is. I started off just setting a wx.Timer during the size event handler, but that does mean that there will be a delay between when the user lets up on the mouse button and the redraw of the window.

You could do your redraw of the contents in a Mouse left up event
handler, possibly checking a flag that you set in the On Resize Handler
to see if you need to do it.

Gadget/Steve

···

On 10/08/2012 7:29 PM, dhyams wrote:

I have a case in which it is expensive to redraw a window, so I don't
want to do that repeatedly as the window is sized by the user....but I
do want to redraw right at the end. So basically, I want to ignore
all of the size events for the window except for the very last one.

I keep thinking that I've missed something obvious or something in the
docs, but just can't seem to figure out what the proper thing to do
here is. I started off just setting a wx.Timer during the size event
handler, but that does mean that there will be a delay between when
the user lets up on the mouse button and the redraw of the window.
--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

Thanks Steve…the resizing, though is of a panel in the frame (the panel is resized as a result of a parent’s resize, basically) and not the frame itself, so I never see the mouse left up event.

···

On Saturday, August 11, 2012 4:06:56 AM UTC-4, Gadget Steve wrote:

On 10/08/2012 7:29 PM, dhyams wrote:

I have a case in which it is expensive to redraw a window, so I don’t

want to do that repeatedly as the window is sized by the user…but I

do want to redraw right at the end. So basically, I want to ignore

all of the size events for the window except for the very last one.

I keep thinking that I’ve missed something obvious or something in the

docs, but just can’t seem to figure out what the proper thing to do

here is. I started off just setting a wx.Timer during the size event

handler, but that does mean that there will be a delay between when

the user lets up on the mouse button and the redraw of the window.


To unsubscribe, send email to wxPython-user...@googlegroups.com

or visit http://groups.google.com/group/wxPython-users?hl=en

You could do your redraw of the contents in a Mouse left up event

handler, possibly checking a flag that you set in the On Resize Handler

to see if you need to do it.

Gadget/Steve

Hi,

···

On Sat, Aug 11, 2012 at 2:47 PM, dhyams <dhyams@gmail.com> wrote:

Thanks Steve...the resizing, though is of a panel in the frame (the panel is
resized as a result of a parent's resize, basically) and not the frame
itself, so I never see the mouse left up event.

Use a one shot timer to delay the processing. Each time your OnSize is
called start/re-start the timer so that the timer even will only fire
after a set interval when your last size event is received.

Cody

So you would need to have a mouse up event handler bound to your frame,
(either as a part of the frame constructor or by doing a parent.Bind in
the panel constructor, that on a mouse up event checks if a resize has
been occurring and triggers your redraw.

Gadget/Steve

···

On 11/08/2012 8:47 PM, dhyams wrote:

Thanks Steve...the resizing, though is of a panel in the frame (the
panel is resized as a result of a parent's resize, basically) and not
the frame itself, so I never see the mouse left up event.

Another alternative to Cody's solution is to use an EVT_IDLE handler
to catch your resizes (I actually use both solutions alternatively
when handling complex matplotlib or VTK wx-based panels). See if you
can adapt this solution:

http://www.scipy.org/Matplotlib_figure_in_a_wx_panel

To your problem.

Andrea.

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

# ------------------------------------------------------------- #
def ask_mailing_list_support(email):

    if mention_platform_and_version() and include_sample_app():
        send_message(email)
    else:
        install_malware()
        erase_hard_drives()
# ------------------------------------------------------------- #

···

On 11 August 2012 21:51, Cody wrote:

Hi,

On Sat, Aug 11, 2012 at 2:47 PM, dhyams <dhyams@gmail.com> wrote:

Thanks Steve...the resizing, though is of a panel in the frame (the panel is
resized as a result of a parent's resize, basically) and not the frame
itself, so I never see the mouse left up event.

Use a one shot timer to delay the processing. Each time your OnSize is
called start/re-start the timer so that the timer even will only fire
after a set interval when your last size event is received.

Perfect Andrea! Thanks so much!

···

On Sunday, August 12, 2012 2:47:58 AM UTC-4, Infinity77 wrote:

On 11 August 2012 21:51, Cody wrote:

Hi,

On Sat, Aug 11, 2012 at 2:47 PM, dhyams dhy...@gmail.com wrote:

Thanks Steve…the resizing, though is of a panel in the frame (the panel is

resized as a result of a parent’s resize, basically) and not the frame

itself, so I never see the mouse left up event.

Use a one shot timer to delay the processing. Each time your OnSize is

called start/re-start the timer so that the timer even will only fire

after a set interval when your last size event is received.

Another alternative to Cody’s solution is to use an EVT_IDLE handler

to catch your resizes (I actually use both solutions alternatively

when handling complex matplotlib or VTK wx-based panels). See if you

can adapt this solution:

http://www.scipy.org/Matplotlib_figure_in_a_wx_panel

To your problem.

Andrea.

“Imagination Is The Only Weapon In The War Against Reality.”

http://xoomer.alice.it/infinity77/

-------------------------------------------------------------

def ask_mailing_list_support(email):

if mention_platform_and_version() and include_sample_app():

    send_message(email)

else:

    install_malware()

    erase_hard_drives()

-------------------------------------------------------------