liveConsole 1.7.5__tar.gz → 1.7.7__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- liveconsole-1.7.7/PKG-INFO +217 -0
- liveconsole-1.7.7/README.md +202 -0
- {liveconsole-1.7.5 → liveconsole-1.7.7}/pyproject.toml +5 -1
- liveconsole-1.7.7/src/liveConsole.egg-info/PKG-INFO +217 -0
- {liveconsole-1.7.5 → liveconsole-1.7.7}/src/pysole/pysole.py +31 -15
- {liveconsole-1.7.5 → liveconsole-1.7.7}/src/pysole/suggestionManager.py +5 -2
- liveconsole-1.7.7/src/pysole/utils.py +45 -0
- liveconsole-1.7.5/PKG-INFO +0 -161
- liveconsole-1.7.5/README.md +0 -148
- liveconsole-1.7.5/src/liveConsole.egg-info/PKG-INFO +0 -161
- liveconsole-1.7.5/src/pysole/utils.py +0 -13
- {liveconsole-1.7.5 → liveconsole-1.7.7}/LICENSE +0 -0
- {liveconsole-1.7.5 → liveconsole-1.7.7}/MANIFEST.in +0 -0
- {liveconsole-1.7.5 → liveconsole-1.7.7}/setup.cfg +0 -0
- {liveconsole-1.7.5 → liveconsole-1.7.7}/src/liveConsole/__init__.py +0 -0
- {liveconsole-1.7.5 → liveconsole-1.7.7}/src/liveConsole.egg-info/SOURCES.txt +0 -0
- {liveconsole-1.7.5 → liveconsole-1.7.7}/src/liveConsole.egg-info/dependency_links.txt +0 -0
- {liveconsole-1.7.5 → liveconsole-1.7.7}/src/liveConsole.egg-info/entry_points.txt +0 -0
- {liveconsole-1.7.5 → liveconsole-1.7.7}/src/liveConsole.egg-info/requires.txt +0 -0
- {liveconsole-1.7.5 → liveconsole-1.7.7}/src/liveConsole.egg-info/top_level.txt +0 -0
- {liveconsole-1.7.5 → liveconsole-1.7.7}/src/pysole/__init__.py +0 -0
- {liveconsole-1.7.5 → liveconsole-1.7.7}/src/pysole/__main__.py +0 -0
- {liveconsole-1.7.5 → liveconsole-1.7.7}/src/pysole/commandHistory.py +0 -0
- {liveconsole-1.7.5 → liveconsole-1.7.7}/src/pysole/helpTab.py +0 -0
- {liveconsole-1.7.5 → liveconsole-1.7.7}/src/pysole/liveConsole.py +0 -0
- {liveconsole-1.7.5 → liveconsole-1.7.7}/src/pysole/mainConsole.py +0 -0
- {liveconsole-1.7.5 → liveconsole-1.7.7}/src/pysole/settings.json +0 -0
- {liveconsole-1.7.5 → liveconsole-1.7.7}/src/pysole/styledTextbox.py +0 -0
- {liveconsole-1.7.5 → liveconsole-1.7.7}/src/pysole/themes.json +0 -0
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: liveConsole
|
|
3
|
+
Version: 1.7.7
|
|
4
|
+
Summary: An IDLE-like debugger to allow for real-time command injection for debugging and testing python code
|
|
5
|
+
Author-email: Tzur Soffer <tzur.soffer@gmail.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/TzurSoffer/Pysole
|
|
8
|
+
Project-URL: Repository, https://github.com/TzurSoffer/Pysole
|
|
9
|
+
Requires-Python: >=3.7
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Requires-Dist: customtkinter
|
|
13
|
+
Requires-Dist: pygments
|
|
14
|
+
Dynamic: license-file
|
|
15
|
+
|
|
16
|
+
# PYSOLE
|
|
17
|
+
|
|
18
|
+
## You can finally test your code in real time without using idle!
|
|
19
|
+
### If you found [this repository](https://github.com/TzurSoffer/Pysole) useful, please give it a ⭐!.
|
|
20
|
+
|
|
21
|
+
## Showcase (click to watch on Youtube)
|
|
22
|
+
[](https://www.youtube.com/shorts/pjoelNjc3O0)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
Table of contents
|
|
26
|
+
|
|
27
|
+
- Features
|
|
28
|
+
- Installation
|
|
29
|
+
- Usage
|
|
30
|
+
- Parameters
|
|
31
|
+
- Keyboard Shortcuts
|
|
32
|
+
- Troubleshooting/Notes
|
|
33
|
+
- Contributing
|
|
34
|
+
- License
|
|
35
|
+
|
|
36
|
+
## Features
|
|
37
|
+
|
|
38
|
+
Pysole provides a compact but powerful set of features designed to make interactive debugging and live testing fast and pleasant.
|
|
39
|
+
|
|
40
|
+
1. Live GUI console (syntax highlighting)
|
|
41
|
+
- Real-time syntax highlighting using Pygments.
|
|
42
|
+
- Monokai style by default, configurable through themes.
|
|
43
|
+
|
|
44
|
+
2. Autocomplete & suggestions
|
|
45
|
+
- Autocomplete for Python keywords, built-ins and variables in scope.
|
|
46
|
+
- Popup suggestions after typing (configurable behavior) and insert-on-confirm.
|
|
47
|
+
|
|
48
|
+
3. Run remaining script code at startup
|
|
49
|
+
- `runRemainingCode=True` will execute the remainder of the calling script after `probe()` is invoked.
|
|
50
|
+
- `printStartupCode=True` prints the captured code chunks as they execute.
|
|
51
|
+
|
|
52
|
+
4. Thread-safe execution + output capture
|
|
53
|
+
- User code runs in a background thread to avoid blocking the GUI.
|
|
54
|
+
- `stdout` and `stderr` are redirected into the GUI console output area.
|
|
55
|
+
|
|
56
|
+
5. Multi-line input, indentation & history
|
|
57
|
+
- Shift+Enter inserts a newline with proper indentation.
|
|
58
|
+
- Command history with clickable entries for easy reuse.
|
|
59
|
+
|
|
60
|
+
6. Integrated Help Panel and Features tab
|
|
61
|
+
- Right-hand help panel shows `help(obj)` output.
|
|
62
|
+
- A Features view is available from the File menu and shows the built-in features summary.
|
|
63
|
+
|
|
64
|
+
7. Themes & persistent settings
|
|
65
|
+
- Theme picker in the File menu; selected theme is written to `settings.json`.
|
|
66
|
+
- Settings (THEME, BEHAVIOR, FONT) are loaded at startup from `src/pysole/settings.json`.
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
## Installation
|
|
70
|
+
|
|
71
|
+
Quick install
|
|
72
|
+
|
|
73
|
+
```powershell
|
|
74
|
+
pip install liveConsole
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Notes: the package is published under the name `liveConsole` (see `pyproject.toml`).
|
|
78
|
+
|
|
79
|
+
If you prefer to install from source, clone this repo and run:
|
|
80
|
+
|
|
81
|
+
```powershell
|
|
82
|
+
pip install -e .
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Command-line entry points
|
|
86
|
+
|
|
87
|
+
After installation, two console commands are provided:
|
|
88
|
+
|
|
89
|
+
- `pysole` — open the GUI console (same as `liveconsole`)
|
|
90
|
+
- `liveconsole` — open the GUI console
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
## Usage
|
|
94
|
+
|
|
95
|
+
Programmatic usage (embed in scripts):
|
|
96
|
+
|
|
97
|
+
- Basic, automatic caller capture:
|
|
98
|
+
```python
|
|
99
|
+
import pysole
|
|
100
|
+
pysole.probe()
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
- Run the remaining code in the current file inside the console and print the code as it executes
|
|
104
|
+
```python
|
|
105
|
+
pysole.probe(runRemainingCode=True, printStartupCode=True)
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
- Override appearance and prompt
|
|
109
|
+
```python
|
|
110
|
+
pysole.probe(primaryPrompt='PY> ', font='Consolas', fontSize=14)
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## Parameters
|
|
114
|
+
|
|
115
|
+
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`.
|
|
116
|
+
|
|
117
|
+
Note: `probe(...)` forwards its arguments to `InteractiveConsole(...)` so you can pass any of the parameters below to `probe()` directly.
|
|
118
|
+
|
|
119
|
+
runRemainingCode
|
|
120
|
+
- Meaning: When `True`, Pysole will read the remainder of the source file that contains the `probe()` call and run those lines inside the console's namespace.
|
|
121
|
+
- Type: bool
|
|
122
|
+
- Default: `False`
|
|
123
|
+
- Behavior: The implementation inspects `callerFrame.f_code.co_filename` for the filename and `callerFrame.f_lineno` for the line number where `probe()` was called. Lines after that line are captured into `startupCode` and executed on console startup.
|
|
124
|
+
- Caution: This requires the source file to be readable from disk (not packaged/compiled away). Large files will be read into memory.
|
|
125
|
+
|
|
126
|
+
printStartupCode
|
|
127
|
+
- 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.
|
|
128
|
+
- Type: bool
|
|
129
|
+
- Default: `False`
|
|
130
|
+
- 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. If `False`, the entire remaining code is executed silently in one go (but output is still captured and shown).
|
|
131
|
+
|
|
132
|
+
primaryPrompt
|
|
133
|
+
- Meaning: Overrides the primary prompt string (for example `>>>`). This updates the in-memory `BEHAVIOR['PRIMARY_PROMPT']` used by the console and the default can also be changed in the settings file directly.
|
|
134
|
+
- Type: string
|
|
135
|
+
- Default: The prompt value defined in `settings.json` under `BEHAVIOR -> PRIMARY_PROMPT`.
|
|
136
|
+
- Notes: Passing this parameter changes the prompt for the current session only.
|
|
137
|
+
|
|
138
|
+
font
|
|
139
|
+
- Meaning: Overrides the font family used in console widgets.
|
|
140
|
+
- Type: string (font family name, e.g. "Consolas", "Courier New")
|
|
141
|
+
- Default: The font specified by `settings.json` -> `THEME` -> `FONT`.
|
|
142
|
+
|
|
143
|
+
fontSize
|
|
144
|
+
- Meaning: Overrides the font size used in console widgets.
|
|
145
|
+
- Type: int (font size in points / pixels depending on the platform and Tk configuration)
|
|
146
|
+
- Default: Value from `settings.json` -> `THEME` -> `FONT_SIZE`.
|
|
147
|
+
|
|
148
|
+
removeWaterMark
|
|
149
|
+
- Meaning: Controls whether a short welcome watermark message (with a GitHub link and request to star the project) is printed at startup.
|
|
150
|
+
- Type: bool
|
|
151
|
+
- Default: `False` (watermark shown)
|
|
152
|
+
|
|
153
|
+
userGlobals
|
|
154
|
+
- 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.
|
|
155
|
+
- Type: dict-like (typically the dict returned by `globals()`)
|
|
156
|
+
- Default: If omitted, the console infers the caller's globals using `callerFrame.f_globals` (or from `inspect.currentframe().f_back` if `callerFrame` is also omitted).
|
|
157
|
+
- When to pass: Provide this when you want the console to operate on a specific module or custom namespace.
|
|
158
|
+
|
|
159
|
+
userLocals
|
|
160
|
+
- Meaning: The `locals()` mapping used as the console's local namespace. Local variables available at the call site will be visible here.
|
|
161
|
+
- Type: dict-like (typically the dict returned by `locals()`)
|
|
162
|
+
- Default: Inferred from the caller's frame (`callerFrame.f_locals`) if not provided.
|
|
163
|
+
|
|
164
|
+
callerFrame
|
|
165
|
+
- Meaning: An `inspect` frame object used to infer both `userGlobals` and `userLocals` when they are not supplied. It's also used to determine the source file and line number for the "run remaining code" feature.
|
|
166
|
+
- Type: frame object (as returned by `inspect.currentframe()` and `frame.f_back`)
|
|
167
|
+
- Default: If omitted, `probe()` sets `callerFrame = inspect.currentframe().f_back` to automatically capture the frame of the caller.
|
|
168
|
+
- When to pass: Use an explicit frame when calling `probe()` from helper wrappers or non-standard contexts where automatic frame detection would be wrong.
|
|
169
|
+
|
|
170
|
+
Behavioral notes and edge cases
|
|
171
|
+
- `probe()` replaces `sys.stdout`, `sys.stderr`, and `sys.stdin` with console-aware redirectors while the console is running. These streams are restored when the console's `onClose()` runs (but be mindful when embedding Pysole in larger apps).
|
|
172
|
+
- If `runRemainingCode=True` but 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 without `runRemainingCode` or pass an explicit `startupCode` (if you extend the API).
|
|
173
|
+
- 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.
|
|
174
|
+
|
|
175
|
+
## Keyboard Shortcuts
|
|
176
|
+
|
|
177
|
+
| Key | Action |
|
|
178
|
+
| --- | --- |
|
|
179
|
+
| `Enter` | Execute command (if complete) |
|
|
180
|
+
| `Shift+Enter` | Insert newline with auto-indent |
|
|
181
|
+
| `Tab` | Complete the current word / show suggestions |
|
|
182
|
+
| `Up/Down` | Navigate suggestion list |
|
|
183
|
+
| `Escape` | Hide suggestions |
|
|
184
|
+
| `Ctrl Click` | open help panel on the current method/func/class... |
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
## Troubleshooting/Notes
|
|
188
|
+
|
|
189
|
+
Behavioral notes and edge cases
|
|
190
|
+
|
|
191
|
+
- `probe()` temporarily replaces `sys.stdout`, `sys.stderr` and `sys.stdin` with redirectors that send text to the GUI console. These are restored on close (`onClose()`). Embedding Pysole in larger apps should take this into account.
|
|
192
|
+
- `runRemainingCode=True` requires the calling module's source file to be available on disk. Running this in frozen/packaged environments may fail.
|
|
193
|
+
- `printStartupCode=True` prints chunks determined by top-level statements (zero indent) and their indented blocks so function/class/loop definitions are grouped with their bodies.
|
|
194
|
+
|
|
195
|
+
Settings and themes
|
|
196
|
+
|
|
197
|
+
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.
|
|
198
|
+
|
|
199
|
+
Troubleshooting
|
|
200
|
+
|
|
201
|
+
- If the GUI doesn't start, make sure `customtkinter` is installed for your Python version.
|
|
202
|
+
- On Linux, ensure your Tk/Tcl support is present (system package) and `DISPLAY` is set when running headful UIs.
|
|
203
|
+
- If `runRemainingCode` appears to run the wrong code, check where `probe()` is called (wrappers can shift the caller frame). Use `callerFrame=` to pass an explicit frame if needed.
|
|
204
|
+
|
|
205
|
+
## Contributing
|
|
206
|
+
|
|
207
|
+
- Bug reports and PRs welcome. Please open issues on the upstream GitHub repository: https://github.com/TzurSoffer/Pysole
|
|
208
|
+
- Keep test changes small and focused. Include a short description of the error / feature and steps to reproduce.
|
|
209
|
+
|
|
210
|
+
Changelog (high level)
|
|
211
|
+
|
|
212
|
+
- See `pyproject.toml` for the current package version.
|
|
213
|
+
|
|
214
|
+
## License
|
|
215
|
+
|
|
216
|
+
This project is available under the MIT license — see the `LICENSE` file in the repository root.
|
|
217
|
+
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
# PYSOLE
|
|
2
|
+
|
|
3
|
+
## You can finally test your code in real time without using idle!
|
|
4
|
+
### If you found [this repository](https://github.com/TzurSoffer/Pysole) useful, please give it a ⭐!.
|
|
5
|
+
|
|
6
|
+
## Showcase (click to watch on Youtube)
|
|
7
|
+
[](https://www.youtube.com/shorts/pjoelNjc3O0)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
Table of contents
|
|
11
|
+
|
|
12
|
+
- Features
|
|
13
|
+
- Installation
|
|
14
|
+
- Usage
|
|
15
|
+
- Parameters
|
|
16
|
+
- Keyboard Shortcuts
|
|
17
|
+
- Troubleshooting/Notes
|
|
18
|
+
- Contributing
|
|
19
|
+
- License
|
|
20
|
+
|
|
21
|
+
## Features
|
|
22
|
+
|
|
23
|
+
Pysole provides a compact but powerful set of features designed to make interactive debugging and live testing fast and pleasant.
|
|
24
|
+
|
|
25
|
+
1. Live GUI console (syntax highlighting)
|
|
26
|
+
- Real-time syntax highlighting using Pygments.
|
|
27
|
+
- Monokai style by default, configurable through themes.
|
|
28
|
+
|
|
29
|
+
2. Autocomplete & suggestions
|
|
30
|
+
- Autocomplete for Python keywords, built-ins and variables in scope.
|
|
31
|
+
- Popup suggestions after typing (configurable behavior) and insert-on-confirm.
|
|
32
|
+
|
|
33
|
+
3. Run remaining script code at startup
|
|
34
|
+
- `runRemainingCode=True` will execute the remainder of the calling script after `probe()` is invoked.
|
|
35
|
+
- `printStartupCode=True` prints the captured code chunks as they execute.
|
|
36
|
+
|
|
37
|
+
4. Thread-safe execution + output capture
|
|
38
|
+
- User code runs in a background thread to avoid blocking the GUI.
|
|
39
|
+
- `stdout` and `stderr` are redirected into the GUI console output area.
|
|
40
|
+
|
|
41
|
+
5. Multi-line input, indentation & history
|
|
42
|
+
- Shift+Enter inserts a newline with proper indentation.
|
|
43
|
+
- Command history with clickable entries for easy reuse.
|
|
44
|
+
|
|
45
|
+
6. Integrated Help Panel and Features tab
|
|
46
|
+
- Right-hand help panel shows `help(obj)` output.
|
|
47
|
+
- A Features view is available from the File menu and shows the built-in features summary.
|
|
48
|
+
|
|
49
|
+
7. Themes & persistent settings
|
|
50
|
+
- Theme picker in the File menu; selected theme is written to `settings.json`.
|
|
51
|
+
- Settings (THEME, BEHAVIOR, FONT) are loaded at startup from `src/pysole/settings.json`.
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
## Installation
|
|
55
|
+
|
|
56
|
+
Quick install
|
|
57
|
+
|
|
58
|
+
```powershell
|
|
59
|
+
pip install liveConsole
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Notes: the package is published under the name `liveConsole` (see `pyproject.toml`).
|
|
63
|
+
|
|
64
|
+
If you prefer to install from source, clone this repo and run:
|
|
65
|
+
|
|
66
|
+
```powershell
|
|
67
|
+
pip install -e .
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Command-line entry points
|
|
71
|
+
|
|
72
|
+
After installation, two console commands are provided:
|
|
73
|
+
|
|
74
|
+
- `pysole` — open the GUI console (same as `liveconsole`)
|
|
75
|
+
- `liveconsole` — open the GUI console
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
## Usage
|
|
79
|
+
|
|
80
|
+
Programmatic usage (embed in scripts):
|
|
81
|
+
|
|
82
|
+
- Basic, automatic caller capture:
|
|
83
|
+
```python
|
|
84
|
+
import pysole
|
|
85
|
+
pysole.probe()
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
- Run the remaining code in the current file inside the console and print the code as it executes
|
|
89
|
+
```python
|
|
90
|
+
pysole.probe(runRemainingCode=True, printStartupCode=True)
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
- Override appearance and prompt
|
|
94
|
+
```python
|
|
95
|
+
pysole.probe(primaryPrompt='PY> ', font='Consolas', fontSize=14)
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## Parameters
|
|
99
|
+
|
|
100
|
+
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`.
|
|
101
|
+
|
|
102
|
+
Note: `probe(...)` forwards its arguments to `InteractiveConsole(...)` so you can pass any of the parameters below to `probe()` directly.
|
|
103
|
+
|
|
104
|
+
runRemainingCode
|
|
105
|
+
- Meaning: When `True`, Pysole will read the remainder of the source file that contains the `probe()` call and run those lines inside the console's namespace.
|
|
106
|
+
- Type: bool
|
|
107
|
+
- Default: `False`
|
|
108
|
+
- Behavior: The implementation inspects `callerFrame.f_code.co_filename` for the filename and `callerFrame.f_lineno` for the line number where `probe()` was called. Lines after that line are captured into `startupCode` and executed on console startup.
|
|
109
|
+
- Caution: This requires the source file to be readable from disk (not packaged/compiled away). Large files will be read into memory.
|
|
110
|
+
|
|
111
|
+
printStartupCode
|
|
112
|
+
- 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.
|
|
113
|
+
- Type: bool
|
|
114
|
+
- Default: `False`
|
|
115
|
+
- 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. If `False`, the entire remaining code is executed silently in one go (but output is still captured and shown).
|
|
116
|
+
|
|
117
|
+
primaryPrompt
|
|
118
|
+
- Meaning: Overrides the primary prompt string (for example `>>>`). This updates the in-memory `BEHAVIOR['PRIMARY_PROMPT']` used by the console and the default can also be changed in the settings file directly.
|
|
119
|
+
- Type: string
|
|
120
|
+
- Default: The prompt value defined in `settings.json` under `BEHAVIOR -> PRIMARY_PROMPT`.
|
|
121
|
+
- Notes: Passing this parameter changes the prompt for the current session only.
|
|
122
|
+
|
|
123
|
+
font
|
|
124
|
+
- Meaning: Overrides the font family used in console widgets.
|
|
125
|
+
- Type: string (font family name, e.g. "Consolas", "Courier New")
|
|
126
|
+
- Default: The font specified by `settings.json` -> `THEME` -> `FONT`.
|
|
127
|
+
|
|
128
|
+
fontSize
|
|
129
|
+
- Meaning: Overrides the font size used in console widgets.
|
|
130
|
+
- Type: int (font size in points / pixels depending on the platform and Tk configuration)
|
|
131
|
+
- Default: Value from `settings.json` -> `THEME` -> `FONT_SIZE`.
|
|
132
|
+
|
|
133
|
+
removeWaterMark
|
|
134
|
+
- Meaning: Controls whether a short welcome watermark message (with a GitHub link and request to star the project) is printed at startup.
|
|
135
|
+
- Type: bool
|
|
136
|
+
- Default: `False` (watermark shown)
|
|
137
|
+
|
|
138
|
+
userGlobals
|
|
139
|
+
- 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.
|
|
140
|
+
- Type: dict-like (typically the dict returned by `globals()`)
|
|
141
|
+
- Default: If omitted, the console infers the caller's globals using `callerFrame.f_globals` (or from `inspect.currentframe().f_back` if `callerFrame` is also omitted).
|
|
142
|
+
- When to pass: Provide this when you want the console to operate on a specific module or custom namespace.
|
|
143
|
+
|
|
144
|
+
userLocals
|
|
145
|
+
- Meaning: The `locals()` mapping used as the console's local namespace. Local variables available at the call site will be visible here.
|
|
146
|
+
- Type: dict-like (typically the dict returned by `locals()`)
|
|
147
|
+
- Default: Inferred from the caller's frame (`callerFrame.f_locals`) if not provided.
|
|
148
|
+
|
|
149
|
+
callerFrame
|
|
150
|
+
- Meaning: An `inspect` frame object used to infer both `userGlobals` and `userLocals` when they are not supplied. It's also used to determine the source file and line number for the "run remaining code" feature.
|
|
151
|
+
- Type: frame object (as returned by `inspect.currentframe()` and `frame.f_back`)
|
|
152
|
+
- Default: If omitted, `probe()` sets `callerFrame = inspect.currentframe().f_back` to automatically capture the frame of the caller.
|
|
153
|
+
- When to pass: Use an explicit frame when calling `probe()` from helper wrappers or non-standard contexts where automatic frame detection would be wrong.
|
|
154
|
+
|
|
155
|
+
Behavioral notes and edge cases
|
|
156
|
+
- `probe()` replaces `sys.stdout`, `sys.stderr`, and `sys.stdin` with console-aware redirectors while the console is running. These streams are restored when the console's `onClose()` runs (but be mindful when embedding Pysole in larger apps).
|
|
157
|
+
- If `runRemainingCode=True` but 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 without `runRemainingCode` or pass an explicit `startupCode` (if you extend the API).
|
|
158
|
+
- 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.
|
|
159
|
+
|
|
160
|
+
## Keyboard Shortcuts
|
|
161
|
+
|
|
162
|
+
| Key | Action |
|
|
163
|
+
| --- | --- |
|
|
164
|
+
| `Enter` | Execute command (if complete) |
|
|
165
|
+
| `Shift+Enter` | Insert newline with auto-indent |
|
|
166
|
+
| `Tab` | Complete the current word / show suggestions |
|
|
167
|
+
| `Up/Down` | Navigate suggestion list |
|
|
168
|
+
| `Escape` | Hide suggestions |
|
|
169
|
+
| `Ctrl Click` | open help panel on the current method/func/class... |
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
## Troubleshooting/Notes
|
|
173
|
+
|
|
174
|
+
Behavioral notes and edge cases
|
|
175
|
+
|
|
176
|
+
- `probe()` temporarily replaces `sys.stdout`, `sys.stderr` and `sys.stdin` with redirectors that send text to the GUI console. These are restored on close (`onClose()`). Embedding Pysole in larger apps should take this into account.
|
|
177
|
+
- `runRemainingCode=True` requires the calling module's source file to be available on disk. Running this in frozen/packaged environments may fail.
|
|
178
|
+
- `printStartupCode=True` prints chunks determined by top-level statements (zero indent) and their indented blocks so function/class/loop definitions are grouped with their bodies.
|
|
179
|
+
|
|
180
|
+
Settings and themes
|
|
181
|
+
|
|
182
|
+
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.
|
|
183
|
+
|
|
184
|
+
Troubleshooting
|
|
185
|
+
|
|
186
|
+
- If the GUI doesn't start, make sure `customtkinter` is installed for your Python version.
|
|
187
|
+
- On Linux, ensure your Tk/Tcl support is present (system package) and `DISPLAY` is set when running headful UIs.
|
|
188
|
+
- If `runRemainingCode` appears to run the wrong code, check where `probe()` is called (wrappers can shift the caller frame). Use `callerFrame=` to pass an explicit frame if needed.
|
|
189
|
+
|
|
190
|
+
## Contributing
|
|
191
|
+
|
|
192
|
+
- Bug reports and PRs welcome. Please open issues on the upstream GitHub repository: https://github.com/TzurSoffer/Pysole
|
|
193
|
+
- Keep test changes small and focused. Include a short description of the error / feature and steps to reproduce.
|
|
194
|
+
|
|
195
|
+
Changelog (high level)
|
|
196
|
+
|
|
197
|
+
- See `pyproject.toml` for the current package version.
|
|
198
|
+
|
|
199
|
+
## License
|
|
200
|
+
|
|
201
|
+
This project is available under the MIT license — see the `LICENSE` file in the repository root.
|
|
202
|
+
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "liveConsole"
|
|
3
|
-
version = "1.7.
|
|
3
|
+
version = "1.7.7"
|
|
4
4
|
description = "An IDLE-like debugger to allow for real-time command injection for debugging and testing python code"
|
|
5
5
|
authors = [{ name="Tzur Soffer", email="tzur.soffer@gmail.com" }]
|
|
6
6
|
license = {text = "MIT"}
|
|
@@ -8,6 +8,10 @@ readme = "README.md"
|
|
|
8
8
|
requires-python = ">=3.7"
|
|
9
9
|
dependencies = ["customtkinter", "pygments"]
|
|
10
10
|
|
|
11
|
+
[project.urls]
|
|
12
|
+
Homepage = "https://github.com/TzurSoffer/Pysole"
|
|
13
|
+
Repository = "https://github.com/TzurSoffer/Pysole"
|
|
14
|
+
|
|
11
15
|
[project.scripts]
|
|
12
16
|
liveconsole = "liveConsole:_standalone"
|
|
13
17
|
pysole = "pysole:_standalone"
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: liveConsole
|
|
3
|
+
Version: 1.7.7
|
|
4
|
+
Summary: An IDLE-like debugger to allow for real-time command injection for debugging and testing python code
|
|
5
|
+
Author-email: Tzur Soffer <tzur.soffer@gmail.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/TzurSoffer/Pysole
|
|
8
|
+
Project-URL: Repository, https://github.com/TzurSoffer/Pysole
|
|
9
|
+
Requires-Python: >=3.7
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Requires-Dist: customtkinter
|
|
13
|
+
Requires-Dist: pygments
|
|
14
|
+
Dynamic: license-file
|
|
15
|
+
|
|
16
|
+
# PYSOLE
|
|
17
|
+
|
|
18
|
+
## You can finally test your code in real time without using idle!
|
|
19
|
+
### If you found [this repository](https://github.com/TzurSoffer/Pysole) useful, please give it a ⭐!.
|
|
20
|
+
|
|
21
|
+
## Showcase (click to watch on Youtube)
|
|
22
|
+
[](https://www.youtube.com/shorts/pjoelNjc3O0)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
Table of contents
|
|
26
|
+
|
|
27
|
+
- Features
|
|
28
|
+
- Installation
|
|
29
|
+
- Usage
|
|
30
|
+
- Parameters
|
|
31
|
+
- Keyboard Shortcuts
|
|
32
|
+
- Troubleshooting/Notes
|
|
33
|
+
- Contributing
|
|
34
|
+
- License
|
|
35
|
+
|
|
36
|
+
## Features
|
|
37
|
+
|
|
38
|
+
Pysole provides a compact but powerful set of features designed to make interactive debugging and live testing fast and pleasant.
|
|
39
|
+
|
|
40
|
+
1. Live GUI console (syntax highlighting)
|
|
41
|
+
- Real-time syntax highlighting using Pygments.
|
|
42
|
+
- Monokai style by default, configurable through themes.
|
|
43
|
+
|
|
44
|
+
2. Autocomplete & suggestions
|
|
45
|
+
- Autocomplete for Python keywords, built-ins and variables in scope.
|
|
46
|
+
- Popup suggestions after typing (configurable behavior) and insert-on-confirm.
|
|
47
|
+
|
|
48
|
+
3. Run remaining script code at startup
|
|
49
|
+
- `runRemainingCode=True` will execute the remainder of the calling script after `probe()` is invoked.
|
|
50
|
+
- `printStartupCode=True` prints the captured code chunks as they execute.
|
|
51
|
+
|
|
52
|
+
4. Thread-safe execution + output capture
|
|
53
|
+
- User code runs in a background thread to avoid blocking the GUI.
|
|
54
|
+
- `stdout` and `stderr` are redirected into the GUI console output area.
|
|
55
|
+
|
|
56
|
+
5. Multi-line input, indentation & history
|
|
57
|
+
- Shift+Enter inserts a newline with proper indentation.
|
|
58
|
+
- Command history with clickable entries for easy reuse.
|
|
59
|
+
|
|
60
|
+
6. Integrated Help Panel and Features tab
|
|
61
|
+
- Right-hand help panel shows `help(obj)` output.
|
|
62
|
+
- A Features view is available from the File menu and shows the built-in features summary.
|
|
63
|
+
|
|
64
|
+
7. Themes & persistent settings
|
|
65
|
+
- Theme picker in the File menu; selected theme is written to `settings.json`.
|
|
66
|
+
- Settings (THEME, BEHAVIOR, FONT) are loaded at startup from `src/pysole/settings.json`.
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
## Installation
|
|
70
|
+
|
|
71
|
+
Quick install
|
|
72
|
+
|
|
73
|
+
```powershell
|
|
74
|
+
pip install liveConsole
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Notes: the package is published under the name `liveConsole` (see `pyproject.toml`).
|
|
78
|
+
|
|
79
|
+
If you prefer to install from source, clone this repo and run:
|
|
80
|
+
|
|
81
|
+
```powershell
|
|
82
|
+
pip install -e .
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Command-line entry points
|
|
86
|
+
|
|
87
|
+
After installation, two console commands are provided:
|
|
88
|
+
|
|
89
|
+
- `pysole` — open the GUI console (same as `liveconsole`)
|
|
90
|
+
- `liveconsole` — open the GUI console
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
## Usage
|
|
94
|
+
|
|
95
|
+
Programmatic usage (embed in scripts):
|
|
96
|
+
|
|
97
|
+
- Basic, automatic caller capture:
|
|
98
|
+
```python
|
|
99
|
+
import pysole
|
|
100
|
+
pysole.probe()
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
- Run the remaining code in the current file inside the console and print the code as it executes
|
|
104
|
+
```python
|
|
105
|
+
pysole.probe(runRemainingCode=True, printStartupCode=True)
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
- Override appearance and prompt
|
|
109
|
+
```python
|
|
110
|
+
pysole.probe(primaryPrompt='PY> ', font='Consolas', fontSize=14)
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## Parameters
|
|
114
|
+
|
|
115
|
+
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`.
|
|
116
|
+
|
|
117
|
+
Note: `probe(...)` forwards its arguments to `InteractiveConsole(...)` so you can pass any of the parameters below to `probe()` directly.
|
|
118
|
+
|
|
119
|
+
runRemainingCode
|
|
120
|
+
- Meaning: When `True`, Pysole will read the remainder of the source file that contains the `probe()` call and run those lines inside the console's namespace.
|
|
121
|
+
- Type: bool
|
|
122
|
+
- Default: `False`
|
|
123
|
+
- Behavior: The implementation inspects `callerFrame.f_code.co_filename` for the filename and `callerFrame.f_lineno` for the line number where `probe()` was called. Lines after that line are captured into `startupCode` and executed on console startup.
|
|
124
|
+
- Caution: This requires the source file to be readable from disk (not packaged/compiled away). Large files will be read into memory.
|
|
125
|
+
|
|
126
|
+
printStartupCode
|
|
127
|
+
- 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.
|
|
128
|
+
- Type: bool
|
|
129
|
+
- Default: `False`
|
|
130
|
+
- 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. If `False`, the entire remaining code is executed silently in one go (but output is still captured and shown).
|
|
131
|
+
|
|
132
|
+
primaryPrompt
|
|
133
|
+
- Meaning: Overrides the primary prompt string (for example `>>>`). This updates the in-memory `BEHAVIOR['PRIMARY_PROMPT']` used by the console and the default can also be changed in the settings file directly.
|
|
134
|
+
- Type: string
|
|
135
|
+
- Default: The prompt value defined in `settings.json` under `BEHAVIOR -> PRIMARY_PROMPT`.
|
|
136
|
+
- Notes: Passing this parameter changes the prompt for the current session only.
|
|
137
|
+
|
|
138
|
+
font
|
|
139
|
+
- Meaning: Overrides the font family used in console widgets.
|
|
140
|
+
- Type: string (font family name, e.g. "Consolas", "Courier New")
|
|
141
|
+
- Default: The font specified by `settings.json` -> `THEME` -> `FONT`.
|
|
142
|
+
|
|
143
|
+
fontSize
|
|
144
|
+
- Meaning: Overrides the font size used in console widgets.
|
|
145
|
+
- Type: int (font size in points / pixels depending on the platform and Tk configuration)
|
|
146
|
+
- Default: Value from `settings.json` -> `THEME` -> `FONT_SIZE`.
|
|
147
|
+
|
|
148
|
+
removeWaterMark
|
|
149
|
+
- Meaning: Controls whether a short welcome watermark message (with a GitHub link and request to star the project) is printed at startup.
|
|
150
|
+
- Type: bool
|
|
151
|
+
- Default: `False` (watermark shown)
|
|
152
|
+
|
|
153
|
+
userGlobals
|
|
154
|
+
- 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.
|
|
155
|
+
- Type: dict-like (typically the dict returned by `globals()`)
|
|
156
|
+
- Default: If omitted, the console infers the caller's globals using `callerFrame.f_globals` (or from `inspect.currentframe().f_back` if `callerFrame` is also omitted).
|
|
157
|
+
- When to pass: Provide this when you want the console to operate on a specific module or custom namespace.
|
|
158
|
+
|
|
159
|
+
userLocals
|
|
160
|
+
- Meaning: The `locals()` mapping used as the console's local namespace. Local variables available at the call site will be visible here.
|
|
161
|
+
- Type: dict-like (typically the dict returned by `locals()`)
|
|
162
|
+
- Default: Inferred from the caller's frame (`callerFrame.f_locals`) if not provided.
|
|
163
|
+
|
|
164
|
+
callerFrame
|
|
165
|
+
- Meaning: An `inspect` frame object used to infer both `userGlobals` and `userLocals` when they are not supplied. It's also used to determine the source file and line number for the "run remaining code" feature.
|
|
166
|
+
- Type: frame object (as returned by `inspect.currentframe()` and `frame.f_back`)
|
|
167
|
+
- Default: If omitted, `probe()` sets `callerFrame = inspect.currentframe().f_back` to automatically capture the frame of the caller.
|
|
168
|
+
- When to pass: Use an explicit frame when calling `probe()` from helper wrappers or non-standard contexts where automatic frame detection would be wrong.
|
|
169
|
+
|
|
170
|
+
Behavioral notes and edge cases
|
|
171
|
+
- `probe()` replaces `sys.stdout`, `sys.stderr`, and `sys.stdin` with console-aware redirectors while the console is running. These streams are restored when the console's `onClose()` runs (but be mindful when embedding Pysole in larger apps).
|
|
172
|
+
- If `runRemainingCode=True` but 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 without `runRemainingCode` or pass an explicit `startupCode` (if you extend the API).
|
|
173
|
+
- 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.
|
|
174
|
+
|
|
175
|
+
## Keyboard Shortcuts
|
|
176
|
+
|
|
177
|
+
| Key | Action |
|
|
178
|
+
| --- | --- |
|
|
179
|
+
| `Enter` | Execute command (if complete) |
|
|
180
|
+
| `Shift+Enter` | Insert newline with auto-indent |
|
|
181
|
+
| `Tab` | Complete the current word / show suggestions |
|
|
182
|
+
| `Up/Down` | Navigate suggestion list |
|
|
183
|
+
| `Escape` | Hide suggestions |
|
|
184
|
+
| `Ctrl Click` | open help panel on the current method/func/class... |
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
## Troubleshooting/Notes
|
|
188
|
+
|
|
189
|
+
Behavioral notes and edge cases
|
|
190
|
+
|
|
191
|
+
- `probe()` temporarily replaces `sys.stdout`, `sys.stderr` and `sys.stdin` with redirectors that send text to the GUI console. These are restored on close (`onClose()`). Embedding Pysole in larger apps should take this into account.
|
|
192
|
+
- `runRemainingCode=True` requires the calling module's source file to be available on disk. Running this in frozen/packaged environments may fail.
|
|
193
|
+
- `printStartupCode=True` prints chunks determined by top-level statements (zero indent) and their indented blocks so function/class/loop definitions are grouped with their bodies.
|
|
194
|
+
|
|
195
|
+
Settings and themes
|
|
196
|
+
|
|
197
|
+
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.
|
|
198
|
+
|
|
199
|
+
Troubleshooting
|
|
200
|
+
|
|
201
|
+
- If the GUI doesn't start, make sure `customtkinter` is installed for your Python version.
|
|
202
|
+
- On Linux, ensure your Tk/Tcl support is present (system package) and `DISPLAY` is set when running headful UIs.
|
|
203
|
+
- If `runRemainingCode` appears to run the wrong code, check where `probe()` is called (wrappers can shift the caller frame). Use `callerFrame=` to pass an explicit frame if needed.
|
|
204
|
+
|
|
205
|
+
## Contributing
|
|
206
|
+
|
|
207
|
+
- Bug reports and PRs welcome. Please open issues on the upstream GitHub repository: https://github.com/TzurSoffer/Pysole
|
|
208
|
+
- Keep test changes small and focused. Include a short description of the error / feature and steps to reproduce.
|
|
209
|
+
|
|
210
|
+
Changelog (high level)
|
|
211
|
+
|
|
212
|
+
- See `pyproject.toml` for the current package version.
|
|
213
|
+
|
|
214
|
+
## License
|
|
215
|
+
|
|
216
|
+
This project is available under the MIT license — see the `LICENSE` file in the repository root.
|
|
217
|
+
|