Skip to main content

A fully functional terminal/console widget for Windows, built on Python, Tkinnter and Pyte

Project description

Windows Terminal Emulator

This project is a fully functional terminal emulator application for Windows.

Features

  • Local terminal emulation on Windows.
  • Tabbed interface for managing multiple terminal sessions.
  • Support for text-based UI applications like VIM and htop will work when ssh'd to a linux host.
  • Customizable appearance and behavior.

Screen Shots


Window with color

Libraries Used

  • tkinter: Standard GUI toolkit for Python used for the application interface.
  • pyte: A simple VTXXX-compatible terminal emulator library used for interpreting escape sequences and managing the terminal state.
  • uuid: For generating unique identifiers for terminal sessions.
  • threading: For managing concurrent operations.
  • winpty: A Windows software package providing an interface to the Windows pseudo terminal (WinPTY).

Key Classes

  • App: The main application class that initializes the GUI, manages terminal tabs, and handles user interactions.
  • Terminal: A class representing a single terminal instance. It handles the rendering of the terminal screen, input events, and terminal resizing.
  • WinPtyHandler: This class manages the interaction with the local Windows command line, encapsulating the functionality provided by WinPTY.
  • KeyHandler: A utility class for interpreting keyboard input and sending it to the terminal.

Methodology

The core of the terminal emulation is handled by pyte. Here's how it's integrated into our application:

  1. Terminal Output Handling: When output from the command line is available, it is fed into pyte's ByteStream object. pyte interprets this data, which includes processing escape sequences and maintaining an in-memory representation of the terminal's screen.

  2. Screen Rendering: The Terminal class translates pyte's in-memory screen into text and colors in the tkinter.Text widget. This involves converting the screen's character cells into styled text that can be displayed in the GUI.

  3. Input Handling: User input from the keyboard is captured by the KeyHandler and sent to the WinPtyHandler. For remote connections, input would be sent via an SSH channel.

  4. Terminal Resizing: When the terminal window is resized, both pyte and WinPtyHandler are informed of the new dimensions. pyte uses this information to update its screen model, and WinPtyHandler adjusts the pseudo terminal accordingly.

  5. Session Management: Each terminal tab has a unique session, identified by a UUID. This allows for multiple independent terminal sessions within the application.

Getting Started

To run the application, ensure you have Python installed and the required packages available. Clone the repository, and run the main script:

python main_winpty.py

Contributions

Contributions to the project are welcome. Please fork the repository and submit a pull request with your enhancements.

License

This project is licensed under the GPLv3 License - see the LICENSE file for details.

Build

# Create a wheel
pip install wheel setuptools
python setup.py sdist bdist_wheel

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tkwinterm-0.2.2.tar.gz (25.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tkwinterm-0.2.2-py3-none-any.whl (25.2 kB view details)

Uploaded Python 3

File details

Details for the file tkwinterm-0.2.2.tar.gz.

File metadata

  • Download URL: tkwinterm-0.2.2.tar.gz
  • Upload date:
  • Size: 25.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.11

File hashes

Hashes for tkwinterm-0.2.2.tar.gz
Algorithm Hash digest
SHA256 7fb3d913f268f3b59cc81644af42cf63ae3b73fcf52d7b108a0712b0118f0162
MD5 8cb71efe8af849547dd70a1dbba2f3a2
BLAKE2b-256 61edf35c23ff8c426464cbd19d22e7fb09243f37f6061f9c8bf307dccfa574ed

See more details on using hashes here.

File details

Details for the file tkwinterm-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: tkwinterm-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 25.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.11

File hashes

Hashes for tkwinterm-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 1745aa360f7dfd81c6d659b6f42dc459eb2aef509e64d2a0e0702b6f322272e4
MD5 71bfbabcd80866a79949693a1f13f915
BLAKE2b-256 be0b133552178447d440e3724c80d8c7529b0a4fc2ad5b01c365f6933d1c1620

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page