Gtk.LinkButton¶
class — extends Button, Accessible, Actionable, Buildable, ConstraintTarget
A button with a hyperlink.
<picture> <source srcset="link-button-dark.png" media="(prefers-color-scheme: dark)"> <img alt="An example GtkLinkButton" src="link-button.png"> </picture>
It is useful to show quick links to resources.
A link button is created by calling either LinkButton.new or
LinkButton.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
LinkButton.set_uri.
By default, GtkLinkButton calls FileLauncher.launch when the button
is clicked. This behaviour can be overridden by connecting to the
LinkButton.activate-link signal and returning True from
the signal handler.
Shortcuts and Gestures¶
GtkLinkButton supports the following keyboard shortcuts:
- <kbd>Shift</kbd>+<kbd>F10</kbd> or <kbd>Menu</kbd> opens the context menu.
Actions¶
GtkLinkButton defines a set of built-in actions:
clipboard.copycopies the url to the clipboard.menu.popupopens 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 AccessibleRole.link role.
Constructors¶
new¶
Creates a new GtkLinkButton with the URI as its text.
Parameters:
uri— a valid URI
new_with_label¶
Creates a new GtkLinkButton containing a label.
Parameters:
uri— a valid URIlabel— the text of the button
Methods¶
get_uri¶
Retrieves the URI of the GtkLinkButton.
get_visited¶
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 LinkButton.set_visited.
set_uri¶
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¶
Sets the “visited” state of the GtkLinkButton.
See LinkButton.get_visited for more details.
Parameters:
visited— the new “visited” state
Properties¶
uri¶
The URI bound to this button.
visited¶
The 'visited' state of this button.
A visited link is drawn in a different color.
Signals¶
activate-link¶
Emitted each time the GtkLinkButton is clicked.
The default handler will call FileLauncher.launch with the URI
stored inside the LinkButton.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.