LinkButton
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.
Accessibility
GtkLinkButton
uses the LINK
role.
Constructors
Methods
- class LinkButton
-
- 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 theGtkLinkButton
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
Signals
- class LinkButton.signals
- activate_link() → bool
Emitted each time the
GtkLinkButton
is clicked.The default handler will call
launch
with the URI stored inside theuri
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.