GUI-based Python code generator extension for Jupyter Lab, Jupyter Notebook, and Google Colab
—
Main JupyterLab extension plugin that integrates Visual Python into the JupyterLab interface, providing panel management, command registration, and global environment setup.
Main activation function that initializes the Visual Python extension within JupyterLab.
/**
* Activates the Visual Python extension in JupyterLab
* @param app - JupyterLab application instance
* @param palette - Command palette for adding commands
*/
function activate(app: JupyterLab, palette: ICommandPalette): void;Description: Initializes the Visual Python extension by setting up global variables, creating the VpPanel, registering commands, and integrating with JupyterLab's UI system.
Parameters:
app: JupyterLab application instance providing access to shell, commands, and servicespalette: Command palette interface for registering Visual Python commandsBehavior:
Usage: Called automatically by JupyterLab during extension loading.
The extension establishes global variables accessible throughout the Visual Python system.
// Global variables set during activation
global.vpBase: string; // Base path to Visual Python library
global.vpExtType: string; // Extension type identifier (lab/lite)
global.vpLab: JupyterLab; // JupyterLab application reference
global.$: jQuery; // jQuery library for DOM manipulationGlobal Variables:
global.vpBase
stringglobal.vpExtType
stringglobal.vpLab
JupyterLabglobal.$
jQueryWebpack-based loaders for Visual Python assets and resources.
/**
* Loads CSS files for Visual Python styling
* @param path - Path to CSS file
* @returns Loaded CSS content as string
*/
function __VP_CSS_LOADER__(path: string): string;
/**
* Loads text files for Visual Python templates and content
* @param path - Path to text file
* @returns Loaded text content as string
*/
function __VP_TEXT_LOADER__(path: string): string;
/**
* Loads raw files and binary resources for Visual Python
* @param path - Path to resource file
* @returns Raw file content of any type
*/
function __VP_RAW_LOADER__(path: string): any;__VP_CSS_LOADER__
path - Path to CSS file relative to Visual Python assetsstring - Loaded CSS content ready for injection__VP_TEXT_LOADER__
path - Path to text file relative to Visual Python assetsstring - Loaded text content__VP_RAW_LOADER__
path - Path to resource file relative to Visual Python assetsany - Raw file content (can be binary data, JSON, etc.)Usage Context: These loaders are used internally by the Visual Python extension during the webpack build process to bundle static assets. They are exposed as part of the public API for potential extension by other developers or for debugging purposes.
// Extension plugin configuration
const extension = {
id: 'jupyterlab-visualpython:plugin',
autoStart: true,
requires: [ICommandPalette],
activate: activate
};Extension Properties:
id: Unique identifier for the extension pluginautoStart: Enables automatic activation when JupyterLab startsrequires: Dependencies required for activation (ICommandPalette)activate: Main activation functionThe extension registers commands for Visual Python interaction:
// Command registration during activation
app.commands.addCommand('jupyterlab-visualpython:toggle', {
label: 'Toggle Visual Python',
execute: () => {
if (vpPanel.isVisible) {
vpPanel.hide();
} else {
app.shell.add(vpPanel, 'right');
vpPanel.show();
}
}
});The extension integrates with JupyterLab's shell system:
Commands are added to JupyterLab's command palette:
palette.addItem({
command: 'jupyterlab-visualpython:toggle',
category: 'Visual Python'
});The extension detects the JupyterLab environment type:
// Environment type detection
const extType = app.version.includes('lite') ? 'lite' : 'lab';
global.vpExtType = extType;The extension includes error handling for:
Install with Tessl CLI
npx tessl i tessl/pypi-jupyterlab-visualpython