wx.HyperlinkCtrl

Inheritance diagram for wx.HyperlinkCtrl:



Description

This class shows a static text element which links to an URL. Appearance and behaviour is completely customizable. In fact, when the user clicks on the hyperlink, a wx.HyperlinkEvent is sent but if that event is not handled (or it’s skipped; see wx.Event.Skip), then a call to wx.LaunchDefaultBrowser is done with the hyperlink’s URL.

Note

Note that standard wx.Window functions like SetBackgroundColour, SetFont, SetCursor, SetLabel can be used to customize appearance of the hyperlink.

Window Styles

Window Style Description
wx.HL_ALIGN_LEFT Align the text to the left.
wx.HL_ALIGN_RIGHT Align the text to the right.
wx.HL_ALIGN_CENTRE Center the text (horizontally).
wx.HL_CONTEXTMENU Pop up a context menu when the hyperlink is right-clicked. The context menu contains a “Copy URL” menu item which is automatically handled by the hyperlink and which just copies in the clipboard the URL (not the label) of the control.
wx.HL_DEFAULT_STYLE The default style for wx.HyperlinkCtrl: wx.NO_BORDER | wx.HL_CONTEXTMENU | wx.HL_ALIGN_CENTRE.

Event Handling

Event Name Description
wx.EVT_HYPERLINK(id, func) The hyperlink was (left) clicked. If this event is not handled in user’s code (or it’s skipped; see wx.Event.Skip), then a call to wx.LaunchDefaultBrowser is done with the hyperlink’s URL.

Control Appearance


wxMSW

wxMSW

wxMAC

wxMAC

wxGTK

wxGTK


Class API

Methods

__init__(parent, id, label, url, pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.HL_DEFAULT_STYLE, name=wx.HyperlinkCtrlNameStr)

A static text control that emulates a hyperlink. The link is displayed in an appropriate text style, derived from the control’s normal font. When the mouse rolls over the link, the cursor changes to a hand and the link’s color changes to the active color.

Clicking on the link does not launch a web browser; instead, a wx.HyperlinkEvent is fired.

Use the wx.EVT_HYPERLINK event binding to catch link events.

Parameters:


Returns:

wx.HyperlinkCtrl


GetHoverColour()

Returns the colour used to print the label of the hyperlink when the mouse is over the control.


Returns:

wx.Colour


GetNormalColour()

Returns the colour used to print the label when the link has never been clicked before (i.e. the link has not been visited) and the mouse is not over the control.


Returns:

wx.Colour


GetURL()

Returns the URL associated with the hyperlink.


Returns:

string


GetVisited()

Returns True if the hyperlink has already been clicked by the user at least one time.


Returns:

bool


GetVisitedColour()

Returns the colour used to print the label when the mouse is not over the control and the link has already been clicked before (i.e. the link has been visited).


Returns:

wx.Colour


SetHoverColour(colour)

Sets the colour used to print the label of the hyperlink when the mouse is over the control.

Parameters:


SetNormalColour(colour)

Sets the colour used to print the label when the link has never been clicked before (i.e. the link has not been visited) and the mouse is not over the control.

Parameters:


SetURL(url)

Sets the URL associated with the hyperlink.

Parameters:

  • url (string)

SetVisited(visited=True)

Marks the hyperlink as visited.

Parameters:

  • visited (bool)

See also

SetVisitedColour


SetVisitedColour(colour)

Sets the colour used to print the label when the mouse is not over the control and the link has already been clicked before (i.e. the link has been visited).

Parameters:


Properties

HoverColour
See GetHoverColour and SetHoverColour
NormalColour
See GetNormalColour and SetNormalColour
URL
See GetURL and SetURL
Visited
See GetVisited and SetVisited
VisitedColour
See GetVisitedColour and SetVisitedColour