+#---------------------------------------------------------------------------
+# A class to be used to simply display a message in the demo pane
+# rather than running the sample itself.
+
+class MessagePanel(wx.Panel):
+ def __init__(self, parent, message, caption='', flags=0):
+ wx.Panel.__init__(self, parent)
+
+ # Make widgets
+ if flags:
+ artid = None
+ if flags & wx.ICON_EXCLAMATION:
+ artid = wx.ART_WARNING
+ elif flags & wx.ICON_ERROR:
+ artid = wx.ART_ERROR
+ elif flags & wx.ICON_QUESTION:
+ artid = wx.ART_QUESTION
+ elif flags & wx.ICON_INFORMATION:
+ artid = wx.ART_INFORMATION
+
+ if artid is not None:
+ bmp = wx.ArtProvider.GetBitmap(artid, wx.ART_MESSAGE_BOX, (32,32))
+ icon = wx.StaticBitmap(self, -1, bmp)
+ else:
+ icon = (32,32) # make a spacer instead
+
+ if caption:
+ caption = wx.StaticText(self, -1, caption)
+ caption.SetFont(wx.Font(28, wx.SWISS, wx.NORMAL, wx.BOLD))
+
+ message = wx.StaticText(self, -1, message)
+
+ # add to sizers for layout
+ tbox = wx.BoxSizer(wx.VERTICAL)
+ if caption:
+ tbox.Add(caption)
+ tbox.Add((10,10))
+ tbox.Add(message)
+
+ hbox = wx.BoxSizer(wx.HORIZONTAL)
+ hbox.Add((10,10), 1)
+ hbox.Add(icon)
+ hbox.Add((10,10))
+ hbox.Add(tbox)
+ hbox.Add((10,10), 1)
+
+ box = wx.BoxSizer(wx.VERTICAL)
+ box.Add((10,10), 1)
+ box.Add(hbox, 0, wx.EXPAND)
+ box.Add((10,10), 2)
+
+ self.SetSizer(box)
+ self.Fit()
+