import wx
from wx.html import HtmlWindow
class HtmlDialog(wx.MessageDialog):
'''A messagedialog with HTML-formatted message'''
def __init__(self, parent, title, message):
wx.Dialog.__init__(self, parent, title = title)
self.htmlwindow = HtmlWindow(self)
self.okbutton = wx.Button(self, wx.ID_OK)
self.cancelbutton = wx.Button(self, wx.ID_CANCEL)
self.sizer = wx.BoxSizer(wx.VERTICAL)
self.buttonsizer = wx.BoxSizer(wx.HORIZONTAL)
self.sizer.Add(self.htmlwindow, flag = wx.EXPAND, proportion = 1)
self.buttonsizer.Add(self.okbutton, flag = wx.EXPAND | wx.TOP, border = 5)
self.buttonsizer.Add(self.cancelbutton, flag = wx.EXPAND | wx.TOP, border = 5)
self.htmlwindow.SetPage(message)
self.SetAutoLayout(True)
self.SetSizer(self.sizer)
self.Layout()
if __name__ == '__main__':
print "Unit testing"
class MyApp(wx.App):
def OnInit(self):
dlg = HtmlDialog(None, "My fancy dialog",
'THIS is HTML!')
dlg.ShowModal()
raise SystemExit
app = MyApp(0)
app.MainLoop()