Message Boxes

Use the wxMessageDialog class. Don't forget to Destroy() it when you're done.

Example

Some handy functions for common message box tasks:

   1 def YesNo(parent, question, caption = 'Yes or no?'):
   2     dlg = wx.MessageDialog(parent, question, caption, wx.YES_NO | wx.ICON_QUESTION)
   3     result = dlg.ShowModal() == wx.ID_YES
   4     dlg.Destroy()
   5     return result
   6 def Info(parent, message, caption = 'Insert program title'):
   7     dlg = wx.MessageDialog(parent, message, caption, wx.OK | wx.ICON_INFORMATION)
   8     dlg.ShowModal()
   9     dlg.Destroy()
  10 def Warn(parent, message, caption = 'Warning!'):
  11     dlg = wx.MessageDialog(parent, message, caption, wx.OK | wx.ICON_WARNING)
  12     dlg.ShowModal()
  13     dlg.Destroy()

Scrolled Message Dialog

Show the 'message' in a ScrolledMessageDialog. This import line is required: from wxPython.lib.dialogs import wxScrolledMessageDialog

   1 def InfoText(parent, message, caption='Information !'):
   2     dlg = wx.ScrolledMessageDialog(parent, message, caption)
   3     dlg.ShowModal()

MessageBoxes (last edited 2008-03-11 10:50:17 by localhost)