class LinkButton(**properties: Any)

Superclasses: Button, Widget, InitiallyUnowned, Object

Implemented Interfaces: Accessible, Actionable, Buildable, ConstraintTarget

A GtkLinkButton is a button with a hyperlink.

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.

CSS nodes

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


GtkLinkButton uses the LINK role.


class LinkButton
classmethod new(uri: str) Widget

Creates a new GtkLinkButton with the URI as its text.


uri – a valid URI

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

Creates a new GtkLinkButton containing a label.

  • uri – a valid URI

  • label – the text of the button


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.


uri – a valid URI

set_visited(visited: bool) None

Sets the “visited” state of the GtkLinkButton.

See get_visited for more details.


visited – the new “visited” state


class LinkButton
props.uri: str

The URI bound to this button.

props.visited: bool

The ‘visited’ state of this button.

A visited link is drawn in a different color.


class LinkButton.signals

Emitted each time the GtkLinkButton is clicked.

The default handler will call launch with the URI stored inside the uri property.

To override the default behavior, you can connect to the ::activate-link signal and stop the propagation of the signal by returning True from your handler.