Skip to main content

('A customizable Tkinter-based text console widget, in which a user types in commands to be sent to the Python interpreter.',)

Project description

text_console

text_console is a customizable, Tkinter-based interactive shell widget that lets users type commands into a console pane and have them evaluated in your application’s Python environment. It supports arrows and command history. It’s designed for embedding in GUI apps, debugging, scripting, and educational tools as an API Playground.

It can also be used as a standalone Python command interpreter.

This program is similar to wxPython Shell, implemented using Tkinter.

Key Features

  • Live code execution

    Send single- or multi-line Python code to the interpreter and see results immediately.

  • Integrated application context

    Access and modify your app’s variables and functions via the console_locals namespace.

  • Advanced editing

    • Keyboard shortcuts: all standard keyboard shortcut are allowed
    • Multiline editing: Single line and multiline editing is allowed, also with copy/paste features. When pressing enter within an edited line, a popup appears to ask the requested action (execute the command, add a new line, abort). Shift-Enter is also allowed.
    • Prompt Protection: The prompt area (>>> or ... ) is protected. The cursor cannot move into or before the prompt, and editing actions (insertion, deletion) are blocked in the prompt area.
    • Smart Arrow Navigation: Left and right arrow keys skip over prompt tags and any protected regions, ensuring the cursor only lands in editable areas. Arrow navigation also respects line boundaries and prompt positions.
    • Home/End Navigation: The Home and End keys move the cursor to the beginning or end of the current line, but never into the prompt area.
    • Undo/Redo Support: Full undo/redo support is enabled (Ctrl+Z/Ctrl+Y), with fine-grained control for character-by-character undo.
    • Tab and Shift+Tab: Pressing Tab inserts four spaces. Pressing Shift+Tab removes up to four spaces.
    • Selection Awareness: Editing and navigation actions are aware of text selection. For example, custom arrow key logic is bypassed when a selection is active.
    • Clear Console: The console can be cleared with a single command, automatically restoring the prompt and positioning the cursor for new input.
  • Command history

    Navigate previous commands with ↑/↓ arrows; history is saved to a file you choose.

  • Cut/Copy/Paste/Clear

    Right-click context menu (and customizable via context_menu_items) for text editing.

  • Customizable UI

    The package provides flexibility to customize:

    • history_file: Change the location of the history file
    • console_locals: Add custom variables and functions to the console's namespace
    • context_menu_items: Modify the right-click context menu
    • show_about_message: Customize the about dialog content
    • show_help_content: Customize the help window content
    • create_menu: Override to completely customize the menu bar
  • Subclass-friendly

    Extend the TextConsole class and override any of the above to fit your needs.

Full information and usage details at the text_console GitHub repository.

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

text_console-2.0.3.tar.gz (22.8 kB view details)

Uploaded Source

File details

Details for the file text_console-2.0.3.tar.gz.

File metadata

  • Download URL: text_console-2.0.3.tar.gz
  • Upload date:
  • Size: 22.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.4

File hashes

Hashes for text_console-2.0.3.tar.gz
Algorithm Hash digest
SHA256 33bdce29b5bae87f81c3b763c06b73001a1db99108e6178576bdcce230069ae5
MD5 2b374a07e2b0216201179d05aeb76df4
BLAKE2b-256 a81f91e7249ab7963ec5dfd42ff891474d860f3deed4079d7e08644f40591fea

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