AGW Logo

agw_title HyperLinkCtrl

HyperLinkCtrl is a control for wxPython that acts like a hyper link in a typical browser. Latest features include the ability to capture your own left, middle, and right click events to perform your own custom event handling and ability to open link in a new or current browser window.

hierarchy Inheritance Diagram

Inheritance diagram for: HyperLinkCtrl

Inheritance diagram of HyperLinkCtrl


appearance Control Appearance


HyperLinkCtrl

HyperLinkCtrl


method_summary Methods Summary

__init__Default class constructor.
AutoBrowseAutomatically browse to URL when clicked.
DisplayErrorDisplays an error message (according to the ReportErrors parameter) in a
DoPopupSets whether to show popup menu on right click or not.
EnableRolloverEnable/disable rollover.
GetBoldReturns whether the HyperLinkCtrl has text in bold or not.
GetColoursGets the colours for the link, the visited link and the mouse
GetLinkCursorGets the link cursor.
GetURLRetrieve the URL associated to the HyperLinkCtrl.
GetUnderlinesReturns if link is underlined, if the mouse rollover is
GetVisitedReturns whether a link has been visited or not.
GotoURLGoto the specified URL.
OnMouseEventHandles the wx.EVT_MOUSE_EVENTS events for HyperLinkCtrl.
OnPopUpCopyHandles the wx.EVT_MENU event for HyperLinkCtrl.
OpenInSameWindowOpen multiple URL in the same window (if possible).
ReportErrorsSet whether to report browser errors or not.
SetBoldSets the HyperLinkCtrl label in bold text.
SetColoursSets the colours for the link, the visited link and the mouse rollover.
SetLinkCursorSets link cursor properties.
SetURLSets the HyperLinkCtrl text to the specified URL.
SetUnderlinesSets whether the text should be underlined or not for new links, visited links and rollovers.
SetVisitedSets a link as visited.
UpdateLinkUpdates the link, changing text properties if:

API Class API

class HyperLinkCtrl(StaticText)[source]

HyperLinkCtrl is a control for wxPython that acts like a hyper link in a typical browser. Latest features include the ability to capture your own left, middle, and right click events to perform your own custom event handling and ability to open link in a new or current browser window.



__init__(parent, id=-1, label="", pos=wx.DefaultPosition, size=wx.DefaultSize, style=0, name="staticText", URL="")[source]

Default class constructor.

Parameters:
  • parent – the window parent. Must not be None;
  • id – window identifier. A value of -1 indicates a default value;
  • label – the control label;
  • pos – the control position. A value of (-1, -1) indicates a default position, chosen by either the windowing system or wxPython, depending on platform;
  • size – the control size. A value of (-1, -1) indicates a default size, chosen by either the windowing system or wxPython, depending on platform;
  • style – the window style;
  • name – the window name;
  • URL – a string specifying the url link to navigate to.

Note

Pass URL=”” to use the label as the url link to navigate to.



AutoBrowse(AutoBrowse=True)[source]

Automatically browse to URL when clicked.

Parameters:AutoBrowseTrue to automatically browse to an URL when clicked, False otherwise.

Note

Set AutoBrowse to False to receive EVT_HYPERLINK_LEFT events.



DisplayError(ErrorMessage, ReportErrors=True)[source]

Displays an error message (according to the ReportErrors parameter) in a wx.MessageBox.

Parameters:
  • ErrorMessage – a string representing the error to display;
  • ReportErrorsTrue to display error dialog if an error occurrs navigating to the URL.


DoPopup(DoPopup=True)[source]

Sets whether to show popup menu on right click or not.

Parameters:DoPopupTrue to show a popup menu on right click, False otherwise.


EnableRollover(EnableRollover=False)[source]

Enable/disable rollover.

Parameters:EnableRolloverTrue to enable text effects during rollover, False to disable them.


GetBold()[source]

Returns whether the HyperLinkCtrl has text in bold or not.



GetColours()[source]

Gets the colours for the link, the visited link and the mouse rollover.



GetLinkCursor()[source]

Gets the link cursor.



GetURL()[source]

Retrieve the URL associated to the HyperLinkCtrl.



GetUnderlines()[source]

Returns if link is underlined, if the mouse rollover is underlined and if the visited link is underlined.



GetVisited()[source]

Returns whether a link has been visited or not.



GotoURL(URL, ReportErrors=True, NotSameWinIfPossible=False)[source]

Goto the specified URL.

Parameters:
  • URL – the url link we wish to navigate;
  • ReportErrors – Use True to display error dialog if an error occurrs navigating to the URL;
  • NotSameWinIfPossible – Use True to attempt to open the URL in new browser window.


OnMouseEvent(event)[source]

Handles the wx.EVT_MOUSE_EVENTS events for HyperLinkCtrl.

Parameters:event – a wx.MouseEvent event to be processed.


OnPopUpCopy(event)[source]

Handles the wx.EVT_MENU event for HyperLinkCtrl.

Parameters:event – a wx.MenuEvent event to be processed.

Note

This method copies the data from the HyperLinkCtrl to the clipboard.



OpenInSameWindow(NotSameWinIfPossible=False)[source]

Open multiple URL in the same window (if possible).

Parameters:NotSameWinIfPossibleTrue to open an hyperlink in a new browser window, False to use an existing browser window.


ReportErrors(ReportErrors=True)[source]

Set whether to report browser errors or not.

Parameters:ReportErrors – Use True to display error dialog if an error occurrs navigating to the URL;


SetBold(Bold=False)[source]

Sets the HyperLinkCtrl label in bold text.

Parameters:BoldTrue to set the HyperLinkCtrl label as bold, False otherwise.


SetColours(link=wx.Colour(0, 0, 255), visited=wx.Colour(79, 47, 79), rollover=wx.Colour(0, 0, 255))[source]

Sets the colours for the link, the visited link and the mouse rollover.

  • Visited link: VIOLET
  • Rollover: BLUE
Parameters:
  • link – a valid wx.Colour to use as text foreground for new links (default=RED);
  • visited – a valid wx.Colour to use as text foreground for visited links (default=VIOLET);

  • rollover – a valid wx.Colour to use as text foreground for links rollovers (default=BLUE).



SetLinkCursor(cur=wx.CURSOR_HAND)[source]

Sets link cursor properties.

Parameters:cur – an integer representing a wx.StockCursor constant.


SetURL(URL)[source]

Sets the HyperLinkCtrl text to the specified URL.

Parameters:URL – the new URL associated with HyperLinkCtrl.


SetUnderlines(link=True, visited=True, rollover=True)[source]

Sets whether the text should be underlined or not for new links, visited links and rollovers.

Parameters:
  • linkTrue to set the text of new links as underlined, False otherwise;
  • visitedTrue to set the text of visited links as underlined, False otherwise;
  • rolloverTrue to set the text of rollovers as underlined, False otherwise.


SetVisited(Visited=False)[source]

Sets a link as visited.

Parameters:VisitedTrue to set a link as visited, False otherwise.


Updates the link, changing text properties if:

  • User specific setting;
  • Link visited;
  • New link;
Parameters:OnRefreshTrue to refresh the control, False otherwise.
Tree

Table Of Contents

Previous topic

hyperlink

Next topic

HyperLinkEvent