Skip to main content

No project description provided

Project description

Shellac Webview

A Selenium wrapper for building desktop applications using web technologies. It uses FastAPI for backend communication and Selenium for browser automation.

Installation

pip install shellac-webview

Basic Usage

from shellac import Window

win = Window()

@win.bind
def my_function(event):
    return "Data from Python"

html = """
<button onclick="run()">Run</button>
<script>
    async function run() {
        const result = await webui.call("my_function");
        console.log(result);
    }
</script>
"""

win.show(html)
win.wait()

Binding

You can bind functions in python to be called from js using webui.call("func_name")

Function Binding

You can bind a specific function to a name.

def my_function(event):
    return f"Hello, {event.data[0]}!"

win.bind("greet", my_function)

JS Usage:

const response = await webui.call("greet", "Alice");
console.log(response); // "Hello, Alice!"

Decorator Binding

Use the @bind decorator for a cleaner syntax.

@win.bind
def calculate(event):
    return event.data[0] * 2

JS Usage: webui.call("calculate", 21);

Class/Namespace Binding

You can bind an entire class or instance. All public methods (not starting with _) will be available in JavaScript.

@win.bind("db")
class Database:
    def get_user(self, event):
        return {"id": event.data[0], "name": "John Doe"}

or with

win.bind("db", Database())

JS Usage:

const user = await webui.call("db.get_user", 1);

Class Mapping

If you bind a class without a prefix, its methods are mapped to the top-level.

class API:
    def status(self, event):
        return "Online"

win.bind(API)

JS Usage: webui.call("status");

The Event Object

Every bound Python function receives an Event object as its first argument.

  • event.window: The Window instance.
  • event.data: A list of arguments passed from JavaScript.
  • event.element: The name of the function called.

Window Configuration

You can configure the window size and behavior before calling show().

win = Window()
win.config.width = 1200
win.config.height = 900
win.config.hide_controls = True # Hides address bar/tabs (App Mode)
win.config.kiosk = False        # Fullscreen mode

Browser Selection

By default, the library looks for Chrome, Edge, or Firefox. You can force a specific browser:

from webui import Browser

win.show("index.html", browser=Browser.Firefox)

Available options: Chrome, Firefox, Edge, Chromium, Brave, Vivaldi.

Other functions

Once the window is running, you can navigate to new pages or execute JavaScript from Python.

# Navigate to a new URL
win.navigate("https://google.com")

# Execute JS directly
win.run_js("alert('Hello from Python!')")

# Change title
win.set_title("New Title")

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

shellac_webview-1.3.3.tar.gz (10.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

shellac_webview-1.3.3-py3-none-any.whl (10.4 kB view details)

Uploaded Python 3

File details

Details for the file shellac_webview-1.3.3.tar.gz.

File metadata

  • Download URL: shellac_webview-1.3.3.tar.gz
  • Upload date:
  • Size: 10.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for shellac_webview-1.3.3.tar.gz
Algorithm Hash digest
SHA256 c9bb2f2067b2728363ce5e3037568a484c603993fb3fb9e602111b75ad5fbbf0
MD5 6e72a9293e0a90460f7533e9b986a49c
BLAKE2b-256 565965d445dbe6da329dd4eb9f1bd3aaa97917a3e4e57e4c3b951eb9635f108f

See more details on using hashes here.

Provenance

The following attestation bundles were made for shellac_webview-1.3.3.tar.gz:

Publisher: release.yml on Sharkow1743/shellac-webview

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file shellac_webview-1.3.3-py3-none-any.whl.

File metadata

File hashes

Hashes for shellac_webview-1.3.3-py3-none-any.whl
Algorithm Hash digest
SHA256 dfb646422e3da804a29af240e7933122254c23c61e554203f5b29f6e6ea62fb3
MD5 b803f9c20c16225e1a2b8ab74a7183b7
BLAKE2b-256 b1bf38db30fef0bcd7e9b27adeb9004472ad5fc1d184c1c7fdf6f6dfb0a572c1

See more details on using hashes here.

Provenance

The following attestation bundles were made for shellac_webview-1.3.3-py3-none-any.whl:

Publisher: release.yml on Sharkow1743/shellac-webview

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page