开发者

OK/CANCEL order in "custom" dialogs created with wxglade

开发者 https://www.devze.com 2023-03-20 02:27 出处:网络
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] [CANCEL]&

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] [CANCEL]".

I have no problem with the standard dialogs, but then my "custom dialogs" must be tweaked to match the same order, dependent o开发者_C百科f the O.S.

My doubts:

1.- It seems to exist a class called wx.StdDialogButtonSizer, but I'm not sure how it should be used. Can somebody post any working simple / working example?

And the "Main question":

2.- I use wxglade to "build" code for the dialogs, so I'm not sure I can use StdDialogButtonSizer. Is there a way to define the dialog with a given order, and in run-time check if the buttons follow the right order and "exchange" those two widgets if not?

Thanks


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

import wx

########################################################################
class SampleDialog(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.

0

精彩评论

暂无评论...
验证码 换一张
取 消