StdDialogButtonSizer and tab order

I just rewrote part of Dabo to use the StdDialogButtonSizer, since that seemed the sane thing to do for multiplatform development.

However, I'm noticing that on Gtk my Cancel button is appearing before my Okay button. This isn't a problem, because I assume that is the standard for the platform.

What *is* a problem is that when I tab through the controls, the Okay button gets focus first, then the Cancel button. This is, obviously, because that was the order I created them.

Should this be submitted as a bug, or is it "by design"?

···

--
Paul McNett
http://paulmcnett.com
http://dabodev.com

I just rewrote part of Dabo to use the StdDialogButtonSizer, since that seemed
the sane thing to do for multiplatform development.

However, I'm noticing that on Gtk my Cancel button is appearing before my Okay
button. This isn't a problem, because I assume that is the standard for the
platform.

What *is* a problem is that when I tab through the controls, the Okay button
gets focus first, then the Cancel button. This is, obviously, because that was
the order I created them.

Yes, but I think the order should be independent of the creation, in
this particular sizer, and should rely on the native one.

Should this be submitted as a bug, or is it "by design"?

My opinion, it's a bug but try to ask on wx-users or wx-dev first. Maybe
there is a reason for that behavior.

Ricardo

···

On Fri, 2005-12-09 at 13:14 -0800, Paul McNett wrote:

Where else in wxPython do you rely on sizers to control your tab
order? If you create 2 buttons, add them to a sizer, remove the first
button (without destroying it), and then append it back to the same
sizer, would you expect the tab order to change?

···

On 12/9/05, Paul McNett <p@ulmcnett.com> wrote:

I just rewrote part of Dabo to use the StdDialogButtonSizer, since that seemed
the sane thing to do for multiplatform development.

However, I'm noticing that on Gtk my Cancel button is appearing before my Okay
button. This isn't a problem, because I assume that is the standard for the
platform.

What *is* a problem is that when I tab through the controls, the Okay button
gets focus first, then the Cancel button. This is, obviously, because that was
the order I created them.

Should this be submitted as a bug, or is it "by design"?

--

# p.d.

Peter Decker wrote:

Where else in wxPython do you rely on sizers to control your tab
order? If you create 2 buttons, add them to a sizer, remove the first
button (without destroying it), and then append it back to the same
sizer, would you expect the tab order to change?

I wouldn't expect any old sizer to control my tab order. But in the case of this specialized sizer, which implicitly changes the button order depending on platform and no matter how I set it, I would think that it would also massage the tab order for me.

···

--
Paul McNett
http://paulmcnett.com
http://dabodev.com

Paul McNett wrote:

Peter Decker wrote:

Where else in wxPython do you rely on sizers to control your tab
order? If you create 2 buttons, add them to a sizer, remove the first
button (without destroying it), and then append it back to the same
sizer, would you expect the tab order to change?

I wouldn't expect any old sizer to control my tab order. But in the case of this specialized sizer, which implicitly changes the button order depending on platform and no matter how I set it, I would think that it would also massage the tab order for me.

FWIW, here's the code I added to get the tab order to match the display order:

# Put the buttons in a StdDialogButtonSizer, so they get positioned/sized
# per the native platform conventions, and add that sizer to self.Sizer:
buttonSizer = wx.StdDialogButtonSizer()
buttonSizer.AddButton(self.btnOK)
buttonSizer.AddButton(self.btnCancel)
buttonSizer.Realize()

# Wx rearranges the order of the buttons per platform conventions, but
# doesn't rearrange the tab order for us. So, we do it manually:
buttons =
for child in buttonSizer.GetChildren():
  win = child.GetWindow()
  if win is not None:
    buttons.append(win)
buttons[1].MoveAfterInTabOrder(buttons[0])

···

--
Paul McNett
http://paulmcnett.com
http://dabodev.com