Gtk.LinkButton

g GObject.GInterface GObject.GInterface Gtk.Accessible Gtk.Accessible GObject.GInterface->Gtk.Accessible Gtk.Actionable Gtk.Actionable GObject.GInterface->Gtk.Actionable Gtk.Buildable Gtk.Buildable GObject.GInterface->Gtk.Buildable Gtk.ConstraintTarget Gtk.ConstraintTarget GObject.GInterface->Gtk.ConstraintTarget GObject.InitiallyUnowned GObject.InitiallyUnowned Gtk.Widget Gtk.Widget GObject.InitiallyUnowned->Gtk.Widget GObject.Object GObject.Object GObject.Object->GObject.InitiallyUnowned Gtk.Accessible->Gtk.Widget Gtk.Button Gtk.Button Gtk.Actionable->Gtk.Button Gtk.Buildable->Gtk.Widget Gtk.LinkButton Gtk.LinkButton Gtk.Button->Gtk.LinkButton Gtk.ConstraintTarget->Gtk.Widget Gtk.Widget->Gtk.Button

Example

../_images/LinkButton.png
Subclasses:

None

Methods

Inherited:

Gtk.Button (16), Gtk.Widget (181), GObject.Object (37), Gtk.Accessible (15), Gtk.Buildable (1), Gtk.Actionable (5)

Structs:

Gtk.WidgetClass (18), GObject.ObjectClass (5)

class

new (uri)

class

new_with_label (uri, label)

get_uri ()

get_visited ()

set_uri (uri)

set_visited (visited)

Virtual Methods

Inherited:

Gtk.Button (2), Gtk.Widget (25), GObject.Object (7), Gtk.Accessible (6), Gtk.Buildable (9), Gtk.Actionable (4)

Properties

Inherited:

Gtk.Button (6), Gtk.Widget (34), Gtk.Accessible (1), Gtk.Actionable (2)

Name

Type

Flags

Short Description

uri

str

r/w

visited

bool

r/w/en

Signals

Inherited:

Gtk.Button (2), Gtk.Widget (13), GObject.Object (1)

Name

Short Description

activate-link

Emitted each time the GtkLinkButton is clicked.

Fields

Inherited:

Gtk.Button (2), Gtk.Widget (13), GObject.Object (1)

Class Details

class Gtk.LinkButton(**kwargs)
Bases:

Gtk.Button

Abstract:

No

A GtkLinkButton is a button with a hyperlink.

An example Gtk.LinkButton

It is useful to show quick links to resources.

A link button is created by calling either [ctor`Gtk`.LinkButton.new] or [ctor`Gtk`.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 [method`Gtk`.LinkButton.set_uri].

By default, GtkLinkButton calls [method`Gtk`.FileLauncher.launch] when the button is clicked. This behaviour can be overridden by connecting to the [signal`Gtk`.LinkButton::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 Gtk.AccessibleRole.LINK role.

classmethod new(uri)[source]
Parameters:

uri (str) – a valid URI

Returns:

a new link button widget.

Return type:

Gtk.Widget

Creates a new GtkLinkButton with the URI as its text.

classmethod new_with_label(uri, label)[source]
Parameters:
  • uri (str) – a valid URI

  • label (str or None) – the text of the button

Returns:

a new link button widget.

Return type:

Gtk.Widget

Creates a new GtkLinkButton containing a label.

get_uri()[source]
Returns:

a valid URI. The returned string is owned by the link button and should not be modified or freed.

Return type:

str

Retrieves the URI of the GtkLinkButton.

get_visited()[source]
Returns:

True if the link has been visited, False otherwise

Return type:

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 [method`Gtk`.LinkButton.set_visited].

set_uri(uri)[source]
Parameters:

uri (str) – a valid URI

Sets uri as the URI where the GtkLinkButton points.

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

set_visited(visited)[source]
Parameters:

visited (bool) – the new “visited” state

Sets the “visited” state of the GtkLinkButton.

See [method`Gtk`.LinkButton.get_visited] for more details.

Signal Details

Signal Name:

activate-link

Flags:

RUN_LAST

Parameters:

link_button (Gtk.LinkButton) – The object which received the signal

Returns:

True if the signal has been handled

Return type:

bool

Emitted each time the GtkLinkButton is clicked.

The default handler will call [method`Gtk`.FileLauncher.launch] with the URI stored inside the [property`Gtk`.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.

Property Details

Gtk.LinkButton.props.uri
Name:

uri

Type:

str

Default Value:

None

Flags:

READABLE, WRITABLE

The URI bound to this button.

Gtk.LinkButton.props.visited
Name:

visited

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

The ‘visited’ state of this button.

A visited link is drawn in a different color.