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: TheWindowinstance.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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file shellac_webview-1.3.2.tar.gz.
File metadata
- Download URL: shellac_webview-1.3.2.tar.gz
- Upload date:
- Size: 10.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8af2b6c5559ac452f0369563a9de3ae51dfdcb7524f0aa1418fdd324331ef0ec
|
|
| MD5 |
12c1c544e02baf87407d439646531104
|
|
| BLAKE2b-256 |
010866900fc4fa12cc257bc181bb7258bb0b5f6c86b307ab6c2da456e95aba10
|
Provenance
The following attestation bundles were made for shellac_webview-1.3.2.tar.gz:
Publisher:
release.yml on Sharkow1743/shellac-webview
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
shellac_webview-1.3.2.tar.gz -
Subject digest:
8af2b6c5559ac452f0369563a9de3ae51dfdcb7524f0aa1418fdd324331ef0ec - Sigstore transparency entry: 1201870766
- Sigstore integration time:
-
Permalink:
Sharkow1743/shellac-webview@5f562ae26fea85c587ccee077d61ec357c780eca -
Branch / Tag:
refs/tags/v1.3.2 - Owner: https://github.com/Sharkow1743
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@5f562ae26fea85c587ccee077d61ec357c780eca -
Trigger Event:
release
-
Statement type:
File details
Details for the file shellac_webview-1.3.2-py3-none-any.whl.
File metadata
- Download URL: shellac_webview-1.3.2-py3-none-any.whl
- Upload date:
- Size: 10.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3c7b4890acd1bd0b59c17b2d45cc3ab8e89e8bae8f1c6ca681d5454d34715e6b
|
|
| MD5 |
25be12671d64baae8db594c63663a701
|
|
| BLAKE2b-256 |
caabb1f89aee73f19ab3cb5e63aaddeb13eda5e7ebad62670a71c31c71ec8c8a
|
Provenance
The following attestation bundles were made for shellac_webview-1.3.2-py3-none-any.whl:
Publisher:
release.yml on Sharkow1743/shellac-webview
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
shellac_webview-1.3.2-py3-none-any.whl -
Subject digest:
3c7b4890acd1bd0b59c17b2d45cc3ab8e89e8bae8f1c6ca681d5454d34715e6b - Sigstore transparency entry: 1201870769
- Sigstore integration time:
-
Permalink:
Sharkow1743/shellac-webview@5f562ae26fea85c587ccee077d61ec357c780eca -
Branch / Tag:
refs/tags/v1.3.2 - Owner: https://github.com/Sharkow1743
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@5f562ae26fea85c587ccee077d61ec357c780eca -
Trigger Event:
release
-
Statement type: