I have two questions about tab behaviour in wxPython:
Is it possible to set a control as not being able to receive focus from a tab event?
Is it possible to find out which is the next control in the tab order? For example, I have an application with a ListCtrl, and I want the control to be able to receive focus from a tab event only if there are rows in the ListCtrl, and pass focus to the next control in the tab order if the ListCtrl is empty. I know that I can put the logic in the EVT_SET_FOCUS event of the ListCtrl, but I don’t know how to programmatically figure out the next control in the tab order.
I’ve done some googling prior to writing this post, but I can’t find any answers to these questions. Thanks in advance.
If you are going this way, I recommend making a list of the controls you would like to receive focus, in the correct order, and just calling the next one when the tab key is pressed.
I have two questions about tab behaviour in wxPython:
1. Is it possible to set a control as not being able to receive
focus from a tab event?
2. Is it possible to find out which is the next control in the tab
order? For example, I have an application with a ListCtrl, and
I want the control to be able to receive focus from a tab event
only if there are rows in the ListCtrl, and pass focus to the
next control in the tab order if the ListCtrl is empty. I know
that I can put the logic in the EVT_SET_FOCUS event of the
ListCtrl, but I don't know how to programmatically figure out
the next control in the tab order.
I've done some googling prior to writing this post, but I can't find any answers to these questions. Thanks in advance.
Tab order is usually set to the order that the widgets are created. So you can create them in the order you want to tab to, and then disable the ListCtrl when it doesn't have any rows. Disabled controls don't accept focus. When you add a row, just enable the control.
On Tue, Mar 10, 2009 at 10:32 AM, Mike Driscoll > <mike@pythonlibrary.org <mailto:mike@pythonlibrary.org>> wrote:
mercado wrote:
I have two questions about tab behaviour in wxPython:
1. Is it possible to set a control as not being able to receive
focus from a tab event?
2. Is it possible to find out which is the next control in
the tab
order? For example, I have an application with a
ListCtrl, and
I want the control to be able to receive focus from a tab
event
only if there are rows in the ListCtrl, and pass focus to the
next control in the tab order if the ListCtrl is empty.
I know
that I can put the logic in the EVT_SET_FOCUS event of the
ListCtrl, but I don't know how to programmatically figure out
the next control in the tab order.
I've done some googling prior to writing this post, but I
can't find any answers to these questions. Thanks in advance.
Tab order is usually set to the order that the widgets are
created. So you can create them in the order you want to tab to,
and then disable the ListCtrl when it doesn't have any rows.
Disabled controls don't accept focus. When you add a row, just
enable the control.
For what it's worth, Boa Constructor has an easy way to change tab order
for the generated controls it makes. (right-click in Designer, select
"Creation/Tab Order").
Che
···
On Tue, Mar 10, 2009 at 10:32 AM, Mike Driscoll <mike@pythonlibrary.org> wrote:
mercado wrote:
I have two questions about tab behaviour in wxPython:
1. Is it possible to set a control as not being able to receive
focus from a tab event?
2. Is it possible to find out which is the next control in the tab
order? For example, I have an application with a ListCtrl, and
I want the control to be able to receive focus from a tab event
only if there are rows in the ListCtrl, and pass focus to the
next control in the tab order if the ListCtrl is empty. I know
that I can put the logic in the EVT_SET_FOCUS event of the
ListCtrl, but I don't know how to programmatically figure out
the next control in the tab order.