Tab traversal on static box children of type textctrl does not work

Hi,

I’m struggling getting the attached code to work. I want to be able to traverse between the two textctrls using TAB, but nothing happens. I’m using version 3.0 of wxpython and the test code is executed on OS X. If I instead have two combos inside the static box the TAB works fine, or in the case of inserting the text ctrls directly on a panel (w/o the StaticBox).

Is there something I’m doing wrong here?

Kind Regards,

controltest.py (871 Bytes)

I'm trying this not on wx 3 or OS X, but I think this is general enough
that it should apply in your platform and version, too. But you'll have to
try it...

Try changing the parent of the three widgets to be the panel, not the sb.
As I recall, staticBox's should have a sibling relationship to the widgets
inside, not a parent/child.

You didn't ask about this part, but also call .SetSizer() on the panel, not
the frame itself. That is, use:

    panel.SetSizer(sizer)

in order for the panel to take up the available space on the frame
dynamically, which is what you will want, I think.

Che

···

On Sun, Mar 2, 2014 at 10:44 PM, Geir Arne <evjeng@gmail.com> wrote:

Hi,
I'm struggling getting the attached code to work. I want to be able to
traverse between the two textctrls using TAB, but nothing happens. I'm
using version 3.0 of wxpython and the test code is executed on OS X. If I
instead have two combos inside the static box the TAB works fine, or in the
case of inserting the text ctrls directly on a panel (w/o the StaticBox).

Is there something I'm doing wrong here?

C M wrote:

Try changing the parent of the three widgets to be the panel, not the
sb. As I recall, staticBox's should have a sibling relationship to the
widgets inside, not a parent/child.

That changed in 2.9. The recommendation is now to use a parent/child relationship between the staticbox and the widgets contained in it, however I've noticed some other glitches related to this in the past so I think the transition was not as smooth as people expected it to be. Using the sibling relationship should still work for the time being, but it may eventually get phased out.

···

--
Robin Dunn
Software Craftsman