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 reflects the core functionality of wxPython Shell, offering an even richer feature set.

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.

Keyboard shortcuts

Shortcut Description
Return Execute current command; if editing mid-line or multiline, show modal allowing to select either to run the code or insert a linefeed in the cursor position.
Shift Return Insert a new line within the edited multiline command.
Control Return Move the cursor to the end of the last line of input.
Tab Indent code (up to 4 spaces); if selection, indent all selected lines.
Shift Tab Un-indent (remove up to 4 spaces before cursor).
Down Arrow Recall next command in history.
Up Arrow Recall previous command in history.
Left Arrow Move to previous non-tagged character.
Right Arrow Move to next non-tagged character.
Control Left Arrow Move to previous word.
Control Right Arrow Move to next word.
Escape Jump to last blank command (empty input) in history.
BackSpace Delete character before cursor.
Control R Open Command History panel / Start reverse history search.
Control C Copy selected code, removing prompts first.
Control V Paste text from clipboard, handling prompts and multiline input.
Button-3 (Right Click) Show context menu (Cut, Copy, Paste, Clear).
Control Z Undo last edit (safe, ignores errors).
Control Y Redo last undone edit (safe, ignores errors).
Control K Remove the current element from the history.
Home Move cursor to start of current line.
End Move cursor to end of current line.
Control + Increase font size.
Control - Decrease font size.
Control 0 Reset font size.

In the History Panel:

Shortcut Description
Control N In history panel: Find next search match
Control B In history panel: Find previous search match
Control S In history panel: Load selected command to main window
Double-click Recall command to main window from history panel
Esc In history panel: Close Command History panel / Cancel search

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.6.tar.gz (26.0 kB view details)

Uploaded Source

File details

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

File metadata

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

File hashes

Hashes for text_console-2.0.6.tar.gz
Algorithm Hash digest
SHA256 386b7b8f47c050a2b3135532f62e1db5ef52c0d023a9d2d3cb66adcc3fda3a57
MD5 0c70e94dab8fdfe4b5c96b6e8d219bce
BLAKE2b-256 ec0e8dc930c77875cd15c007f8644c0891c8a3d494f83c79cb61340f1ebcac59

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