-
Notifications
You must be signed in to change notification settings - Fork 11
Description
PyOrion
Hello everyone π
Iβm posting this here because maybe youβre interested in trying it out or even contributing.
Iβve developed PyOrion β a framework that enables Python developers to build fully asynchronous, native, web-based GUIs.
The idea was born because existing solutions like pywebview, PySide/Qt, or wxWidgets always run into the same problem:
the GUI event loop blocks the Python main thread or makes asynchronous programming unnecessarily complicated.
So I took a different approach:
The GUI loop runs entirely in a separate Rust process, while communication with Python happens asynchronously via Unix Domain Sockets or Named Pipes.
This allows us to leverage the systemβs native WebView engines β with no separate servers, no blocking, and true cross-platform support.
π¨ The Problem with Existing Solutions
-
pywebview
- Uses native WebViews, but runs the event loop in the same process as Python.
- Result: The Python main thread is blocked.
- Asynchronous workflows are possible, but only through queues or callbacks β messy and hard to maintain.
-
PySide / Qt
- Powerful, but heavyweight: huge runtimes, complex dependencies.
- Async support only via hacks or threading.
-
wxWidgets / Tkinter
- Outdated, minimal web support, blocking event loops.
Core Issue:
All these frameworks tightly couple the GUI loop to the Python main thread β blocking Pythonβs modern async world (asyncio, FastAPI, etc.).
β My Approach: PyOrion
-
Multiprocessing with Rust
The GUI is built using pyo3 and the Tauri Toolkit, running in its own Rust process.
Each process has its own main thread β the event loop runs system-conformant, without blocking Python. -
Native WebView Engine
- macOS β WKWebView
- Windows β WebView2
- Linux β WebKitGTK
- Android β System WebView
β No additional HTTP or WebSocket server required.
-
Asynchronous Communication
- Currently implemented with a WebSocket bridge.
- Soon to be replaced with wryβs
ipc_handlerβ more direct, higher performance, no script injection overhead.
-
Cross-Platform Uniformity
macOS, Linux, Windows, Android, iOS β the same architecture everywhere:
Rust handles the GUI event loop, Python stays 100% async.
βοΈ Architecture Overview
-
Startup Phase
Python launches the Rust process and passes initial configuration (window, options, ports). -
IPC Layer
Bidirectional communication between Python and Rust.- Windows β Named Pipes
- Unix β UDS file descriptors
Deeply integrated with Rustβs GUI event loop.
-
Script Injection
At startup, Rust injects a small script into the WebView (JS) to provide the PyOrion API. -
WebView Runtime
π API Reference
WindowBuilder Methods
Used to configure and initialize a window.
with_always_on_bottom()with_always_on_top()with_closable()with_content_protection()with_decorations()with_focused()with_fullscreen()with_inner_size()with_inner_size_constraints()with_max_inner_size()with_maximizable()with_maximized()with_min_inner_size()with_minimizable()with_position()with_resizable()with_theme()with_title()with_transparent()with_visible()with_visible_on_all_workspaces()with_window_icon()
Window Methods
Runtime operations for window instances (controllable via IPC).
available_monitors()current_monitor()cursor_position()drag_resize_window()drag_window()fullscreen()id()inner_position()inner_size()is_closable()is_decorated()is_focused()is_maximizable()is_maximized()is_minimizable()is_minimized()is_resizable()is_visible()monitor_from_point()outer_position()outer_size()primary_monitor()request_redraw()request_user_attention()scale_factor()set_*()methods (e.g.set_title,set_resizable,set_visible, β¦)theme()title()
WebViewBuilder Methods
Used to configure and initialize a WebView.
with_accept_first_mouse()with_asynchronous_custom_protocol()with_autoplay()with_back_forward_navigation_gestures()with_background_color()with_bounds()with_clipboard()with_devtools()with_document_title_changed_handler()with_download_*_handler()with_drag_drop_handler()with_focused()with_headers()with_hotkeys_zoom()with_html()with_incognito()with_initialization_script()with_navigation_handler()with_new_window_req_handler()with_on_page_load_handler()with_proxy_config()with_transparent()with_url()with_user_agent()with_visible()with_web_context()
WebView Methods
Runtime operations for WebViews.
bounds()clear_all_browsing_data()close_devtools()evaluate_script()focus()is_devtools_open()load_url()open_devtools()print()set_background_color()set_bounds()set_visible()url()zoom()
Native Capabilities
Planned or partially implemented extensions:
clipboardcontrolcenterdialogdirswebviewwindowos_infotray-iconglobal-hotkeymenu
π Command System & JavaScript API
Inspired by Tauri:
- JavaScript can call Python commands via
window.invoke(). - Python can send events and commands to JS (and vice versa).
- Fully asynchronous, IPC-based, isolated from existing frameworks.
Integration with Python Frameworks
PyOrion can be embedded into existing Python web frameworks, e.g.:
- Reflex
- NiceGUI
- Rio
- NextPy
- Dara
- Streamlit
- Gradio
- Dash
- Workcell
Example: JS β Python
window.invoke("get_user", { id: 42 }).then(user => {
console.log("User:", user);
});from pyorion import command
@command
async def get_user(id: int):
return {"id": id, "name": "Alice"}π Key Features
- π Ultra-lightweight
- π₯ π± Cross-Platform (macOS, Windows, Linux, Android, iOS)
- π¦ Modern Core: Rust (TAO + WRY)
- π Security-focused
- β‘ High Performance, small binaries
- π Native integrations
- π Async Command System (Tauri-style)
π€ Community & Support
- β Star the project on GitHub
- π Report bugs or open issues
- π‘ Propose new features
- π§ Submit pull requests
- π£ Share PyOrion with your network
π Conclusion
While frameworks like pywebview, Qt, or wxWidgets block Python or add unnecessary overhead, PyOrion takes a new approach:
- GUI loop in a separate process
- Async IPC (soon
ipc_handlerinstead of WebSocket) - Native WebView integration
- Command system for Python β JavaScript communication (Tauri-inspired)
With PyOrion, itβs finally possible to build truly asynchronous, native, web-based GUIs in Python β lightweight, modern, and cross-platform.