Added the sample code from wxPython In Action to the samples dir
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@42925 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
71
wxPython/samples/wxPIA_book/Chapter-16/helpfiles/Index.hhk
Normal file
71
wxPython/samples/wxPIA_book/Chapter-16/helpfiles/Index.hhk
Normal file
@@ -0,0 +1,71 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
|
||||
<HTML>
|
||||
<HEAD>
|
||||
<meta name="GENERATOR" content="Microsoft® HTML Help Workshop 4.1">
|
||||
<!-- Sitemap 1.0 -->
|
||||
</HEAD><BODY>
|
||||
<UL>
|
||||
<LI> <OBJECT type="text/sitemap">
|
||||
<param name="Name" value="1">
|
||||
<param name="Local" value="book1.htm">
|
||||
</OBJECT>
|
||||
<LI> <OBJECT type="text/sitemap">
|
||||
<param name="Name" value="Untitled: d:\HELPS\testing\main.htm">
|
||||
<param name="Local" value="main.htm">
|
||||
</OBJECT>
|
||||
<UL>
|
||||
<LI> <OBJECT type="text/sitemap">
|
||||
<param name="Name" value="Nested 1">
|
||||
<param name="Local" value="book1.htm">
|
||||
</OBJECT>
|
||||
<LI> <OBJECT type="text/sitemap">
|
||||
<param name="Name" value="Nested 2">
|
||||
<param name="Local" value="book2.htm">
|
||||
</OBJECT>
|
||||
<UL>
|
||||
<LI> <OBJECT type="text/sitemap">
|
||||
<param name="Name" value="MoreNested 1">
|
||||
<param name="Local" value="book1.htm">
|
||||
</OBJECT>
|
||||
<LI> <OBJECT type="text/sitemap">
|
||||
<param name="Name" value="MoreNested 2">
|
||||
<param name="Local" value="book2.htm">
|
||||
</OBJECT>
|
||||
<LI> <OBJECT type="text/sitemap">
|
||||
<param name="Name" value="MoreNested 3">
|
||||
<param name="Local" value="book1.htm">
|
||||
</OBJECT>
|
||||
</UL>
|
||||
<LI> <OBJECT type="text/sitemap">
|
||||
<param name="Name" value="Nested 3">
|
||||
<param name="Local" value="book1.htm">
|
||||
</OBJECT>
|
||||
</UL>
|
||||
<LI> <OBJECT type="text/sitemap">
|
||||
<param name="Name" value="2">
|
||||
<param name="Local" value="book2.htm">
|
||||
</OBJECT>
|
||||
<LI> <OBJECT type="text/sitemap">
|
||||
<param name="Name" value="multiple">
|
||||
<param name="Local" value="book2.htm">
|
||||
</OBJECT>
|
||||
<LI> <OBJECT type="text/sitemap">
|
||||
<param name="Name" value="multiple">
|
||||
<param name="Local" value="book1.htm">
|
||||
</OBJECT>
|
||||
<UL>
|
||||
<LI> <OBJECT type="text/sitemap">
|
||||
<param name="Name" value="Nested under multiple">
|
||||
<param name="Local" value="book1.htm">
|
||||
</OBJECT>
|
||||
<LI> <OBJECT type="text/sitemap">
|
||||
<param name="Name" value="Nested under multiple 2">
|
||||
<param name="Local" value="book1.htm">
|
||||
</OBJECT>
|
||||
</UL>
|
||||
<LI> <OBJECT type="text/sitemap">
|
||||
<param name="Name" value="multiple">
|
||||
<param name="Local" value="main.htm">
|
||||
</OBJECT>
|
||||
</UL>
|
||||
</BODY></HTML>
|
18
wxPython/samples/wxPIA_book/Chapter-16/helpfiles/another.hhc
Normal file
18
wxPython/samples/wxPIA_book/Chapter-16/helpfiles/another.hhc
Normal file
@@ -0,0 +1,18 @@
|
||||
<HTML>
|
||||
<HEAD>
|
||||
<!-- Sitemap 1.0 -->
|
||||
</HEAD><BODY>
|
||||
<OBJECT type="text/site properties">
|
||||
<param name="ImageType" value="Folder">
|
||||
</OBJECT>
|
||||
<UL>
|
||||
<LI> <OBJECT type="text/sitemap">
|
||||
<param name="Name" value="Project file">
|
||||
<param name="Local" value="another.hhp">
|
||||
</OBJECT>
|
||||
<LI> <OBJECT type="text/sitemap">
|
||||
<param name="Name" value="Contents file">
|
||||
<param name="Local" value="another.hhc">
|
||||
</OBJECT>
|
||||
</UL>
|
||||
</BODY></HTML>
|
@@ -0,0 +1,6 @@
|
||||
[OPTIONS]
|
||||
Compatibility=1.1
|
||||
Contents file=another.hhc
|
||||
Display compile progress=No
|
||||
Title=Another book
|
||||
Default topic=another.htm
|
24
wxPython/samples/wxPIA_book/Chapter-16/helpfiles/another.htm
Normal file
24
wxPython/samples/wxPIA_book/Chapter-16/helpfiles/another.htm
Normal file
@@ -0,0 +1,24 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title>Another HTML Help book</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>Another book...</h1>
|
||||
Here's another book to demonstrate that
|
||||
<UL>
|
||||
<LI> You can display multiple books in a help controller
|
||||
<LI> You can selectively search books. Try it!
|
||||
<LI> Index files are optional. This book doesn't supply an index, but it does supply
|
||||
a contents (.hhc) file. You must always supply a contents file because
|
||||
<UL>
|
||||
<LI> Contents trees rule :-)
|
||||
<LI> The search algorithm uses the contents tree to find out which pages are
|
||||
available.
|
||||
</UL>
|
||||
Wanna know what a contents file looks like? Click <a href="another.hhc">here</a>
|
||||
</UL>
|
||||
You can also view the <a href="another.hhp">project file</a> for this book.
|
||||
</body>
|
||||
</html>
|
@@ -0,0 +1,4 @@
|
||||
<html><title>Book 1</title><body>
|
||||
<h2>Book 1.</h2>
|
||||
How do you enjoy <i> book one</i>??
|
||||
</body></html>
|
@@ -0,0 +1,5 @@
|
||||
<html><title>Book 1</title><body>
|
||||
<h2>Book 2.</h2>
|
||||
How do you enjoy <i> book two</i>??
|
||||
<p>Please click <a href="page2-b.htm">HERE</a>
|
||||
</body></html>
|
@@ -0,0 +1,28 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
|
||||
<HTML>
|
||||
<HEAD>
|
||||
<meta name="GENERATOR" content="Microsoft® HTML Help Workshop 4.1">
|
||||
<!-- Sitemap 1.0 -->
|
||||
</HEAD><BODY>
|
||||
<OBJECT type="text/site properties">
|
||||
<param name="ImageType" value="Folder">
|
||||
</OBJECT>
|
||||
<UL>
|
||||
<LI> <OBJECT type="text/sitemap">
|
||||
<param name="Name" value="Book 1">
|
||||
<param name="Local" value="book1.htm">
|
||||
</OBJECT>
|
||||
<LI> <OBJECT type="text/sitemap">
|
||||
<param name="Name" value="Book 2">
|
||||
<param name="ID" value=34>
|
||||
<param name="Local" value="book2.htm">
|
||||
</OBJECT>
|
||||
<UL>
|
||||
<LI> <OBJECT type="text/sitemap">
|
||||
<param name="Name" value="sub book">
|
||||
<param name="Local" value="page2-b.htm">
|
||||
</OBJECT>
|
||||
</UL>
|
||||
</UL>
|
||||
</BODY></HTML>
|
||||
|
@@ -0,0 +1,5 @@
|
||||
<html><body>
|
||||
<h2>This is main page.</h2>
|
||||
<a href="book1.htm">Book 1</a><br>
|
||||
<a href="book2.htm">Book 2</a><br>
|
||||
</body></html>
|
@@ -0,0 +1,5 @@
|
||||
<html><body>
|
||||
<font color="#FF0000" size=+4 face="Tahoma">
|
||||
Hello, you're on sub page of page 2 !!!
|
||||
</font>
|
||||
</body></html>
|
16
wxPython/samples/wxPIA_book/Chapter-16/helpfiles/testing.hhp
Normal file
16
wxPython/samples/wxPIA_book/Chapter-16/helpfiles/testing.hhp
Normal file
@@ -0,0 +1,16 @@
|
||||
[OPTIONS]
|
||||
Compatibility=1.1
|
||||
Compiled file=testing.chm
|
||||
Contents file=contents.hhc
|
||||
Display compile progress=No
|
||||
Index file=Index.hhk
|
||||
Language=0x405 Èesky
|
||||
Title=Test HELPFILE
|
||||
Default topic=main.htm
|
||||
|
||||
[FILES]
|
||||
main.htm
|
||||
book1.htm
|
||||
book2.htm
|
||||
page2-b.htm
|
||||
|
59
wxPython/samples/wxPIA_book/Chapter-16/html_help.py
Normal file
59
wxPython/samples/wxPIA_book/Chapter-16/html_help.py
Normal file
@@ -0,0 +1,59 @@
|
||||
"""
|
||||
wxPython can use html files for online help or other forms of
|
||||
documentation for your application. The help can be organized as a
|
||||
collection of books, and there is a help viewer available that enables
|
||||
the user to browse by book, via an index or full text search. The
|
||||
format of the contents and index files are similar to Microsoft
|
||||
HtmlHelp.
|
||||
"""
|
||||
|
||||
import wx
|
||||
import wx.html
|
||||
|
||||
class MyHtmlFrame(wx.Frame):
|
||||
def __init__(self, parent, title):
|
||||
wx.Frame.__init__(self, parent, -1, title)
|
||||
p = wx.Panel(self)
|
||||
b1 = wx.Button(p, -1, "Show Help Contents")
|
||||
b2 = wx.Button(p, -1, "Show Help Index")
|
||||
b3 = wx.Button(p, -1, "Show Specific Help")
|
||||
self.Bind(wx.EVT_BUTTON, self.OnShowHelpContents, b1)
|
||||
self.Bind(wx.EVT_BUTTON, self.OnShowHelpIndex, b2)
|
||||
self.Bind(wx.EVT_BUTTON, self.OnShowSpecificHelp, b3)
|
||||
|
||||
sizer = wx.BoxSizer(wx.VERTICAL)
|
||||
sizer.Add((10,10))
|
||||
sizer.Add(b1, 0, wx.ALL, 10)
|
||||
sizer.Add(b2, 0, wx.ALL, 10)
|
||||
sizer.Add(b3, 0, wx.ALL, 10)
|
||||
p.SetSizer(sizer)
|
||||
|
||||
self.InitHelp()
|
||||
|
||||
|
||||
def InitHelp(self):
|
||||
def _addBook(filename):
|
||||
if not self.help.AddBook(filename):
|
||||
wx.MessageBox("Unable to open: " + filename,
|
||||
"Error", wx.OK|wx.ICON_EXCLAMATION)
|
||||
|
||||
self.help = wx.html.HtmlHelpController()
|
||||
|
||||
_addBook("helpfiles/testing.hhp")
|
||||
_addBook("helpfiles/another.hhp")
|
||||
|
||||
|
||||
def OnShowHelpContents(self, evt):
|
||||
self.help.DisplayContents()
|
||||
|
||||
def OnShowHelpIndex(self, evt):
|
||||
self.help.DisplayIndex()
|
||||
|
||||
def OnShowSpecificHelp(self, evt):
|
||||
self.help.Display("sub book")
|
||||
|
||||
|
||||
app = wx.PySimpleApp()
|
||||
frm = MyHtmlFrame(None, "HTML Help")
|
||||
frm.Show()
|
||||
app.MainLoop()
|
71
wxPython/samples/wxPIA_book/Chapter-16/html_tag.py
Normal file
71
wxPython/samples/wxPIA_book/Chapter-16/html_tag.py
Normal file
@@ -0,0 +1,71 @@
|
||||
import wx
|
||||
import wx.html
|
||||
|
||||
page = """<html><body>
|
||||
|
||||
This silly example shows how custom tags can be defined and used in a
|
||||
wx.HtmlWindow. We've defined a new tag, <blue> that will change
|
||||
the <blue>foreground color</blue> of the portions of the document that
|
||||
it encloses to some shade of blue. The tag handler can also use
|
||||
parameters specifed in the tag, for example:
|
||||
|
||||
<ul>
|
||||
<li> <blue shade='sky'>Sky Blue</blue>
|
||||
<li> <blue shade='midnight'>Midnight Blue</blue>
|
||||
<li> <blue shade='dark'>Dark Blue</blue>
|
||||
<li> <blue shade='navy'>Navy Blue</blue>
|
||||
</ul>
|
||||
|
||||
</body></html>
|
||||
"""
|
||||
|
||||
|
||||
class BlueTagHandler(wx.html.HtmlWinTagHandler):
|
||||
def __init__(self):
|
||||
wx.html.HtmlWinTagHandler.__init__(self)
|
||||
|
||||
def GetSupportedTags(self):
|
||||
return "BLUE"
|
||||
|
||||
def HandleTag(self, tag):
|
||||
old = self.GetParser().GetActualColor()
|
||||
clr = "#0000FF"
|
||||
if tag.HasParam("SHADE"):
|
||||
shade = tag.GetParam("SHADE")
|
||||
if shade.upper() == "SKY":
|
||||
clr = "#3299CC"
|
||||
if shade.upper() == "MIDNIGHT":
|
||||
clr = "#2F2F4F"
|
||||
elif shade.upper() == "DARK":
|
||||
clr = "#00008B"
|
||||
elif shade.upper == "NAVY":
|
||||
clr = "#23238E"
|
||||
|
||||
self.GetParser().SetActualColor(clr)
|
||||
self.GetParser().GetContainer().InsertCell(wx.html.HtmlColourCell(clr))
|
||||
|
||||
self.ParseInner(tag)
|
||||
|
||||
self.GetParser().SetActualColor(old)
|
||||
self.GetParser().GetContainer().InsertCell(wx.html.HtmlColourCell(old))
|
||||
|
||||
return True
|
||||
|
||||
|
||||
wx.html.HtmlWinParser_AddTagHandler(BlueTagHandler)
|
||||
|
||||
|
||||
|
||||
class MyHtmlFrame(wx.Frame):
|
||||
def __init__(self, parent, title):
|
||||
wx.Frame.__init__(self, parent, -1, title)
|
||||
html = wx.html.HtmlWindow(self)
|
||||
if "gtk2" in wx.PlatformInfo:
|
||||
html.SetStandardFonts()
|
||||
html.SetPage(page)
|
||||
|
||||
|
||||
app = wx.PySimpleApp()
|
||||
frm = MyHtmlFrame(None, "Custom HTML Tag Handler")
|
||||
frm.Show()
|
||||
app.MainLoop()
|
19
wxPython/samples/wxPIA_book/Chapter-16/html_window.py
Normal file
19
wxPython/samples/wxPIA_book/Chapter-16/html_window.py
Normal file
@@ -0,0 +1,19 @@
|
||||
import wx
|
||||
import wx.html
|
||||
|
||||
class MyHtmlFrame(wx.Frame):
|
||||
def __init__(self, parent, title):
|
||||
wx.Frame.__init__(self, parent, -1, title)
|
||||
html = wx.html.HtmlWindow(self)
|
||||
if "gtk2" in wx.PlatformInfo:
|
||||
html.SetStandardFonts()
|
||||
|
||||
html.SetPage(
|
||||
"Here is some <b>formatted</b> <i><u>text</u></i> "
|
||||
"loaded from a <font color=\"red\">string</font>.")
|
||||
|
||||
|
||||
app = wx.PySimpleApp()
|
||||
frm = MyHtmlFrame(None, "Simple HTML")
|
||||
frm.Show()
|
||||
app.MainLoop()
|
@@ -0,0 +1,17 @@
|
||||
import wx
|
||||
import wx.html
|
||||
|
||||
class MyHtmlFrame(wx.Frame):
|
||||
def __init__(self, parent, title):
|
||||
wx.Frame.__init__(self, parent, -1, title, size=(600,400))
|
||||
html = wx.html.HtmlWindow(self)
|
||||
if "gtk2" in wx.PlatformInfo:
|
||||
html.SetStandardFonts()
|
||||
|
||||
wx.CallAfter(
|
||||
html.LoadPage, "http://wxwidgets.org/manuals/2.6.2/wx_wxbutton.html")
|
||||
|
||||
app = wx.PySimpleApp()
|
||||
frm = MyHtmlFrame(None, "Simple HTML Browser")
|
||||
frm.Show()
|
||||
app.MainLoop()
|
@@ -0,0 +1,21 @@
|
||||
import wx
|
||||
import wx.html
|
||||
|
||||
class MyHtmlFrame(wx.Frame):
|
||||
def __init__(self, parent, title):
|
||||
wx.Frame.__init__(self, parent, -1, title, size=(600,400))
|
||||
self.CreateStatusBar()
|
||||
|
||||
html = wx.html.HtmlWindow(self)
|
||||
if "gtk2" in wx.PlatformInfo:
|
||||
html.SetStandardFonts()
|
||||
html.SetRelatedFrame(self, self.GetTitle() + " -- %s")
|
||||
html.SetRelatedStatusBar(0)
|
||||
|
||||
wx.CallAfter(
|
||||
html.LoadPage, "http://wxwidgets.org/manuals/2.6.2/wx_wxbutton.html")
|
||||
|
||||
app = wx.PySimpleApp()
|
||||
frm = MyHtmlFrame(None, "Simple HTML Browser")
|
||||
frm.Show()
|
||||
app.MainLoop()
|
Reference in New Issue
Block a user