wx.html.HtmlWindow is probably the only class you will directly use unless you want to do something special (like adding new tag handlers or MIME filters).
The purpose of this class is to display rich content pages (either local file or downloaded via HTTP
protocol) in a window based on a subset of the HTML standard. The width of the window is constant, given in the constructor and virtual height is changed dynamically depending on page size. Once the window is created you can set its content by calling SetPage
with raw HTML, LoadPage
with a wx.FileSystem location or LoadFile
with a filename.
wx.html.HtmlWindow uses the wx.Image class for displaying images, so you need to initialize the handlers for any image formats you use before loading a page. See wx.InitAllImageHandlers
and wx.Image.AddHandler
.
This class supports the following styles:
wx.html.HW_SCROLLBAR_NEVER
: Never display scrollbars, not even when the page is larger than the window.
wx.html.HW_SCROLLBAR_AUTO
: Display scrollbars only if pageâs size exceeds windowâs size.
wx.html.HW_NO_SELECTION
: Donât allow the user to select text.
Handlers bound for the following event types will receive one of the wx.html.HtmlCellEvent wx.html.HtmlLinkEvent parameters.
EVT_HTML_CELL_CLICKED: A wx.html.HtmlCell was clicked.
EVT_HTML_CELL_HOVER: The mouse passed over a wx.html.HtmlCell.
EVT_HTML_LINK_CLICKED: A wx.html.HtmlCell which contains a hyperlink was clicked.
Note
If you want complete HTML/CSS support as well as a Javascript engine, consider using wx.html2.WebView instead.
Class Hierarchy¶Inheritance diagram for class
HtmlWindow:
Methods Summary¶ Properties Summary¶ Class API¶Possible constructors:
HtmlWindow() -> None HtmlWindow(parent, id=ID_ANY, pos=DefaultPosition, size=DefaultSize, style=HW_DEFAULT_STYLE, name="htmlWindow") -> None
HtmlWindow is probably the only class you will directly use unless you want to do something special (like adding new tag handlers or MIME filters).
__init__ (self)
Default constructor.
None
__init__ (self, parent, id=ID_ANY, pos=DefaultPosition, size=DefaultSize, style=HW_DEFAULT_STYLE, name=âhtmlWindowâ)
Constructor.
The parameters are the same as Scrolled.__init__
constructor.
None
Adds an input filter to the static list of available filters.
These filters are present by default:
text/html text/plain image/*
The plain text filter will be used if no other filter matches.
filter (wx.html.HtmlFilter)
None
Appends HTML fragment to currently displayed text and refreshes the window.
source (string) â HTML code fragment
bool
False
if an error occurred, True
otherwise.
variant (WindowVariant)
VisualAttributes
Retrieves the default cursor for a given HTMLCursor type.
type (HTMLCursor) â HTMLCursor type to retrieve.
Cursor
Added in version 4.1/wxWidgets-3.1.0.
Returns pointer to the top-level container.
Returns anchor within currently opened page (see wx.html.HtmlWindow.GetOpenedPage
).
If no page is opened or if the displayed page wasnât produced by call to LoadPage
, empty string is returned.
str
Returns full location of the opened page.
If no page is opened or if the displayed page wasnât produced by call to LoadPage
, empty string is returned.
str
Returns title of the opened page or ââ if the current page does not contain <TITLE
> tag.
str
Returns a pointer to the current parser.
Returns the related frame.
Frame
Moves back to the previous page.
Only pages displayed using LoadPage
are stored in history list.
bool
Returns True
if it is possible to go back in the history i.e.
HistoryBack
wonât fail.
bool
Returns True
if it is possible to go forward in the history i.e.
HistoryForward
wonât fail.
bool
Clears history.
None
Moves to next page in history.
Only pages displayed using LoadPage
are stored in history list.
bool
Loads an HTML page from a file and displays it.
filename (string)
bool
False
if an error occurred, True
otherwise
Unlike SetPage
this function first loads the HTML page from location and then displays it.
location (string) â The address of the document. See the FileSystem Overview for details on the address format and wx.FileSystem for a description of how the file is opened.
bool
False
if an error occurred, True
otherwise
This method is called when a mouse button is clicked inside wx.html.HtmlWindow.
The default behaviour is to emit a wx.html.HtmlCellEvent and, if the event was not processed or skipped, call OnLinkClicked
if the cell contains a hypertext link.
Overloading this method is deprecated; intercept the event instead.
cell (wx.html.HtmlCell) â The cell inside which the mouse was clicked, always a simple (i.e. non-container) cell
x (int) â The logical x coordinate of the click point
y (int) â The logical y coordinate of the click point
event (wx.MouseEvent) â The mouse event containing other information about the click
bool
True
if a link was clicked, False
otherwise.
This method is called when a mouse moves over an HTML cell.
Default behaviour is to emit a wx.html.HtmlCellEvent.
Overloading this method is deprecated; intercept the event instead.
cell (wx.html.HtmlCell) â The cell inside which the mouse is currently, always a simple (i.e. non-container) cell
x (int) â The logical x coordinate of the click point
y (int) â The logical y coordinate of the click point
None
Called when user clicks on hypertext link.
Default behaviour is to emit a wx.html.HtmlLinkEvent and, if the event was not processed or skipped, call LoadPage
and do nothing else.
Overloading this method is deprecated; intercept the event instead.
Also see wx.html.HtmlLinkInfo.
link (wx.html.HtmlLinkInfo)
None
Called when an URL is being opened (either when the user clicks on a link or an image is loaded).
The URL will be opened only if OnOpeningURL
returns HTML_OPEN
. This method is called by wx.html.HtmlParser.OpenURL
.
You can override OnOpeningURL
to selectively block some URLs (e.g. for security reasons) or to redirect them elsewhere. Default behaviour is to always return HTML_OPEN
.
type (HtmlURLType) â Indicates type of the resource. Is one of
wx.html.HTML_URL_PAGE
: Opening a HTML page.
wx.html.HTML_URL_IMAGE
: Opening an image.
wx.html.HTML_URL_OTHER
: Opening a resource that doesnât fall into any other category.
url (string) â URL being opened.
Pointer to String variable that must be filled with an URL if OnOpeningURL
returns HTML_REDIRECT
.
Tuple[HtmlOpeningStatus, str]
wx.html.HTML_OPEN
: Open the URL.
wx.html.HTML_BLOCK
: Deny access to the URL, wx.html.HtmlParser.OpenURL
will return None
.
wx.html.HTML_REDIRECT
: Donât open url, redirect to another URL. OnOpeningURL
must fill redirect with the new URL. OnOpeningURL
will be called again on returned URL.
Called on parsing <TITLE
> tag.
title (string)
None
This reads custom settings from Config.
It uses the path âpathâ if given, otherwise it saves info into currently selected path. The values are stored in sub-path wx.html.HtmlWindow. Read values: all things set by SetFonts
, SetBorders
.
cfg (wx.ConfigBase) â Config from which you want to read the configuration.
path (string) â Optional path in config tree. If not given current path is used.
None
anchor (String
)
bool
Selects all text in the window.
None
Selects the line of text that pos points at.
Note that pos is relative to the top of displayed page, not to windowâs origin, use wx.Scrolled.CalcUnscrolledPosition
to convert physical coordinate.
pos (wx.Point)
None
Selects the word at position pos.
Note that pos is relative to the top of displayed page, not to windowâs origin, use wx.Scrolled.CalcUnscrolledPosition
to convert physical coordinate.
pos (wx.Point)
None
Returns the current selection as plain text.
Returns an empty string if no text is currently selected.
str
This function sets the space between border of window and HTML contents.
See image:
b (int) â indentation from borders in pixels
None
Sets the default cursor for a given HTMLCursor type.
These cursors are used for all wx.html.HtmlWindow objects by default, but can be overridden on a per-window basis.
type (HTMLCursor) â HTMLCursor type to retrieve.
cursor (wx.Cursor) â The default cursor for the specified cursor type.
None
Added in version 4.1/wxWidgets-3.1.0.
This function sets font sizes and faces.
See wx.html.HtmlDCRenderer.SetFonts
for detailed description.
normal_face (string)
fixed_face (string)
sizes (list of integers)
None
Sets the source of a page and displays it, for example:
htmlwin.SetPage("<html><body>Hello, world!</body></html>")
If you want to load a document from some location use LoadPage
instead.
source (string) â The HTML to be displayed.
bool
False
if an error occurred, True
otherwise.
Sets the frame in which page title will be displayed.
format is the format of the frame title, e.g. âHtmlHelp : %sâ. It must contain exactly one s. This s is substituted with HTML page title.
frame (wx.Frame)
format (string)
None
SetRelatedStatusBar (self, index)
After calling SetRelatedFrame
, this sets statusbar slot where messages will be displayed.
(Default is -1 = no messages.)
index (int) â Statusbar slot number (0..n)
None
SetRelatedStatusBar (self, statusbar, index=0)
Sets the associated statusbar where messages will be displayed.
Call this instead of SetRelatedFrame
if you want statusbar updates only, no changing of the frame title.
statusbar (wx.StatusBar) â Statusbar pointer
index (int) â Statusbar slot number (0..n)
None
Added in version 2.9.0.
Sets default font sizes and/or default font size.
See wx.html.HtmlDCRenderer.SetStandardFonts
for detailed description.
size (int)
normal_face (string)
fixed_face (string)
None
Returns content of currently displayed page as plain text.
str
Saves custom settings into Config.
It uses the path âpathâ if given, otherwise it saves info into currently selected path. Regardless of whether the path is given or not, the function creates sub-path wx.html.HtmlWindow.
Saved values: all things set by SetFonts
, SetBorders
.
cfg (wx.ConfigBase) â Config to which you want to save the configuration.
path (string) â Optional path in config tree. If not given, the current path is used.
None
See GetOpenedAnchor
See GetOpenedPage
See GetParser
See GetRelatedFrame
and SetRelatedFrame
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4