intercept automatic scrolling

I’ve got a bunch of controls in a gridsizer on a ScrolledPanel. Moving the scrollbars around is pretty slow because of all the controls and sizers within sizers. When I click on a control that’s in view, the ScrolledPanel automatically scrolls to show that whole control, which takes a lot of time. I don’t always want that behavior, so I’m wondering if there’s any way to intercept the event that causes the automatic view change.

Also, if anyone has tips on how to arrange my sizers so that they are faster, I’d appreciate it. Basically I’ve got individual control windows that are built using sizers, so when I arrange them within a massive gridsizer, I think it’s causing a lag whenever it needs to Layout…

NOTICE: Empowered by Presidential Executive Orders, the National Security
Agency may read this email without warning, warrant, or notice. The NSA may do this without any judicial or legislative oversight. The President also claims the right to designate the sender or the reader as an enemy combatant and to imprison him/her indefinitely without access to legal counsel or anyone else, and to be rendered to a foreign government for possible torture or death.

Hi,

I've got a bunch of controls in a gridsizer on a ScrolledPanel. Moving the
scrollbars around is pretty slow because of all the controls and sizers
within sizers. When I click on a control that's in view, the ScrolledPanel
automatically scrolls to show that whole control, which takes a lot of time.
I don't always want that behavior, so I'm wondering if there's any way to
intercept the event that causes the automatic view change.

You might try intercepting the OnChildFocus method of ScrolledPanel.
If in this example "self" is the scrolled panel, just do something
like this:

def OnChildFocus(self, event):
    pass

If you need something more elaborated than a simple "pass", you can
use the properties of the passed event.

Also, if anyone has tips on how to arrange my sizers so that they are
faster, I'd appreciate it. Basically I've got individual control windows
that are built using sizers, so when I arrange them within a massive
gridsizer, I think it's causing a lag whenever it needs to Layout...

This depends on which kind of controls/widgets you have on your
sizers: are they heavy demanding widgets (i.e., grids, listctrls,
treectrls)? Are there very many of them? Without a sample it's
difficult to guess, although if you have many heavy demanding widgets
I would start thinking of re-designing a bit your layout to use less
controls (by hiding them, creating them only when needed and so on).

NOTICE: Empowered by Presidential Executive Orders, the National Security
Agency may read this email without warning, warrant, or notice. The NSA may
do this without any judicial or legislative oversight. The President also
claims the right to designate the sender or the reader as an enemy combatant
and to imprison him/her indefinitely without access to legal counsel or
anyone else, and to be rendered to a foreign government for possible torture
or death.

It's about time to remove this notice.

Andrea.

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

···

On Wed, Jan 7, 2009 at 10:30 PM, $P!D3R DelSol wrote:

Thanks for the awesomely quick reply.
Your OnChildFocus method worked perfectly.
I attached a picture of a typically crowded GUI in my program, in case you have any further thoughts on how to make it
more efficient.

···

________________________________
From: Andrea Gavana <andrea.gavana@gmail.com>
To: $P!D3R DelSol <sunsp1der@yahoo.com>; wxpython-users@lists.wxwidgets.org
Sent: Thursday, January 8, 2009 1:42:28 AM
Subject: Re: [wxpython-users] intercept automatic scrolling

Hi,

On Wed, Jan 7, 2009 at 10:30 PM, $P!D3R DelSol wrote:

I've got a bunch of controls in a gridsizer on a ScrolledPanel. Moving the
scrollbars around is pretty slow because of all the controls and sizers
within sizers. When I click on a control that's in view, the ScrolledPanel
automatically scrolls to show that whole control, which takes a lot of time.
I don't always want that behavior, so I'm wondering if there's any way to
intercept the event that causes the automatic view change.

You might try intercepting the OnChildFocus method of ScrolledPanel.
If in this example "self" is the scrolled panel, just do something
like this:

def OnChildFocus(self, event):
    pass

If you need something more elaborated than a simple "pass", you can
use the properties of the passed event.

Also, if anyone has tips on how to arrange my sizers so that they are
faster, I'd appreciate it. Basically I've got individual control windows
that are built using sizers, so when I arrange them within a massive
gridsizer, I think it's causing a lag whenever it needs to Layout...

This depends on which kind of controls/widgets you have on your
sizers: are they heavy demanding widgets (i.e., grids, listctrls,
treectrls)? Are there very many of them? Without a sample it's
difficult to guess, although if you have many heavy demanding widgets
I would start thinking of re-designing a bit your layout to use less
controls (by hiding them, creating them only when needed and so on).

NOTICE: Empowered by Presidential Executive Orders, the National Security
Agency may read this email without warning, warrant, or notice. The NSA may
do this without any judicial or legislative oversight. The President also
claims the right to designate the sender or the reader as an enemy combatant
and to imprison him/her indefinitely without access to legal counsel or
anyone else, and to be rendered to a foreign government for possible torture
or death.

It's about time to remove this notice.

Andrea.

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

This actually solved a problem I was having too - I had recursive validation turned on for a ScrolledPanel embedded in a Dialog, and apparently this focuses on each widget in turn when validation is run. So when I clicked “Okay”, it scrolled through the window before it closes. Since I still want it to scroll when a user focuses on a control (e.g. tab key), I now track whether the dialog is in the process of being closed before deciding whether to focus or not. This works very well but it seems unnecessarily complex - is there a way to detect from the event whether the focus is resulting from validation or user action? Or can I disable focusing during validation.

thanks,

Nat

···

On Thu, Jan 8, 2009 at 1:42 AM, Andrea Gavana andrea.gavana@gmail.com wrote:

You might try intercepting the OnChildFocus method of ScrolledPanel.
. . .
If you need something more elaborated than a simple “pass”, you can

use the properties of the passed event.

Hi,

Thanks for the awesomely quick reply.
Your OnChildFocus method worked perfectly.
I attached a picture of a typically crowded GUI in my program, in case you have any further thoughts on how to make it
more efficient.

From the picture, it looks like something between a list control and a

property grid. If you see lots of performances degradation, I would
probably re-implement the whole widget as a wxGrid, using custom
renderers for your buttons. It may look like a bunch of work, but in
the end it's very easy and it will improve by far the responsiveness
of your GUI. I did it the first time for my main application here at
work and I was so happy with the performances of my custom grid that
now I use it every time I can in my other apps.

Andrea.

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

···

On Thu, Jan 8, 2009 at 6:44 PM, $P!D3R DelSol wrote:

Hi Nat,

···

On Thu, Jan 8, 2009 at 7:09 PM, Nathaniel Echols wrote:

On Thu, Jan 8, 2009 at 1:42 AM, Andrea Gavana <andrea.gavana@gmail.com> > wrote:

You might try intercepting the OnChildFocus method of ScrolledPanel.
. . .
If you need something more elaborated than a simple "pass", you can
use the properties of the passed event.

This actually solved a problem I was having too - I had recursive validation
turned on for a ScrolledPanel embedded in a Dialog, and apparently this
focuses on each widget in turn when validation is run. So when I clicked
"Okay", it scrolled through the window before it closes. Since I still want
it to scroll when a user focuses on a control (e.g. tab key), I now track
whether the dialog is in the process of being closed before deciding whether
to focus or not. This works very well but it seems unnecessarily complex -
is there a way to detect from the event whether the focus is resulting from
validation or user action? Or can I disable focusing during validation.

I am not sure you can tell the difference between validation or user
action from the event... I do not use validators so much, so I'd
probably go disabling focus during validation.

Andrea.

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

Oops - I assumed this was default behavior, but I just checked and realized that I was focusing on controls even if validation was successful. Deleting that fixed the problem, of course. I guess I misread the example in Robin’s book.

···

On Fri, Jan 9, 2009 at 12:58 AM, Andrea Gavana andrea.gavana@gmail.com wrote:

I am not sure you can tell the difference between validation or user

action from the event… I do not use validators so much, so I’d

probably go disabling focus during validation.