A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://wxpython.org/Phoenix/docs/html/wx.html.HtmlWindow.html below:

wx.html.HtmlWindow — wxPython Phoenix 4.2.4a1 documentation

wx.html.HtmlWindow¶

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 .

Window Styles¶

This class supports the following styles:

Events Emitted by this Class¶

Handlers bound for the following event types will receive one of the wx.html.HtmlCellEvent wx.html.HtmlLinkEvent parameters.

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¶
class wx.html.HtmlWindow(ScrolledWindow, HtmlWindowInterface)¶

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).


Methods¶
__init__(self, *args, **kw)¶

Overloaded Implementations:

__init__ (self)

Default constructor.

Return type:

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.

Parameters:
Return type:

None



static AddFilter(filter)¶

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.

Parameters:

filter (wx.html.HtmlFilter)

Return type:

None


AppendToPage(self, source)¶

Appends HTML fragment to currently displayed text and refreshes the window.

Parameters:

source (string) – HTML code fragment

Return type:

bool

Returns:

False if an error occurred, True otherwise.


static GetClassDefaultAttributes(variant=WINDOW_VARIANT_NORMAL)¶
Parameters:

variant (WindowVariant)

Return type:

VisualAttributes


static GetDefaultHTMLCursor(type)¶

Retrieves the default cursor for a given HTMLCursor type.

Parameters:

type (HTMLCursor) – HTMLCursor type to retrieve.

Return type:

Cursor

Added in version 4.1/wxWidgets-3.1.0.


GetInternalRepresentation(self)¶

Returns pointer to the top-level container.

Return type:

wx.html.HtmlContainerCell


GetOpenedAnchor(self)¶

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.

Return type:

str


GetOpenedPage(self)¶

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.

Return type:

str


GetOpenedPageTitle(self)¶

Returns title of the opened page or “” if the current page does not contain <TITLE> tag.

Return type:

str


GetParser(self)¶

Returns a pointer to the current parser.

Return type:

wx.html.HtmlWinParser


Returns the related frame.

Return type:

Frame


HistoryBack(self)¶

Moves back to the previous page.

Only pages displayed using LoadPage are stored in history list.

Return type:

bool


HistoryCanBack(self)¶

Returns True if it is possible to go back in the history i.e.

HistoryBack won’t fail.

Return type:

bool


HistoryCanForward(self)¶

Returns True if it is possible to go forward in the history i.e.

HistoryForward won’t fail.

Return type:

bool


HistoryClear(self)¶

Clears history.

Return type:

None


HistoryForward(self)¶

Moves to next page in history.

Only pages displayed using LoadPage are stored in history list.

Return type:

bool


LoadFile(self, filename)¶

Loads an HTML page from a file and displays it.

Parameters:

filename (string)

Return type:

bool

Returns:

False if an error occurred, True otherwise


LoadPage(self, location)¶

Unlike SetPage this function first loads the HTML page from location and then displays it.

Parameters:

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.

Return type:

bool

Returns:

False if an error occurred, True otherwise


OnCellClicked(self, cell, x, y, event)¶

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.

Parameters:
  • 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

Return type:

bool

Returns:

True if a link was clicked, False otherwise.


OnCellMouseHover(self, cell, x, y)¶

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.

Parameters:
  • 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

Return type:

None


OnLinkClicked(self, link)¶

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.

Parameters:

link (wx.html.HtmlLinkInfo)

Return type:

None


OnOpeningURL(self, type, url)¶

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 .

Parameters:
  • 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 .

Return type:

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.


OnSetTitle(self, title)¶

Called on parsing <TITLE> tag.

Parameters:

title (string)

Return type:

None


ReadCustomization(self, cfg, path='')¶

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 .

Parameters:
  • 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.

Return type:

None


ScrollToAnchor(self, anchor)¶
Parameters:

anchor (String)

Return type:

bool


SelectAll(self)¶

Selects all text in the window.

Return type:

None


SelectLine(self, pos)¶

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.

Parameters:

pos (wx.Point)

Return type:

None


SelectWord(self, pos)¶

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.

Parameters:

pos (wx.Point)

Return type:

None


SelectionToText(self)¶

Returns the current selection as plain text.

Returns an empty string if no text is currently selected.

Return type:

str


SetBorders(self, b)¶

This function sets the space between border of window and HTML contents.

See image:

Parameters:

b (int) – indentation from borders in pixels

Return type:

None


static SetDefaultHTMLCursor(type, cursor)¶

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.

Parameters:
  • type (HTMLCursor) – HTMLCursor type to retrieve.

  • cursor (wx.Cursor) – The default cursor for the specified cursor type.

Return type:

None

Added in version 4.1/wxWidgets-3.1.0.


SetFonts(self, normal_face, fixed_face, sizes)¶

This function sets font sizes and faces.

See wx.html.HtmlDCRenderer.SetFonts for detailed description.

Parameters:
  • normal_face (string)

  • fixed_face (string)

  • sizes (list of integers)

Return type:

None


SetPage(self, source)¶

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.

Parameters:

source (string) – The HTML to be displayed.

Return type:

bool

Returns:

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.

Parameters:
Return type:

None


Overloaded Implementations:

SetRelatedStatusBar (self, index)

After calling SetRelatedFrame , this sets statusbar slot where messages will be displayed.

(Default is -1 = no messages.)

Parameters:

index (int) – Statusbar slot number (0..n)

Return type:

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.

Parameters:
  • statusbar (wx.StatusBar) – Statusbar pointer

  • index (int) – Statusbar slot number (0..n)

Return type:

None

Added in version 2.9.0.



SetStandardFonts(self, size=-1, normal_face='', fixed_face='')¶

Sets default font sizes and/or default font size.

See wx.html.HtmlDCRenderer.SetStandardFonts for detailed description.

Parameters:
  • size (int)

  • normal_face (string)

  • fixed_face (string)

Return type:

None


ToText(self)¶

Returns content of currently displayed page as plain text.

Return type:

str


WriteCustomization(self, cfg, path='')¶

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 .

Parameters:
  • 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.

Return type:

None


Properties¶
InternalRepresentation¶

See GetInternalRepresentation


OpenedAnchor¶

See GetOpenedAnchor


OpenedPage¶

See GetOpenedPage


OpenedPageTitle¶

See GetOpenedPageTitle


Parser¶

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