LinkButton#

class LinkButton(**properties: Any)#

Superclasses: Button, Widget, InitiallyUnowned, Object

Implemented Interfaces: Accessible, Actionable, Buildable, ConstraintTarget

A GtkLinkButton is a button with a hyperlink.

https://docs.gtk.org/gtk4/link-button.png

It is useful to show quick links to resources.

A link button is created by calling either new or new_with_label. If using the former, the URI you pass to the constructor is used as a label for the widget.

The URI bound to a GtkLinkButton can be set specifically using set_uri.

By default, GtkLinkButton calls launch when the button is clicked. This behaviour can be overridden by connecting to the activate_link signal and returning True from the signal handler.

Shortcuts and Gestures#

GtkLinkButton supports the following keyboard shortcuts:

  • Shift`+:kbd:`F10 or Menu opens the context menu.

Actions#

GtkLinkButton defines a set of built-in actions:

  • clipboard.copy copies the url to the clipboard.

  • menu.popup opens the context menu.

CSS nodes#

GtkLinkButton has a single CSS node with name button. To differentiate it from a plain GtkButton, it gets the .link style class.

Accessibility#

GtkLinkButton uses the LINK role.

Constructors#

class LinkButton
classmethod new(uri: str) Widget#

Creates a new GtkLinkButton with the URI as its text.

Parameters:

uri – a valid URI

classmethod new_with_label(uri: str, label: str | None = None) Widget#

Creates a new GtkLinkButton containing a label.

Parameters:
  • uri – a valid URI

  • label – the text of the button

Methods#

class LinkButton
get_uri() str#

Retrieves the URI of the GtkLinkButton.

get_visited() bool#

Retrieves the “visited” state of the GtkLinkButton.

The button becomes visited when it is clicked. If the URI is changed on the button, the “visited” state is unset again.

The state may also be changed using set_visited.

set_uri(uri: str) None#

Sets uri as the URI where the GtkLinkButton points.

As a side-effect this unsets the “visited” state of the button.

Parameters:

uri – a valid URI

set_visited(visited: bool) None#

Sets the “visited” state of the GtkLinkButton.

See get_visited for more details.

Parameters:

visited – the new “visited” state

Properties#

class LinkButton
props.uri: str#

The type of the None singleton.

props.visited: bool#

The type of the None singleton.

Signals#

class LinkButton.signals

The type of the None singleton.