“自定义"中的确定/取消订单用 wxglade 创建的对话框 [英] OK/CANCEL order in "custom" dialogs created with wxglade

查看:11
本文介绍了“自定义"中的确定/取消订单用 wxglade 创建的对话框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我注意到标准对话框在 Windows 和 Linux 下以不同的顺序显示了一些取消和确定按钮.在 Linux 下,您会看到[CANCEL] [OK]",而在 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 of the O.S.

我的疑惑:

1.- 似乎存在一个名为 wx.StdDialogBu​​ttonSizer 的类,但我不确定应该如何使用它.有人可以发布任何简单/有效的示例吗?

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?

以及主要问题":

2.- 我使用 wxglade 来构建"对话框的代码,所以我不确定我是否可以使用 StdDialogBu​​ttonSizer.有没有办法用给定的顺序定义对话框,并在运行时检查按钮是否遵循正确的顺序和交换"?如果没有,那两个小部件?

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?

谢谢

推荐答案

StdDialogBu​​ttonSizer 绝对是自定义对话框的最佳选择.这是一个简单的例子:

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()

另见 WxPython:跨平台方式符合确定/取消按钮顺序http://wxpython-users.1045709.n5.nabble.com/wx-StdDialogBu​​ttonSizer-and-wx-ID-SAVE-td2360032.html

我不知道格莱德是否有办法做到这一点.

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

这篇关于“自定义"中的确定/取消订单用 wxglade 创建的对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆