A DartPad-style Python playground for VS Code with multi-file support, command-line arguments, Python environment selection, file persistence, and more!
- โ Monaco Editor with Python syntax highlighting
- โ Multi-file support with tab management
- โ Always runs main.py - Other files support imports
- โ Command-line arguments - Pass args to your Python scripts
- โ Python environment selector - Choose your Python interpreter
- โ Resizable split panel - Drag to adjust editor/console sizes
- โ File persistence - Save files to your chosen workspace folder
- โ File watching - Sync with external file changes
- โ Open existing files - Load .py files from disk
- โ IntelliSense toggle - Enable/disable autocomplete
- โ Auto-format - Format code with Black or autopep8
- โ Real-time console output with color-coded messages
- โ Multiple file types - .py, .txt, .json, .csv, .md support
- โ DartPad-like layout - Professional split-pane interface
-
Open the extension folder in VS Code:
cd pythonpad code .
-
Press F5 (or Run > Start Debugging)
- A new "Extension Development Host" window will open
- Your extension is loaded in this test window
-
Open PythonPad:
- Press
Ctrl+Shift+P(Command Palette) - Type "PythonPad: Open Playground"
- Press Enter
- Press
-
Start coding!
- Write Python code in the editor
- Click "Run" or press
Ctrl+Enterto execute - See output in the console panel
-
Debug:
- Set breakpoints in
src/extension.ts - View logs in Debug Console (main window)
- For webview debugging:
Ctrl+Shift+Pโ "Developer: Toggle Developer Tools"
- Set breakpoints in
-
Reload after changes:
- Make code changes
- Press
Ctrl+Rin the Extension Development Host window - Changes will be reflected immediately
-
Package the extension:
npm install -g @vscode/vsce vsce package
-
Install the .vsix file:
- In VS Code: Extensions panel (
Ctrl+Shift+X) - Click "..." menu โ "Install from VSIX..."
- Select
pythonpad-0.0.1.vsix
- In VS Code: Extensions panel (
-
Restart VS Code
-
Open PythonPad:
- Press
Ctrl+Shift+P - Type "PythonPad: Open Playground"
- Press
- Python 3.x installed and available in PATH
- Optional: Install formatters for auto-formatting
- Black:
pip install black - autopep8:
pip install autopep8
- Black:
Two ways to set up your workspace:
Option 1: Open Existing Folder (Recommended)
- Click "๐ Open Folder" button
- Select a folder containing Python files (or an empty folder)
- PythonPad will:
- Load all
.py,.txt,.json,.csv,.mdfiles as tabs - Auto-create
main.pyif it doesn't exist - Set this as your workspace folder
- Enable file watching for external changes
- Load all
Option 2: Manual Workspace Setup
- Click ๐พ Save button or press
Ctrl+S - Select a folder to store your PythonPad files
- Or use command: "PythonPad: Set Workspace Folder"
After setup:
- All new files created with "+ New File" are auto-saved to this folder
- Ctrl+S saves the current file
- External file changes sync automatically
- Click "+ New File" button in the toolbar
- Enter filename (e.g.,
utils.py,config.json) - File is created with appropriate syntax highlighting
- File is automatically saved to the workspace folder
- Always runs main.py - Create a
main.pyfile if it doesn't exist - Click "โถ Run" button or press
Ctrl+Enter - View output in the console panel
- Other files are available for imports
- Enter arguments in the "Args:" field in toolbar
- Example:
--name "John Doe" --count 5 - Access in Python:
import sys print(sys.argv) # ['main.py', '--name', 'John Doe', '--count', '5'] # Or use argparse import argparse parser = argparse.ArgumentParser() parser.add_argument('--name') parser.add_argument('--count', type=int) args = parser.parse_args() print(f"Name: {args.name}, Count: {args.count}")
# main.py
from utils import helper_function
from models.data import DataProcessor
result = helper_function()
print(result)# utils.py
def helper_function():
return "Hello from utils!"# models/data.py
class DataProcessor:
def process(self):
return "Processing data..."All files are written to a temporary directory with proper PYTHONPATH set for execution.
- Click the "Python:" dropdown in toolbar
- Select from available Python interpreters
- Your choice is saved in settings
- Or manually set in settings:
pythonpad.pythonPath
- Click "๐ Open Folder" button in toolbar
- Select a folder (can be empty or contain existing Python files)
- PythonPad will:
- Load all compatible files (
.py,.txt,.json,.csv,.md) as tabs - Auto-create
main.pyif not present - Set as workspace folder
- Start watching for file changes
- Load all compatible files (
- Click "Format" button in toolbar
- Code will be formatted using the selected formatter (Black/autopep8)
- Configure formatter in Settings dropdown
- Formatter must be installed:
pip install blackorpip install autopep8
Click the "โ Settings" button to access:
- Enable IntelliSense: Toggle autocomplete on/off
- Auto-format on save: Automatically format code when saving
- Formatter: Choose between Black, autopep8, or None
- Theme: Switch between Dark and Light themes
Settings are persisted in VS Code configuration.
- Drag the divider between editor and console to resize
- Minimum size: 200px for each panel
- Layout persists during session
- Ctrl+Enter: Run main.py
- Ctrl+S: Save current file to workspace folder
- Ctrl+Space: Trigger IntelliSense (if enabled)
- Alt+Shift+F: Format document
- Ctrl+/: Toggle line comment
- Ctrl+F: Find
- Ctrl+H: Replace
Extension settings can be configured in VS Code settings (Ctrl+,):
{
"pythonpad.formatter": "black",
"pythonpad.formatOnSave": false,
"pythonpad.enableIntelliSense": true,
"pythonpad.lineLength": 88,
"pythonpad.theme": "dark",
"pythonpad.fontSize": 14,
"pythonpad.workspaceFolder": "/path/to/your/pythonpad/files",
"pythonpad.pythonPath": "python3"
}| Setting | Type | Default | Description |
|---|---|---|---|
pythonpad.formatter |
"black" | "autopep8" | "none" |
"black" |
Python code formatter to use |
pythonpad.formatOnSave |
boolean |
false |
Automatically format code on save |
pythonpad.enableIntelliSense |
boolean |
true |
Enable IntelliSense (autocomplete) |
pythonpad.lineLength |
number |
88 |
Maximum line length for formatters |
pythonpad.theme |
"dark" | "light" |
"dark" |
Editor theme |
pythonpad.fontSize |
number |
14 |
Editor font size |
pythonpad.workspaceFolder |
string |
"" |
Folder where PythonPad files are stored |
pythonpad.pythonPath |
string |
"python3" |
Path to Python interpreter |
- Extension Host (Node.js): Handles Python execution, formatting, file I/O, settings
- Webview (Browser): Monaco Editor, UI, console display
- Communication: postMessage API between extension and webview
- Monaco Editor: Loaded from CDN (https://cdn.jsdelivr.net)
- Split.js: Resizable split panels (https://split.js.org)
- Create unlimited files with tabs
- Switch between files by clicking tabs
- Close files with ร button
- Cursor position and scroll state preserved per file
- Supports multiple file types: .py, .js, .json, .txt, .csv, .md, .html, .css
- Real-time stdout/stderr streaming
- Color-coded output:
- White: Standard output
- Red: Error output
- Green: Success messages
- Gray: System messages
- Clear console button
- Auto-scroll to bottom
- All files written to temporary directory
- Entry point is always
main.py - PYTHONPATH set to temp directory (enables local imports)
- Command-line arguments passed securely
- Timeout: 30 seconds
- Cleanup: Temp directory automatically deleted after execution
- Save files to user-selected workspace folder
- File watching: External changes sync to editor
- Conflict resolution: Prompts on external changes
- Ctrl+S saves current file
- Files persist between sessions
- Auto-discovers available Python interpreters
- Dropdown to select interpreter
- Choice persisted in settings
- Fallback to python3/python if none found
- Input field in toolbar
- Secure parsing with
string-argv - Handles quotes and spaces correctly
- Validates against dangerous characters
- Arguments persist during webview session
- Drag divider to resize editor/console
- Uses Split.js library
- Minimum 200px for each panel
- Monaco layout recalculates on resize
Make sure Python is installed and available in PATH:
python3 --versionIf using a specific Python interpreter, select it from the Python dropdown or configure in settings:
{
"pythonpad.pythonPath": "/path/to/python"
}Install the formatter:
pip install black
# or
pip install autopep8Check your internet connection. Monaco Editor is loaded from CDN.
- Make sure workspace folder is set: "PythonPad: Set Workspace Folder" command
- Check folder permissions
- Look for error notifications
Click Run button - it will prompt you to create main.py automatically.
- Make sure to enter args in the "Args:" field before running
- Access in Python via
sys.argv - Check console for argument parsing errors
- Check that the extension compiled successfully:
npm run compile - Reload the Extension Development Host:
Ctrl+R - Check Debug Console for errors
# main.py
import sys
from utils import load_data, process_data
if __name__ == "__main__":
filename = sys.argv[1] if len(sys.argv) > 1 else "data.csv"
data = load_data(filename)
result = process_data(data)
print(f"Processed {len(result)} records")Run with args: data.csv
main.py # Entry point
utils.py # Helper functions
models/data.py # Data models
config.json # Configuration
Main.py always runs, other files imported as needed.
- Write quick Python code in main.py
- Press Ctrl+Enter to run
- See output immediately
- Iterate and test rapidly
pythonpad/
โโโ src/
โ โโโ extension.ts # Main extension code (1394 lines)
โโโ out/ # Compiled JavaScript
โโโ package.json # Extension manifest with settings
โโโ tsconfig.json # TypeScript config
โโโ README.md # This file
npm run compile: Compile TypeScriptnpm run watch: Watch mode for developmentnpm run lint: Run ESLintvsce package: Create VSIX package
-
Runtime:
string-argv: Secure command-line argument parsing
-
Development:
@vscode/python-extension: Python extension API types- TypeScript, ESLint, VS Code test frameworks
โจ Command-line arguments - Pass args to Python scripts โจ Python environment selector - Choose your interpreter โจ File persistence - Save to workspace folder with Ctrl+S โจ Open existing files - Load files from disk โจ File watching - Sync with external changes โจ Resizable split panel - Drag to resize โจ Always run main.py - Consistent entry point
๐ Better state management - Session persists ๐ Split.js integration - Smooth resizable panels ๐ Enhanced error messages - More helpful feedback ๐ Security validation - Args checked for safety
- PythonPad: Open Playground - Open the PythonPad interface
- PythonPad: Set Workspace Folder - Choose folder for file storage
This is a learning project for VS Code extension development. Feel free to fork and experiment!
MIT
- Built with Monaco Editor
- Resizable panels powered by Split.js
- Inspired by DartPad
- Stdin input support for
input()function - Package installation (pip install in virtual env)
- Code templates/snippets library
- Export/share functionality
- Matplotlib plot output display
- Syntax error highlighting (LSP integration)
- Workspace persistence (save/load projects)
- Multiple Python version support
- Debugging support with breakpoints
- Collaborative editing
- Code execution history
- Performance profiling
Enjoy coding with PythonPad! ๐โจ