CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-eel

For little HTML GUI applications, with easy Python/JS interop

Pending

Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

Overview
Eval results
Files

core-functions.mddocs/

Core Application Functions

Essential functions for initializing and running Eel applications, including setup, function exposure, and application lifecycle management.

Capabilities

Application Initialization

Initialize Eel with web files directory and configuration options. This must be called before starting the application.

def init(path: str, allowed_extensions: List[str] = ['.js', '.html', '.txt', '.htm', '.xhtml', '.vue'], js_result_timeout: int = 10000) -> None:
    """
    Initialize Eel with web files directory and configuration.
    
    Parameters:
    - path: str - Path to directory containing web files (HTML, CSS, JS)
    - allowed_extensions: List[str] - File extensions to parse for exposed JS functions
    - js_result_timeout: int - Timeout in milliseconds for JavaScript function results
    
    Returns:
    None
    """

Usage Example:

import eel

# Initialize with web directory
eel.init('web')

# Initialize with custom configuration
eel.init('frontend', allowed_extensions=['.js', '.html', '.vue'], js_result_timeout=5000)

Function Exposure

Decorator to expose Python functions to JavaScript. Functions can be called from JavaScript with callbacks or async/await.

def expose(name_or_function: Optional[Callable[..., Any]] = None) -> Callable[..., Any]:
    """
    Decorator to expose Python functions to JavaScript API.
    
    Parameters:
    - name_or_function: Optional[Callable] - Function to expose or custom name
    
    Returns:
    Callable - Decorated function
    """

Usage Examples:

# Basic exposure
@eel.expose
def process_data(data):
    return {"processed": data.upper()}

# Custom name exposure
@eel.expose("customProcessData")
def process_data_internal(data):
    return {"result": data}

# Expose with string name
@eel.expose("my_function")
def some_function():
    pass

JavaScript Usage:

// Call exposed Python function
eel.process_data("hello")(function(result) {
    console.log(result); // {"processed": "HELLO"}
});

// With async/await
async function callPython() {
    const result = await eel.process_data("hello")();
    console.log(result);
}

Application Startup

Start the Eel application with browser window and web server. This is the main function to launch the application.

def start(*start_urls: str, mode: Optional[Union[str, Literal[False]]] = 'chrome', host: str = 'localhost', port: int = 8000, block: bool = True, jinja_templates: Optional[str] = None, cmdline_args: List[str] = ['--disable-http-cache'], size: Optional[Tuple[int, int]] = None, position: Optional[Tuple[int, int]] = None, geometry: Dict[str, Tuple[int, int]] = {}, close_callback: Optional[Callable[..., Any]] = None, app_mode: bool = True, all_interfaces: bool = False, disable_cache: bool = True, default_path: str = 'index.html', app: btl.Bottle = btl.default_app(), shutdown_delay: float = 1.0, suppress_error: bool = False) -> None:
    """
    Start the Eel application with browser window.
    
    Parameters:
    - *start_urls: str - URLs to open (relative to web directory)
    - mode: Optional[Union[str, Literal[False]]] - Browser mode ('chrome', 'electron', 'edge', 'custom', False)
    - host: str - Host for web server
    - port: int - Port for web server (0 for auto-select)
    - block: bool - Whether to block calling thread
    - jinja_templates: Optional[str] - Folder for Jinja2 templates
    - cmdline_args: List[str] - Command line arguments for browser
    - size: Optional[Tuple[int, int]] - Window size (width, height)
    - position: Optional[Tuple[int, int]] - Window position (left, top)
    - geometry: Dict[str, Tuple[int, int]] - Per-page geometry settings
    - close_callback: Optional[Callable] - Callback when websocket closes
    - app_mode: bool - Whether to run in app mode
    - all_interfaces: bool - Listen on all network interfaces
    - disable_cache: bool - Disable browser caching
    - default_path: str - Default file for root URL
    - app: Bottle - Custom Bottle app instance
    - shutdown_delay: float - Delay before shutdown detection
    - suppress_error: bool - Suppress v1.0.0 API change warnings
    
    Returns:
    None
    """

Usage Examples:

# Basic startup
eel.start('main.html')

# Custom configuration
eel.start('index.html', 
          mode='chrome',
          size=(1200, 800),
          position=(100, 100))

# Multiple URLs
eel.start('page1.html', 'page2.html', mode='electron')

# Non-blocking startup
eel.start('app.html', block=False)

# With close callback
def on_close(page, sockets):
    print(f"Page {page} closed")

eel.start('main.html', close_callback=on_close)

Show Additional Windows

Open additional browser windows/tabs after the application has started.

def show(*start_urls: str) -> None:
    """
    Show specified URLs in browser windows.
    
    Parameters:
    - *start_urls: str - URLs to open in browser
    
    Returns:
    None
    """

Usage Example:

# Show additional windows
eel.show('settings.html')
eel.show('help.html', 'about.html')

Custom Bottle Integration

Register Eel routes with a custom Bottle application instance for advanced middleware integration.

def register_eel_routes(app: Bottle) -> None:
    """
    Register required Eel routes with custom Bottle app.
    
    Parameters:
    - app: Bottle - Bottle application instance
    
    Returns:
    None
    """

Usage Example:

import bottle
import eel

# Create custom Bottle app
app = bottle.Bottle()

# Add middleware (e.g., authentication)
# ... middleware setup ...

# Register Eel routes
eel.register_eel_routes(app)

# Start with custom app
eel.init('web')
eel.start('index.html', app=app)

Install with Tessl CLI

npx tessl i tessl/pypi-eel

docs

async-operations.md

browser-management.md

build-tools.md

core-functions.md

index.md

tile.json