-from wxPython.wx import *
-from wxPython.html import *
-from wxPython.lib.sizers import *
+import sys, os
+
+from wxPython.wx import *
+from wxPython.html import *
+from wxPython.lib.sizers import *
+import wxPython.lib.wxpTag
#----------------------------------------------------------------------
EVT_BUTTON(self, 1205, self.OnForward)
subbox.Add(btn, 1)
+ btn = wxButton(self, 1206, "View Source")
+ EVT_BUTTON(self, 1206, self.OnViewSource)
+ subbox.Add(btn, 1)
+
self.box.Add(subbox)
+
+ # A button with this ID is created on the widget test page.
+ EVT_BUTTON(self, wxID_OK, self.OnOk)
+
self.OnShowDefault(None)
+
def OnSize(self, event):
size = self.GetClientSize()
self.box.Layout(size)
def OnShowDefault(self, event):
- self.html.LoadPage("data/test.htm")
+ name = os.path.join(os.path.split(sys.argv[0])[0], 'data/test.htm')
+ self.html.LoadPage(name)
def OnLoadFile(self, event):
- pass
+ dlg = wxFileDialog(self, wildcard = '*.htm*', style=wxOPEN)
+ if dlg.ShowModal():
+ path = dlg.GetPath()
+ self.html.LoadPage(path)
+ dlg.Destroy()
def OnWithWidgets(self, event):
- pass
+ os.chdir(os.path.split(sys.argv[0])[0])
+ name = os.path.join(os.path.split(sys.argv[0])[0], 'data/widgetTest.htm')
+ self.html.LoadPage(name)
+ #self.html.SetPage(_widgetTest)
+
+ def OnOk(self, event):
+ self.log.WriteText("It works!\n")
def OnBack(self, event):
if not self.html.HistoryBack():
wxMessageBox("No more items in history!")
+
def OnForward(self, event):
if not self.html.HistoryForward():
wxMessageBox("No more items in history!")
+ def OnViewSource(self, event):
+ from wxPython.lib.dialogs import wxScrolledMessageDialog
+ source = self.html.GetParser().GetSource()
+ dlg = wxScrolledMessageDialog(self, source, 'HTML Source')
+ dlg.ShowModal()
+ dlg.Destroy()
+
+
#----------------------------------------------------------------------
def runTest(frame, nb, log):
"""
+
+
+
+
+_widgetTest = '''\
+<html><body>
+The widgets on this page were created dynamically on the fly by a custom
+wxTagHandler found in wxPython.lib.wxpTag.
+
+<hr>
+<center>
+<wxp class="wxButton" width="50%">
+ <param name="label" value="It works!">
+ <param name="id" value="wxID_OK">
+</wxp>
+</center>
+<hr>
+after
+</body></html>
+'''
+
+
+
+
+