Skip to content Skip to sidebar Skip to footer

Ok/cancel Order In "custom" Dialogs Created With Wxglade

I've noticed that standard dialogs some CANCEL and OK buttons in different order under Windows and under Linux. Under Linux, you get '[CANCEL] [OK]', and under Windows, '[OK] [CANC

Solution 1:

The StdDialogButtonSizer is definitely the way to go for custom dialogs. Here's a simple example:

import wx

########################################################################classSampleDialog(wx.Dialog):
    """"""#----------------------------------------------------------------------def__init__(self, parent):
        """Constructor"""
        wx.Dialog.__init__(self, parent, title="Tutorial")

        btnOk = wx.Button(self, wx.ID_OK)
        btnCancel = wx.Button(self, wx.ID_CANCEL)

        btnSizer = wx.StdDialogButtonSizer()
        btnSizer.AddButton(btnOk)
        btnSizer.AddButton(btnCancel)
        btnSizer.Realize()
        self.SetSizer(btnSizer)

#----------------------------------------------------------------------if __name__ == '__main__':
    app = wx.App(False)
    dlg = SampleDialog(None)
    dlg.ShowModal()

See also WxPython: Cross-Platform Way to Conform Ok/Cancel Button Order or http://wxpython-users.1045709.n5.nabble.com/wx-StdDialogButtonSizer-and-wx-ID-SAVE-td2360032.html

I don't know if there's a way to do this in Glade or not though.

Post a Comment for "Ok/cancel Order In "custom" Dialogs Created With Wxglade"