Skip to content

WSH032/pytauri

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PyTauri

Tauri bindings for Python through Pyo3


CI: docs

Documentation: https://wsh032.github.io/pytauri/

Source Code: https://github.com/WSH032/pytauri/


Features

TL;DR

You are hurry and just wanna see/run the demo? See examples/tauri-app.

  • Need Rust compiler, but almost don't need to write Rust code!

  • Can be integrated with tauri-cli to build and package standalone executables!

  • No IPC (inter-process communication) overhead, secure and fast, thanks to Pyo3!

  • Support Tauri official plugins(e.g., notification), and you can write your own plugins!

    demo

  • Natively support async python (asyncio, trio or anyio)

  • 100% Type Completeness

  • Ergonomic API (and as close as possible to the Tauri Rust API)

    • Python

      import sys
      
      from pydantic import BaseModel
      from pytauri import (
          AppHandle,
          Commands,
      )
      from pytauri_plugin_notification import NotificationBuilderArgs, NotificationExt
      
      commands: Commands = Commands()
      
      
      class Person(BaseModel):
          name: str
      
      
      class Greeting(BaseModel):
          message: str
      
      
      @commands.command()
      async def greet(body: Person, app_handle: AppHandle) -> Greeting:
          notification_builder = NotificationExt.builder(app_handle)
          notification_builder.show(
              NotificationBuilderArgs(title="Greeting", body=f"Hello, {body.name}!")
          )
      
          return Greeting(
              message=f"Hello, {body.name}! You've been greeted from Python {sys.version}!"
          )
    • Frontend

      import { pyInvoke } from "tauri-plugin-pytauri-api";
      // or: `const { pyInvoke } = window.__TAURI__.pytauri;`
      
      export interface Person {
          name: string;
      }
      
      export interface Greeting {
          message: string;
      }
      
      export async function greet(body: Person): Promise<Greeting> {
          return await pyInvoke("greet", body);
      }
  • Can be integrated with nicegui/gradio/FastAPI to achieve a full-stack Python development experience (i.g., without Node.js). See examples/nicegui-app.

Release

We follow Semantic Versioning 2.0.0.

Rust and its Python bindings, PyTauri core and its plugins will keep the same MAJOR.MINOR version number.

name pypi crates.io npmjs
👉 core - - -
pytauri pytauri-pypi-v pytauri-crates-v
pytauri-core pytauri-core-crates-v
tauri-plugin-pytauri tauri-plugin-pytauri-crates-v tauri-plugin-pytauri-api-npm-v
👉 plugins - - -
pytauri-plugin-notification pytauri-plugin-notification-pypi-v pytauri-plugin-notification-crates-v
👉 utils - - -
pyo3-utils pyo3-utils-pypi-v pyo3-utils-crates-v
codelldb codelldb-pypi-v

Philosophy

For Pythoneer

I hope PyTauri can become an alternative to pywebview and Pystray, leveraging Tauri's comprehensive features to offer Python developers a GUI framework and a batteries-included development experience similar to electron and PySide.

PyTauri is inspired by FastAPI and Pydantic, aiming to offer a similar development experience.

For Rustacean

Through Pyo3, I hope Rust developers can better utilize the Python ecosystem (e.g., building AI GUI applications with PyTorch).

Although Rust's lifetime and ownership system makes Rust code safer, Python's garbage collection (GC) will make life easier. 😆

Credits

PyTauri is a project that aims to provide Python bindings for Tauri, a cross-platform webview GUI library. Tauri is a trademark of the Tauri Program within the Commons Conservancy and PyTauri is not officially endorsed or supported by them. PyTauri is an independent and community-driven effort that respects the original goals and values of Tauri. PyTauri does not claim any ownership or affiliation with the Tauri Program.

License

This project is licensed under the terms of the Apache License 2.0.