#!/bin/python
import wx
from wx.html import HtmlWindow
def window(text):
class HtmlDialog(wx.MessageDialog):
'''A messagedialog with HTML-formatted message'''
def __init__(self, parent, title, message, style):
wx.Dialog.__init__(self, parent, title = title, style = style)
self.htmlwindow = HtmlWindow(self)
self.sizer = wx.BoxSizer(wx.VERTICAL)
self.buttonsizer = wx.BoxSizer(wx.HORIZONTAL)
self.yesbutton = wx.Button(self, wx.ID_YES)
self.nobutton = wx.Button(self, wx.ID_NO)
self.cancelbutton = wx.Button(self, wx.ID_CANCEL)
self.sizer.Add(self.htmlwindow, flag = wx.EXPAND, proportion = 1)
self.sizer.Add(self.buttonsizer, flag = wx.EXPAND | wx.TOP, border = 5)
self.buttonsizer.Add(self.yesbutton, flag = wx.EXPAND | wx.TOP, border = 5)
self.buttonsizer.Add(self.nobutton, 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", text, wx.DEFAULT_DIALOG_STYLE | wx.STAY_ON_TOP)
dlg.SetSize((800,500))
dlg.SetPosition((wx.DisplaySize()[0]-dlg.GetSize()[0]-10,wx.DisplaySize()[1]-dlg.GetSize()[1]))
dlg.ShowModal()
raise SystemExit
app = MyApp(0)
app.MainLoop()
text='THIS is HTML!'
window(text)
print '''if you see this line you have the proof there are nice people on #wxwidgets and/or #python :P'''