textual_wrapper.wrapper

Wrappers.

Wrapper

The Wrapper for the current operating system and desktop environment

textual_wrapper.wrapper.gtk

Provides access to MainWindow, Terminal, WrapperGtk, and WrapperWindow, or their Unity Launcher counterparts in unity if supported by the current desktop environment.

textual_wrapper.wrapper.gtk.base

GTK wrapper (base implementation).

Classes:

MainWindow()

The main window, containing the terminal widget.

Terminal

Terminal widget for displaying a Textual app.

WrapperGtk(name, arguments[, icon, ...])

A GTK3-based wrapper around a terminal app.

WrapperWindow(wrapper)

Standalone terminal wrapper for the app.

class MainWindow[source]

Bases: ScrolledWindow

The main window, containing the terminal widget.

Methods:

add_widget(widget)

Add a widget to the window.

add_widget(widget)[source]

Add a widget to the window.

Parameters

widget (Widget)

Return type

MainWindow

class Terminal[source]

Bases: Terminal

Terminal widget for displaying a Textual app.

Attributes:

background_colour

Colour to use for the terminal background.

Methods:

get_color_background()

Returns the background colour for text which does not have a specific background colour assigned.

hide_cursor()

Hide the blinking cursor by setting its foreground colour to the background colour.

new()

Create the terminal widget.

set_color_background(background)

Sets the background colour for text which does not have a specific background colour assigned.

spawn_app(arguments, working_directory[, ...])

Launch the app in the terminal.

property background_colour

Colour to use for the terminal background.

Return type

RGBA

get_color_background()[source]

Returns the background colour for text which does not have a specific background colour assigned.

New in version 0.4.0.

Return type

RGBA

hide_cursor()[source]

Hide the blinking cursor by setting its foreground colour to the background colour.

New in version 0.4.0.

classmethod new()[source]

Create the terminal widget.

Return type

Terminal

set_color_background(background)[source]

Sets the background colour for text which does not have a specific background colour assigned.

Only has effect when no background image is set and when the terminal is not transparent.

Parameters

background (RGBA) – The new background colour

New in version 0.4.0.

spawn_app(arguments, working_directory, callback=None)[source]

Launch the app in the terminal.

Parameters
  • arguments (list[str]) – The app executable and any arguments to pass to it.

  • working_directory (str) – Directory to execute the application in.

  • callback (Optional[Callable[Terminal, int, Any, None]]) – Function to call when the app has launched, which is passed the terminal, the child process id, and any errors. Default None.

class WrapperGtk(name, arguments, icon=None, launcher_options=<factory>, menu_options=<factory>, wrapper_window_cls=<class 'WrapperWindow'>)[source]

Bases: Wrapper

A GTK3-based wrapper around a terminal app.

Methods:

run([working_directory])

Launch the wrapper.

Classes:

wrapper_window_cls

The GTK wrapper window itself.

run(working_directory=None)[source]

Launch the wrapper.

Parameters

working_directory (Union[str, Path, PathLike, None]) – Directory to execute the application in. Default None.

wrapper_window_cls

The GTK wrapper window itself.

alias of WrapperWindow

class WrapperWindow(wrapper)[source]

Bases: Window

Standalone terminal wrapper for the app.

Displays the app in a libVTE terminal window, like gnome-terminal but without the standard terminal functionality. Closes when the app exits.

Parameters

wrapper (Wrapper)

Methods:

create_menu_options(menu_options)

Create the menubar options.

on_child_exited(terminal, status)

Handler for the process running in the terminal exiting.

on_menuitem_clicked(item)

Handler for menu buttons being clicked.

run(arguments, working_directory)

Show the wrapper window and launch the Textual app.

set_window_size(target_size)

Set the window size to the closest whole-character increment.

spawn_callback(terminal, pid, error)

Handler for the app finishing spawning.

create_menu_options(menu_options)[source]

Create the menubar options.

Parameters

menu_options (dict[str, list[MenuOption]])

Return type

MenuBar

on_child_exited(terminal, status)[source]

Handler for the process running in the terminal exiting.

Closes the wrapper window.

Parameters
  • terminal (Terminal)

  • status (int)

on_menuitem_clicked(item)[source]

Handler for menu buttons being clicked.

Parameters

item (MenuItem) – The clicked item.

run(arguments, working_directory)[source]

Show the wrapper window and launch the Textual app.

Parameters
  • arguments (list[str]) – The app executable and any arguments to pass to it.

  • working_directory (str) – Directory to execute the application in.

set_window_size(target_size)[source]

Set the window size to the closest whole-character increment.

Parameters

target_size (tuple[int, int]) – The desired size.

Return type

tuple[int, int]

Returns

The actual size of the window.

spawn_callback(terminal, pid, error)[source]

Handler for the app finishing spawning.

Sets up a watcher for the process later exiting.

Parameters
  • terminal (Terminal)

  • pid (int) – Process ID of the Textual app.

  • error (Optional[Any])

textual_wrapper.wrapper.gtk.unity

GTK wrapper with Unity launcher support.

Classes:

WrapperUnity(name, arguments[, icon, ...])

A GTK3-based wrapper around a terminal app, with Unity launcher support.

WrapperWindowUnity(wrapper)

Standalone terminal wrapper for the app.

class WrapperUnity(name, arguments, icon=None, launcher_options=<factory>, menu_options=<factory>, wrapper_window_cls=<class 'WrapperWindow'>)[source]

Bases: WrapperGtk

A GTK3-based wrapper around a terminal app, with Unity launcher support.

Classes:

wrapper_window_cls

The GTK wrapper window itself.

wrapper_window_cls

The GTK wrapper window itself.

alias of WrapperWindowUnity

class WrapperWindowUnity(wrapper)[source]

Bases: WrapperWindow

Standalone terminal wrapper for the app.

Displays the app in a libVTE terminal window, like gnome-terminal but without the standard terminal functionality. Closes when the app exits.

Parameters

wrapper (Wrapper)

Methods:

create_launcher_options()

Create the Unity launcher rightclick menu options.

on_launcher_menuitem_clicked(item, timestamp)

Handler for a Unity Launcher rightclick menu item being clicked.

run(arguments, working_directory)

Show the wrapper window and launch the Textual app.

create_launcher_options()[source]

Create the Unity launcher rightclick menu options.

on_launcher_menuitem_clicked(item, timestamp)[source]

Handler for a Unity Launcher rightclick menu item being clicked.

Parameters
  • item (Menuitem) – The clicked item.

  • timestamp (int)

run(arguments, working_directory)[source]

Show the wrapper window and launch the Textual app.

Parameters
  • arguments (list[str]) – The app executable and any arguments to pass to it.

  • working_directory (str) – Directory to execute the application in.