User interface wxPython对话框

User interface wxPython对话框,user-interface,wxpython,icons,dialog,User Interface,Wxpython,Icons,Dialog,我正在用wxPython编写一个显示错误对话框的类。这是我的密码: import wx class Error: def __init__(self, number, string): self.error_type = number self.error_message = string self.choose_error() def choose_error(self): if self.error_type == 1:

我正在用wxPython编写一个显示错误对话框的类。这是我的密码:

import wx

class Error:
   def __init__(self, number, string):
      self.error_type = number
      self.error_message = string
      self.choose_error()

   def choose_error(self):
      if self.error_type == 1:
         self.DisplayMessage1()
      elif self.error_type == 2:
         self.DisplayMessage2()
      elif self.error_type == 3:
         self.DisplayMessage3()
      elif self.error_type == 4:
         self.DisplayMessage4()

   def DisplayMessage1(self):
      dial = wx.MessageDialog(None, self.error_message, 'Info', wx.OK)
      dial.ShowModal()

   def DisplayMessage2(self):
      dial = wx.MessageDialog(None, self.error_message, 'Error', wx.OK | 
         wx.ICON_ERROR)
      dial.ShowModal()

   def DisplayMessage3(self):
      dial = wx.MessageDialog(None, self.error_message, 'Question', 
         wx.YES_NO | wx.NO_DEFAULT | wx.ICON_QUESTION)
      dial.ShowModal()

   def DisplayMessage4(self):
      dial = wx.MessageDialog(None, self.error_message, 'Warning', wx.OK | 
         wx.ICON_EXCLAMATION)
      dial.ShowModal()

如何将默认图标更改为自定义图标??我试图用wx.Icon替换它们,但没有成功。wxPython中的对话框是否仅限于我上面使用的图标?在Mac OS X上,它们似乎显示不正确。

参数,如
wx.ICON\u ERROR
wx.ICON\u感叹号
不是真正的图标,而是
wx.MessageDialog
构造函数的整数标志。这些消息对话框是通过操作系统调用以本机方式呈现的,因此它们看起来不同,例如在Windows和Mac OS X上

由于wxWidgets是为Windows API设计的,
MessageDialog
参数与Windows API样式标志非常相似(
MB_ICONERROR
MB_IConnexClation
等)

如果您想使用自己的图标进行对话框,只需基于
wx.dialog
实现自己的消息对话框类即可