Gtk.LinkButton


Gtk.LinkButton — Create buttons bound to a URL

Object Hierarchy:

    GObject
    ╰── GInitiallyUnowned
        ╰── Gtk.Widget
            ╰── Gtk.Container
                ╰── Gtk.Bin
                    ╰── Gtk.Button
                        ╰── Gtk.LinkButton

Functions:

Description:

A Gtk.LinkButton is a GtkButton with a hyperlink, similar to the one used by web browsers, which triggers an action when clicked. It is useful to show quick links to resources.

A link button is created by calling either Gtk.LinkButton::new() or 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 Gtk.LinkButton can be set specifically using Gtk.LinkButton::set_uri(), and retrieved using Gtk.LinkButton::get_uri().

By default, Gtk.LinkButton calls gtk_show_uri() when the button is clicked. This behaviour can be overridden by connecting to the signal handler.


Function Details:

new()

new (uri:str) -> Gtk.Widget

Creates a new Gtk.LinkButton with the URI as its text.

  • Returns: a new link button widget.

  • Since: 2.10


new_with_label()

new_with_label (uri:str, label:str=None) -> Gtk.Widget

Creates a new Gtk.LinkButton containing a label.

  • Returns: a new link button widget.

  • Since: 2.10


get_uri()

get_uri (self) -> str

Retrieves the URI set using Gtk.LinkButton:set_uri().

  • Returns: a valid URI. The returned string is owned by the link buttonand should not be modified or freed.

  • Since: 2.10


set_uri()

set_uri (self, uri:str)

Sets uri as the URI where the Gtk.LinkButton points. As a side-effectthis unsets the “visited” state of the button.

  • Since: 2.10

get_visited()

get_visited (self) -> bool

Retrieves the “visited” state of the URI where the Gtk.LinkButtonpoints. The button becomes visited when it is clicked. If the URIis changed on the button, the “visited” state is unset again. The state may also be changed using Gtk.LinkButton:set_visited().

  • Returns: True if the link has been visited, FALSE otherwise

  • Since: 2.14


set_visited()

set_visited (self, visited:bool)

Sets the “visited” state of the URI where the Gtk.LinkButtonpoints. See Gtk.LinkButton:get_visited() for more details.

  • Since: 2.14

Example:

import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk

class LinkButton(Gtk.Window):
    def __init__(self):
        Gtk.Window.__init__()
        self.connect("destroy", Gtk.main_quit)

        linkbutton = Gtk.LinkButton(uri="https://programmica.com/",
                                    label="Programmica")
        self.add(linkbutton)

window = LinkButton()
window.show_all()

Gtk.main()

results matching ""

    No results matching ""