When I add buttons to StdDialogButtonSizer, the left-most displayed button is always the default. On Linux (TuxedoOS, essentially Debian testing and KDE) with Python 3.14.7 and wxPython 4.3.2
Here is a test program:
import wx
class TestDialog(wx.Dialog):
def __init__(self):
super(TestDialog, self).__init__(
None, title="Test Dialog")
text = wx.StaticText(self, label="Some random text")
ok = wx.Button(self, id = wx.ID_OK)
ok.SetDefault()
cancel = wx.Button(self, id = wx.ID_CANCEL)
help = wx.Button(self, wx.ID_HELP)
button_sizer = wx.StdDialogButtonSizer()
button_sizer.AddButton(ok)
button_sizer.AddButton(cancel)
button_sizer.AddButton(help)
button_sizer.SetAffirmativeButton(ok)
button_sizer.Realize()
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(text, flag = wx.ALL, border = 5)
sizer.Add(button_sizer, flag = wx.LEFT | wx.RIGHT | wx.BOTTOM,
border = 10)
self.SetSizer(sizer)
if __name__ == '__main__':
app = wx.App()
dialog = TestDialog()
dialog.ShowModal()
Whether the code ok.SetDefault() or button_sizer.SetAffirmativeButton(ok) is included or not, the left-most button (the help button on KDE) is always the default.
How can I set the OK button, which on my system is the right-most, as the default?