.. include:: headings.inc .. currentmodule:: adv .. _adv.HyperlinkCtrl: ========================================================================================================================================== |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 :ref:`adv.HyperlinkEvent` is sent but if that event is not handled (or it's skipped; see :meth:`Event.Skip` ), then a call to :func:`LaunchDefaultBrowser` is done with the hyperlink's ``URL``. Note that standard :ref:`Window` functions like :meth:`Window.SetBackgroundColour` , :meth:`Window.SetFont` , :meth:`Window.SetCursor` , :meth:`Window.SetLabel` can be used to customize appearance of the hyperlink. .. _HyperlinkCtrl-styles: |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 :ref:`adv.HyperlinkCtrl`: BORDER_NONE|HL_CONTEXTMENU|HL_ALIGN_CENTRE. .. _HyperlinkCtrl-events: |events| Events Emitted by this Class ===================================== Handlers bound for the following event types will receive a :ref:`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 :meth:`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. .. seealso:: `URL`, :ref:`adv.HyperlinkEvent` | |class_hierarchy| Inheritance Diagram ===================================== Inheritance diagram for class **HyperlinkCtrl** .. raw:: html

Inheritance diagram of HyperlinkCtrl

| |appearance| Control Appearance =============================== | .. figure:: _static/images/widgets/fullsize/wxmsw/adv.hyperlinkctrl.png :alt: wxMSW :figclass: floatleft **wxMSW** .. figure:: _static/images/widgets/fullsize/wxmac/adv.hyperlinkctrl.png :alt: wxMAC :figclass: floatright **wxMAC** .. figure:: _static/images/widgets/fullsize/wxgtk/adv.hyperlinkctrl.png :alt: wxGTK :figclass: floatcenter **wxGTK** | |method_summary| Methods Summary ================================ ================================================================================ ================================================================================ :meth:`~HyperlinkCtrl.__init__` :meth:`~HyperlinkCtrl.Create` Creates the hyperlink control. :meth:`~HyperlinkCtrl.GetHoverColour` Returns the colour used to print the label of the hyperlink when the mouse is over the control. :meth:`~HyperlinkCtrl.GetNormalColour` Returns the colour used to print the label when the link has never been clicked before (i.e. :meth:`~HyperlinkCtrl.GetURL` Returns the ``URL`` associated with the hyperlink. :meth:`~HyperlinkCtrl.GetVisited` Returns ``True`` if the hyperlink has already been clicked by the user at least one time. :meth:`~HyperlinkCtrl.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. :meth:`~HyperlinkCtrl.SetHoverColour` Sets the colour used to print the label of the hyperlink when the mouse is over the control. :meth:`~HyperlinkCtrl.SetNormalColour` Sets the colour used to print the label when the link has never been clicked before (i.e. :meth:`~HyperlinkCtrl.SetURL` Sets the ``URL`` associated with the hyperlink. :meth:`~HyperlinkCtrl.SetVisited` Marks the hyperlink as visited (see :meth:`HyperlinkCtrl.SetVisitedColour` ). :meth:`~HyperlinkCtrl.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. ================================================================================ ================================================================================ | |property_summary| Properties Summary ===================================== ================================================================================ ================================================================================ :attr:`~HyperlinkCtrl.HoverColour` See :meth:`~HyperlinkCtrl.GetHoverColour` and :meth:`~HyperlinkCtrl.SetHoverColour` :attr:`~HyperlinkCtrl.NormalColour` See :meth:`~HyperlinkCtrl.GetNormalColour` and :meth:`~HyperlinkCtrl.SetNormalColour` :attr:`~HyperlinkCtrl.URL` See :meth:`~HyperlinkCtrl.GetURL` and :meth:`~HyperlinkCtrl.SetURL` :attr:`~HyperlinkCtrl.Visited` See :meth:`~HyperlinkCtrl.GetVisited` and :meth:`~HyperlinkCtrl.SetVisited` :attr:`~HyperlinkCtrl.VisitedColour` See :meth:`~HyperlinkCtrl.GetVisitedColour` and :meth:`~HyperlinkCtrl.SetVisitedColour` ================================================================================ ================================================================================ | |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) .. method:: __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 :meth:`Create` for more info. :param `parent`: :type `parent`: Window :param `id`: :type `id`: int :param `label`: :type `label`: string :param `url`: :type `url`: string :param `pos`: :type `pos`: Point :param `size`: :type `size`: Size :param `style`: :type `style`: long :param `name`: :type `name`: string **~~~** .. method:: Create(self, parent, id=ID_ANY, label='', url='', pos=DefaultPosition, size=DefaultSize, style=HL_DEFAULT_STYLE, name=HyperlinkCtrlNameStr) Creates the hyperlink control. :param `parent`: Parent window. Must not be ``None``. :type `parent`: Window :param `id`: Window identifier. A value of ``ID_ANY`` indicates a default value. :type `id`: int :param `label`: The label of the hyperlink. :type `label`: string :param `url`: The ``URL`` associated with the given label. :type `url`: string :param `pos`: Window position. :type `pos`: Point :param `size`: Window size. If the DefaultSize is specified then the window is sized appropriately. :type `size`: Size :param `style`: Window style. See :ref:`adv.HyperlinkCtrl`. :type `style`: long :param `name`: Window name. :type `name`: string :rtype: `bool` .. method:: GetHoverColour(self) Returns the colour used to print the label of the hyperlink when the mouse is over the control. :rtype: :ref:`Colour` .. method:: 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. :rtype: :ref:`Colour` .. method:: GetURL(self) Returns the ``URL`` associated with the hyperlink. :rtype: `string` .. method:: GetVisited(self) Returns ``True`` if the hyperlink has already been clicked by the user at least one time. :rtype: `bool` .. method:: 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`). :rtype: :ref:`Colour` .. method:: SetHoverColour(self, colour) Sets the colour used to print the label of the hyperlink when the mouse is over the control. :param `colour`: :type `colour`: Colour .. method:: 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. :param `colour`: :type `colour`: Colour .. method:: SetURL(self, url) Sets the ``URL`` associated with the hyperlink. :param `url`: :type `url`: string .. method:: SetVisited(self, visited=True) Marks the hyperlink as visited (see :meth:`HyperlinkCtrl.SetVisitedColour` ). :param `visited`: :type `visited`: bool .. method:: 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`). :param `colour`: :type `colour`: Colour .. attribute:: HoverColour See :meth:`~HyperlinkCtrl.GetHoverColour` and :meth:`~HyperlinkCtrl.SetHoverColour` .. attribute:: NormalColour See :meth:`~HyperlinkCtrl.GetNormalColour` and :meth:`~HyperlinkCtrl.SetNormalColour` .. attribute:: URL See :meth:`~HyperlinkCtrl.GetURL` and :meth:`~HyperlinkCtrl.SetURL` .. attribute:: Visited See :meth:`~HyperlinkCtrl.GetVisited` and :meth:`~HyperlinkCtrl.SetVisited` .. attribute:: VisitedColour See :meth:`~HyperlinkCtrl.GetVisitedColour` and :meth:`~HyperlinkCtrl.SetVisitedColour`