X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/ec3e670f9f9942d5de4c543edfbc87fc3e0cd797..eb254be6df56f99bd2691e4ca38d59004d2f39f5:/utils/wxPython/demo/wxHtmlWindow.py?ds=sidebyside diff --git a/utils/wxPython/demo/wxHtmlWindow.py b/utils/wxPython/demo/wxHtmlWindow.py index 07ec21a554..afcba359bc 100644 --- a/utils/wxPython/demo/wxHtmlWindow.py +++ b/utils/wxPython/demo/wxHtmlWindow.py @@ -1,7 +1,10 @@ -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 #---------------------------------------------------------------------- @@ -55,35 +58,64 @@ class TestHtmlPanel(wxPanel): 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): @@ -104,3 +136,28 @@ It is not intended to be a high-end HTML browser. If you're looking for somethi """ + + + + +_widgetTest = '''\ +
+The widgets on this page were created dynamically on the fly by a custom +wxTagHandler found in wxPython.lib.wxpTag. + +