1
#----------------------------------------------------------------------
2
# Name: wx.lib.msgpanel
3
# Purpose: The MessagePanel class (Note: this class used to live
4
# in the demo's Main module.)
10
# Copyright: (c) 2009 by Total Control Software
11
# Licence: wxWindows license
12
#----------------------------------------------------------------------
15
MessagePanel is a simple panel class for displaying a message, very
16
much like how wx.MessageDialog works, including the icon flags.
21
#----------------------------------------------------------------------
23
class MessagePanel(wx.Panel):
24
def __init__(self, parent, message, caption='', flags=0):
25
wx.Panel.__init__(self, parent)
31
if flags & wx.ICON_EXCLAMATION:
32
artid = wx.ART_WARNING
33
elif flags & wx.ICON_ERROR:
35
elif flags & wx.ICON_QUESTION:
36
artid = wx.ART_QUESTION
37
elif flags & wx.ICON_INFORMATION:
38
artid = wx.ART_INFORMATION
41
bmp = wx.ArtProvider.GetBitmap(artid, wx.ART_MESSAGE_BOX, (32,32))
42
icon = wx.StaticBitmap(self, -1, bmp)
45
icon = (32,32) # make a spacer instead
48
caption = wx.StaticText(self, -1, caption)
49
caption.SetFont(wx.Font(24, wx.SWISS, wx.NORMAL, wx.BOLD))
51
message = wx.StaticText(self, -1, message)
53
# add to sizers for layout
54
tbox = wx.BoxSizer(wx.VERTICAL)
60
hbox = wx.BoxSizer(wx.HORIZONTAL)
67
box = wx.BoxSizer(wx.VERTICAL)
69
box.Add(hbox, 0, wx.EXPAND)
76
#----------------------------------------------------------------------
79
if __name__ == '__main__':
80
app = wx.App(redirect=False)
81
frm = wx.Frame(None, title='MessagePanel Test')
82
pnl = MessagePanel(frm, flags=wx.ICON_EXCLAMATION,
83
caption="Please stand by...",
85
This is a test. This is a test of the emergency broadcast
86
system. Had this been a real emergency, you would have
87
already been reduced to a pile of radioactive cinders and
88
wondering why 'duck and cover' didn't help.
90
This is only a test...""")
91
frm.Sizer = wx.BoxSizer()
92
frm.Sizer.Add(pnl, 1, wx.EXPAND)