wx.adv.HyperlinkCtrl¶
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.adv.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 that standard wx.Window functions like wx.Window.SetBackgroundColour
, wx.Window.SetFont
, wx.Window.SetCursor
, wx.Window.SetLabel
can be used to customize appearance of the hyperlink.
Window Styles¶
This class supports the following styles:
wx.adv.HL_ALIGN_LEFT
: Align the text to the left.wx.adv.HL_ALIGN_RIGHT
: Align the text to the right. This style is not supported under Windows.wx.adv.HL_ALIGN_CENTRE
: Center the text (horizontally). This style is not supported under Windows.wx.adv.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.adv.HL_DEFAULT_STYLE
: The default style for wx.adv.HyperlinkCtrl: BORDER_NONE|wxHL_CONTEXTMENU|wxHL_ALIGN_CENTRE.
Events Emitted by this Class¶
Handlers bound for the following event types will receive a wx.adv.HyperlinkEvent parameter.
EVT_HYPERLINK: 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 LaunchDefaultBrowser is done with the hyperlink’s URL.
Currently this class is implemented using native support in wxGTK and wxMSW and a generic version is used by the other ports.
See also
Class Hierarchy¶
Control Appearance¶
Methods Summary¶
Creates the hyperlink control. |
|
Returns the colour used to print the label of the hyperlink when the mouse is over the control. |
|
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 the URL associated with the hyperlink. |
|
Returns |
|
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). |
|
Sets the colour used to print the label of the hyperlink when the mouse is over the control. |
|
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. |
|
Sets the URL associated with the hyperlink. |
|
Marks the hyperlink as visited (see |
|
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). |
Properties Summary¶
See |
|
See |
|
See |
|
See |
Class API¶
- class wx.adv.HyperlinkCtrl(Control)¶
Possible constructors:
HyperlinkCtrl() -> None HyperlinkCtrl(parent, id=ID_ANY, label='', url='', pos=DefaultPosition, size=DefaultSize, style=HL_DEFAULT_STYLE, name=HyperlinkCtrlNameStr) -> None
This class shows a static text element which links to an URL.
Methods¶
- __init__(self, *args, **kw)¶
-
__init__ (self)
- Return type:
None
__init__ (self, parent, id=ID_ANY, label=’’, url=’’, pos=DefaultPosition, size=DefaultSize, style=HL_DEFAULT_STYLE, name=HyperlinkCtrlNameStr)
Constructor.
See
Create
for more info.- Parameters:
- Return type:
None
- Create(self, parent, id=ID_ANY, label='', url='', pos=DefaultPosition, size=DefaultSize, style=HL_DEFAULT_STYLE, name=HyperlinkCtrlNameStr)¶
Creates the hyperlink control.
- Parameters:
parent (wx.Window) – Parent window. Must not be
None
.id (wx.WindowID) – Window identifier. A value of
wx.ID_ANY
indicates a default value.label (string) – The label of the hyperlink.
url (string) – The URL associated with the given label.
pos (wx.Point) – Window position.
size (wx.Size) – Window size. If the DefaultSize is specified then the window is sized appropriately.
style (long) – Window style. See wx.adv.HyperlinkCtrl.
name (string) – Window name.
- Return type:
bool
- static GetClassDefaultAttributes(variant=WINDOW_VARIANT_NORMAL)¶
- Parameters:
variant (WindowVariant)
- Return type:
VisualAttributes
- GetHoverColour(self)¶
Returns the colour used to print the label of the hyperlink when the mouse is over the control.
- Return type:
Colour
- GetNormalColour(self)¶
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.
- Return type:
Colour
- GetURL(self)¶
Returns the URL associated with the hyperlink.
- Return type:
str
- GetVisited(self)¶
Returns
True
if the hyperlink has already been clicked by the user at least one time.- Return type:
bool
- GetVisitedColour(self)¶
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).
- Return type:
Colour
- SetHoverColour(self, colour)¶
Sets the colour used to print the label of the hyperlink when the mouse is over the control.
- Parameters:
colour (wx.Colour)
- Return type:
None
- SetNormalColour(self, 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:
colour (wx.Colour)
- Return type:
None
- SetURL(self, url)¶
Sets the URL associated with the hyperlink.
- Parameters:
url (string)
- Return type:
None
- SetVisited(self, visited=True)¶
Marks the hyperlink as visited (see
wx.adv.HyperlinkCtrl.SetVisitedColour
).- Parameters:
visited (bool)
- Return type:
None
- SetVisitedColour(self, 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:
colour (wx.Colour)
- Return type:
None
Properties¶
- HoverColour¶
See
GetHoverColour
andSetHoverColour
- NormalColour¶
See
GetNormalColour
andSetNormalColour
- Visited¶
See
GetVisited
andSetVisited
- VisitedColour¶
See
GetVisitedColour
andSetVisitedColour