Skip to content

Gtk.UriLauncher

class — extends GObject.Object

Asynchronous API to open a uri with an application.

GtkUriLauncher collects the arguments that are needed to open the uri.

Depending on system configuration, user preferences and available APIs, this may or may not show an app chooser dialog or launch the default application right away.

The operation is started with the UriLauncher.launch function.

To launch a file, use FileLauncher.

Constructors

new

@classmethod
def new(cls, uri: str | None = ...) -> UriLauncher

Creates a new GtkUriLauncher object.

Parameters:

  • uri — the uri to open

Methods

can_launch

def can_launch(self, parent: Window | None = ...) -> bool

Returns whether the launcher is likely to succeed in launching an application for its uri.

This can be used to disable controls that trigger the launcher when they are known not to work.

Parameters:

  • parent — the parent window

get_uri

def get_uri(self) -> str | None

Gets the uri that will be opened.

launch

def launch(self, parent: Window | None = ..., cancellable: Gio.Cancellable | None = ..., callback: Gio.AsyncReadyCallback | None = ...) -> None

Launches an application to open the uri.

This may present an app chooser dialog to the user.

Parameters:

  • parent — the parent window
  • cancellable — a cancellable to cancel the operation
  • callback — a callback to call when the operation is complete

launch_finish

def launch_finish(self, result: Gio.AsyncResult) -> bool

Finishes the UriLauncher.launch call and returns the result.

Parameters:

  • result — the result

set_uri

def set_uri(self, uri: str | None = ...) -> None

Sets the uri that will be opened.

Parameters:

  • uri — the uri

Properties

uri

uri: str  # read/write

The uri to launch.