Use your web dev skills to design UIs for your Python apps with this simple, Rust-powered webview library.
Project description
Dry: a simple webview library
Dry is a tiny, no-dependency webview library that lets you use your web development skills to create user interfaces for your Python applications. Built with Rust on top of Wry.
Why?
- Familiar Tech: Use HTML, CSS and JS to design your UIs!
- Flexible Content: Render from an HTML string or from a URL.
- Customizable: Support for borderless windows with custom titlebars!
- Callbacks: Interact with Python from JavaScript!
Installation
Getting started with Dry is straightforward. Simply use pip or uv to install:
pip install dry-webview
uv add dry-webview
Getting Started
Here's a quick example of how to use Dry to create a simple webview:
from dry import Webview
wv = Webview()
wv.title = "My Python App!"
wv.content = "<h1>Hello, World!</h1>"
wv.run()
For more examples, check out the examples directory.
Features
Flexible Content
The Webview class supports loading content from a string containing HTML or from a URL. You could, for example, compile your HTML, CSS and JS into a single file and load it into the webview.
wv.content = "<h1>Hello, World!</h1>" or "http://localhost:8000"
If your UI needs to come from a server, know that wv.run() blocks the main thread. Consider running the server from a separate thread (preferably a daemon one, which will shutdown along with the main thread).
import threading
from dry import Webview
def serve_files():
# Your server logic here
if __name__ == "__main__":
thread = threading.Thread(target=serve_files, daemon=True)
thread.start()
wv = Webview()
wv.content = "http://localhost:8000"
wv.run()
Custom Titlebar
Dry supports custom titlebars, allowing you to create a unique look for your application. You tell the Webview class to hide decorations like this:
wv.decorations = False
And then you can use data-drag-region to define the draggable area in your HTML, which will probably be your custom titlebar:
<div data-drag-region>
<h1>Custom Titlebar</h1>
</div>
A window without decorations will automatically be draggable within the data-drag-region area, having resize handles automatically positioned at all corners.
With or without decorations, basic window controls are available from the DOM, allowing you to minimize, maximize and close window. More are to come in the future.
<button onclick="window.minimize()">Minimize</button>
<button onclick="window.toggleMaximize()">Maximize</button>
<button onclick="window.close()">Close</button>
Callbacks
You can use callbacks to interact with Python from JavaScript. You define them like this:
def hello_world():
return "Hello, World!"
def dumb_sum(a, b):
return a + b
api = {
"helloWorld": hello_world,
"dumbSum": dumb_sum
}
wv = Webview()
wv.api = api
wv.run()
And then you can call them from JavaScript as follows:
const hello = await window.api.helloWorld();
const sum = await window.api.dumbSum(1, 2);
console.log(hello); // Hello, World!
console.log(sum); // 3
Be aware of the supported data types for function arguments and return values:
| Python Type | JavaScript Type |
|---|---|
| None | null |
| bool | boolean |
| int | number |
| float | number |
| str | string |
| list | array |
| tuple | array |
| set | array |
| dict | object |
| bytes | number[] |
Other
The Webview class has a few options you can set through its properties:
| Property | Description |
|---|---|
| title | The window title. Defaults to 'My Dry Webview'. |
| min_size | Minimum window dimensions (width, height). |
| size | Initial window dimensions (width, height). |
| decorations | Whether to show window decorations (title bar, borders). |
| icon_path | Path to the window icon file (.ico format). |
| content | HTML content or URL to display in the window. |
| api | JavaScript-accessible Python functions. |
| dev_tools | Whether to enable developer tools. |
| user_data_folder | Path to store user data. Defaults to temp folder. |
Current Status
Dry is in its early stages and currently supports Windows only. Expect ongoing development, new features, and potential changes.
Platform Compatibility
| Platform | Status |
|---|---|
| Windows 11 | ✅ Tested |
| Linux | ❌ Not Yet |
| macOS | ❌ Not Yet |
Python Compatibility
| Python Version | Status |
|---|---|
| CPython 3.11 | ✅ Tested |
| CPython 3.12 | ✅ Tested |
| CPython 3.13 | ✅ Tested |
License
Dry is distributed under the MIT License. For more details, see the LICENSE file.
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 Distributions
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 dry_webview-0.3.2.tar.gz.
File metadata
- Download URL: dry_webview-0.3.2.tar.gz
- Upload date:
- Size: 48.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.7.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cdd1e066dae8b38eb48f0f294b99a210f0f6ca2bf29c846851f903a48d480c1b
|
|
| MD5 |
24bb7dfc3d8e7beed02e77694ffa44a1
|
|
| BLAKE2b-256 |
913784420b68a3d000179ee820c3041d4a6077a061571ae727c47e84e6841835
|
File details
Details for the file dry_webview-0.3.2-cp313-cp313-win_amd64.whl.
File metadata
- Download URL: dry_webview-0.3.2-cp313-cp313-win_amd64.whl
- Upload date:
- Size: 392.4 kB
- Tags: CPython 3.13, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.7.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d6bbb8caed74dc9ecff05fd91a03e41c8986f0844f4d7d06ab2a8292e88591a1
|
|
| MD5 |
e80427ac1f20646bd0b275df5ea2aa64
|
|
| BLAKE2b-256 |
5075b0f621f49ce439607d6e82656f295e8e0f670b961fb25b92d57840412c9a
|
File details
Details for the file dry_webview-0.3.2-cp312-cp312-win_amd64.whl.
File metadata
- Download URL: dry_webview-0.3.2-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 392.5 kB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.7.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dac8a1fcd622ad6fae185f80991b40dca8ad5e47cdbd5a4d8e0fe4314b33dcde
|
|
| MD5 |
0117dd965301363e0434143b53d78bf6
|
|
| BLAKE2b-256 |
076ff10f3e416c238236c91184dcfb2f41c1301231589421b06a1915709930d1
|
File details
Details for the file dry_webview-0.3.2-cp311-cp311-win_amd64.whl.
File metadata
- Download URL: dry_webview-0.3.2-cp311-cp311-win_amd64.whl
- Upload date:
- Size: 393.3 kB
- Tags: CPython 3.11, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.7.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2f94db13290e942d180b4af635a54dd1f9ac3d98595309b216bf83c2c38a5cee
|
|
| MD5 |
611c07b0bce59b977e8893f60e8b7e7f
|
|
| BLAKE2b-256 |
3235cf4ff7b9cd8335894297769c757eaeb94003d67080f3aa9f20d9ec5749d0
|