Table Of Contents

Previous topic

GenericCalendarCtrl

Next topic

HyperlinkEvent

This Page

phoenix_title 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 HyperlinkEvent is sent but if that event is not handled (or it’s skipped; see Event.Skip ), then a call to LaunchDefaultBrowser is done with the hyperlink’s URL.

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

styles Window Styles

This class supports the following styles:

  • HL_ALIGN_LEFT: Align the text to the left.
  • HL_ALIGN_RIGHT: Align the text to the right. This style is not supported under Windows XP but is supported under all the other Windows versions.
  • HL_ALIGN_CENTRE: Center the text (horizontally). This style is not supported by the native MSW implementation used under Windows XP and later.
  • 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.
  • HL_DEFAULT_STYLE: The default style for HyperlinkCtrl: BORDER_NONE|HL_CONTEXTMENU|HL_ALIGN_CENTRE.

events Events Emitted by this Class

Handlers bound for the following event types will receive a HyperlinkEvent parameter.

  • EVT_HYPERLINK: The hyperlink was (left) clicked. If this event is not handled in user’s code (or it’s skipped; see 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 (under Windows XP and later only) and a generic version is used by the other ports.

See also

URL, HyperlinkEvent


class_hierarchy Inheritance Diagram

Inheritance diagram for class HyperlinkCtrl

Inheritance diagram of HyperlinkCtrl


appearance Control Appearance


wxMSW

wxMSW

wxMAC

wxMAC

wxGTK

wxGTK


method_summary Methods Summary

__init__  
Create Creates the hyperlink control.
GetHoverColour Returns the colour used to print the label of the hyperlink when the mouse is over the control.
GetNormalColour Returns the colour used to print the label when the link has never been clicked before (i.e.
GetURL Returns the URL associated with the hyperlink.
GetVisited Returns True if the hyperlink has already been clicked by the user at least one time.
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.
SetHoverColour Sets the colour used to print the label of the hyperlink when the mouse is over the control.
SetNormalColour Sets the colour used to print the label when the link has never been clicked before (i.e.
SetURL Sets the URL associated with the hyperlink.
SetVisited Marks the hyperlink as visited (see HyperlinkCtrl.SetVisitedColour ).
SetVisitedColour 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.

api Class API



class HyperlinkCtrl(Control)

This class shows a static text element which links to an URL.

Possible constructors:

HyperlinkCtrl()

HyperlinkCtrl(parent, id=ID_ANY, label='', url='',
              pos=DefaultPosition, size=DefaultSize, style=HL_DEFAULT_STYLE,
              name=HyperlinkCtrlNameStr)

Methods



__init__(self, *args, **kw)

overload Overloaded Implementations:



__init__ (self)



__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:
  • parent (Window) –
  • id (int) –
  • label (string) –
  • url (string) –
  • pos (Point) –
  • size (Size) –
  • style (long) –
  • name (string) –





Create(self, parent, id=ID_ANY, label='', url='', pos=DefaultPosition, size=DefaultSize, style=HL_DEFAULT_STYLE, name=HyperlinkCtrlNameStr)

Creates the hyperlink control.

Parameters:
  • parent (Window) – Parent window. Must not be None.
  • id (int) – Window identifier. A value of ID_ANY indicates a default value.
  • label (string) – The label of the hyperlink.
  • url (string) – The URL associated with the given label.
  • pos (Point) – Window position.
  • size (Size) – Window size. If the DefaultSize is specified then the window is sized appropriately.
  • style (long) – Window style. See HyperlinkCtrl.
  • name (string) – Window name.
Return type:

bool



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:string


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 (Colour) –


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 (Colour) –


SetURL(self, url)

Sets the URL associated with the hyperlink.

Parameters:url (string) –


SetVisited(self, visited=True)

Marks the hyperlink as visited (see HyperlinkCtrl.SetVisitedColour ).

Parameters:visited (bool) –


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 (Colour) –

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