An IDLE-like debugger to allow for real-time command injection for debugging and testing python code
Project description
PYSOLE
You can finally test your code in real time without using idle!
If you found this repository useful, please give it a ⭐!.
Showcase (click to watch on Youtube)
Table of contents
- Features
- Installation
- Usage
- Parameters
- Keyboard Shortcuts
- Troubleshooting/Notes
- Contributing
- License
Features
Pysole provides a compact but powerful set of features designed to make interactive debugging and live testing fast and pleasant.
-
Live GUI console (syntax highlighting)
- Real-time syntax highlighting using Pygments.
- Monokai style by default, configurable through themes.
-
Autocomplete & suggestions
- Autocomplete for Python keywords, built-ins and variables in scope.
- Popup suggestions after typing (configurable behavior) and insert-on-confirm.
-
Run remaining script code at startup
runRemainingCode=Truewill execute the remainder of the calling script afterprobe()is invoked.printStartupCode=Trueprints the captured code chunks as they execute.
-
Thread-safe execution + output capture
- User code runs in a background thread to avoid blocking the GUI.
stdoutandstderrare redirected into the GUI console output area.
-
Multi-line input, indentation & history
- Shift+Enter inserts a newline with proper indentation.
- Command history with clickable entries for easy reuse.
-
Integrated Help Panel and Features tab
- Right-hand help panel shows
help(obj)output. - A Features view is available from the File menu and shows the built-in features summary.
- Right-hand help panel shows
-
Themes & persistent settings
- Theme picker in the File menu; selected theme is written to
settings.json. - Settings (THEME, BEHAVIOR, FONT) are loaded at startup from
src/pysole/settings.json.
- Theme picker in the File menu; selected theme is written to
Installation
Quick install
pip install liveConsole
Notes: the package is published under the name liveConsole (see pyproject.toml).
If you prefer to install from source, clone this repo and run:
pip install -e .
Command-line entry points
After installation, two console commands are provided:
pysole— open the GUI console (same asliveconsole)liveconsole— open the GUI console
Usage
Programmatic usage (embed in scripts):
- Basic, automatic caller capture:
import pysole
pysole.probe()
- Run the remaining code in the current file inside the console and print the code as it executes
pysole.probe(runRemainingCode=True, printStartupCode=True)
- Override appearance and prompt
pysole.probe(primaryPrompt='PY> ', font='Consolas', fontSize=14)
Parameters
This section documents the parameters accepted by pysole.probe() and the InteractiveConsole constructor in src/pysole/pysole.py. Most of these parameters are optional; reasonable defaults are taken from the calling frame and settings.json.
Note: probe(...) forwards its arguments to InteractiveConsole(...) so you can pass any of the parameters below to probe() directly.
runRemainingCode
- Meaning: When
True, Pysole will read the remainder of the source file that contains theprobe()call and run those lines inside the console's namespace. - Type: bool
- Default:
False - Behavior: The implementation inspects
callerFrame.f_code.co_filenamefor the filename andcallerFrame.f_linenofor the line number whereprobe()was called. Lines after that line are captured intostartupCodeand executed on console startup. - Caution: This requires the source file to be readable from disk (not packaged/compiled away). Large files will be read into memory.
printStartupCode
- Meaning: Controls how the startup code (captured by
runRemainingCode=True) is executed: printed chunk-by-chunk to the console and executed interactively, or executed silently. - Type: bool
- Default:
False - Behavior: If
True, the startup code is split into logical top-level chunks (top-level statements and their indented blocks). Each chunk is printed and executed sequentially so you can see what runs. IfFalse, the entire remaining code is executed silently in one go (but output is still captured and shown).
primaryPrompt
- Meaning: Overrides the primary prompt string (for example
>>>). This updates the in-memoryBEHAVIOR['PRIMARY_PROMPT']used by the console and the default can also be changed in the settings file directly. - Type: string
- Default: The prompt value defined in
settings.jsonunderBEHAVIOR -> PRIMARY_PROMPT. - Notes: Passing this parameter changes the prompt for the current session only.
font
- Meaning: Overrides the font family used in console widgets.
- Type: string (font family name, e.g. "Consolas", "Courier New")
- Default: The font specified by
settings.json->THEME->FONT.
fontSize
- Meaning: Overrides the font size used in console widgets.
- Type: int (font size in points / pixels depending on the platform and Tk configuration)
- Default: Value from
settings.json->THEME->FONT_SIZE.
removeWaterMark
- Meaning: Controls whether a short welcome watermark message (with a GitHub link and request to star the project) is printed at startup.
- Type: bool
- Default:
False(watermark shown)
userGlobals
- Meaning: The
globals()mapping that the console will use as its global namespace. Variables, functions, and imports in this mapping will be visible to code executed in the console. - Type: dict-like (typically the dict returned by
globals()) - Default: If omitted, the console infers the caller's globals using
callerFrame.f_globals(or frominspect.currentframe().f_backifcallerFrameis also omitted). - When to pass: Provide this when you want the console to operate on a specific module or custom namespace.
userLocals
- Meaning: The
locals()mapping used as the console's local namespace. Local variables available at the call site will be visible here. - Type: dict-like (typically the dict returned by
locals()) - Default: Inferred from the caller's frame (
callerFrame.f_locals) if not provided.
callerFrame
- Meaning: An
inspectframe object used to infer bothuserGlobalsanduserLocalswhen they are not supplied. It's also used to determine the source file and line number for the "run remaining code" feature. - Type: frame object (as returned by
inspect.currentframe()andframe.f_back) - Default: If omitted,
probe()setscallerFrame = inspect.currentframe().f_backto automatically capture the frame of the caller. - When to pass: Use an explicit frame when calling
probe()from helper wrappers or non-standard contexts where automatic frame detection would be wrong.
Behavioral notes and edge cases
probe()replacessys.stdout,sys.stderr, andsys.stdinwith console-aware redirectors while the console is running. These streams are restored when the console'sonClose()runs (but be mindful when embedding Pysole in larger apps).- If
runRemainingCode=Truebut the source file cannot be read (packaged app, missing file, permission issues), the attempt to read the file will fail — in that case either run Pysole withoutrunRemainingCodeor pass an explicitstartupCode(if you extend the API). - When
printStartupCode=True, chunks are determined by top-level lines (zero indent) and their following indented lines. This makes printed execution easier to follow for functions, classes and loops.
Keyboard Shortcuts
| Key | Action |
|---|---|
Enter |
Execute command (if complete) |
Shift+Enter |
Insert newline with auto-indent |
Tab |
Complete the current word / show suggestions |
Up/Down |
Navigate suggestion list |
Escape |
Hide suggestions |
Ctrl Click |
open help panel on the current method/func/class... |
Troubleshooting/Notes
Behavioral notes and edge cases
probe()temporarily replacessys.stdout,sys.stderrandsys.stdinwith redirectors that send text to the GUI console. These are restored on close (onClose()). Embedding Pysole in larger apps should take this into account.runRemainingCode=Truerequires the calling module's source file to be available on disk. Running this in frozen/packaged environments may fail.printStartupCode=Trueprints chunks determined by top-level statements (zero indent) and their indented blocks so function/class/loop definitions are grouped with their bodies.
Settings and themes
Default UI and behavior settings are loaded from src/pysole/settings.json (path built from src/pysole/utils.py). Themes are listed in src/pysole/themes.json. The in-app Theme Picker writes the selected theme back to settings.json to persist across sessions.
Troubleshooting
- If the GUI doesn't start, make sure
customtkinteris installed for your Python version. - On Linux, ensure your Tk/Tcl support is present (system package) and
DISPLAYis set when running headful UIs. - If
runRemainingCodeappears to run the wrong code, check whereprobe()is called (wrappers can shift the caller frame). UsecallerFrame=to pass an explicit frame if needed.
Contributing
- Bug reports and PRs welcome. Please open issues on the upstream GitHub repository: https://github.com/TzurSoffer/Pysole
- Keep test changes small and focused. Include a short description of the error / feature and steps to reproduce.
Changelog (high level)
- See
pyproject.tomlfor the current package version.
License
This project is available under the MIT license — see the LICENSE file in the repository root.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file liveconsole-1.7.9.tar.gz.
File metadata
- Download URL: liveconsole-1.7.9.tar.gz
- Upload date:
- Size: 18.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3bd18fcf6605867caa2870d8d63253194931ccf533ea8a585e2dc2ede97f67f9
|
|
| MD5 |
9bbdd5a3ef7eba657c3ae9868f87b3c6
|
|
| BLAKE2b-256 |
7bee5b0e6160897ed719111a0a906490cf63ea17983a341cf4d39b6090c221dc
|
File details
Details for the file liveconsole-1.7.9-py3-none-any.whl.
File metadata
- Download URL: liveconsole-1.7.9-py3-none-any.whl
- Upload date:
- Size: 21.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
671d9cd191572fe714f9bd191452991178a404c7839aef1dcf510e996aeb6b56
|
|
| MD5 |
04b8ce60816f50d507ecc6aaf416e8bf
|
|
| BLAKE2b-256 |
361de2832d42c6aeda39538d391925ef5e1a6c82bb31296ec83fb3b1f5fddf86
|