Skip to content

mitosch/textual-terminal

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Textual: Terminal

A terminal widget for Textual using Pyte as a linux terminal emulator.

Textual application example with two terminal widgets:

textual_terminal

Usage

from textual_terminal import Terminal

class TerminalApp(App):
    def compose(self) -> ComposeResult:
        yield Terminal(command="htop", id="terminal_htop")
        yield Terminal(command="bash", id="terminal_bash")

    def on_ready(self) -> None:
        terminal_htop: Terminal = self.query_one("#terminal_htop")
        terminal_htop.start()

        terminal_bash: Terminal = self.query_one("#terminal_bash")
        terminal_bash.start()

Installation

pip install textual-terminal

Features

  • Colored output
  • Automatic resize to widget dimensions
  • Simple key handling (navigation, function keys)
  • Simple mouse tracking (click, scroll)

Options

default_colors

By default, textual-terminal uses the colors defined by the system (not the Textual colors). To use the Textual background and foreground colors for "default" ANSI colors, set the option default_colors to textual:

Terminal(command="htop", default_colors="textual")

Note: This only applies to ANSI colors without an explicit setting, e.g. if the background is set to "red" by an application, it will stay red and the option will not have any effect.

References

This library is based on the Textual pyte example by David Brochart.

About

A terminal emulator widget for Textual.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages