Python and Tauri example #5898
saisaigraph
started this conversation in
General
Replies: 1 comment
-
Check out Pyo3. https://pyo3.rs/v0.19.1/ Here's a simple test from my Tauri app:
...
[dependencies.pyo3]
version = "0.18.1"
features = ["auto-initialize"]
use pyo3::prelude::*;
use pyo3::types::IntoPyDict;
async fn main() {
...
}
fn run_python() -> PyResult<()> {
Python::with_gil(|py| {
let sys = py.import("sys")?;
let version: String = sys.getattr("version")?.extract()?;
let locals = [("os", py.import("os")?)].into_py_dict(py);
let code = "os.getenv('USER') or os.getenv('USERNAME') or 'Unknown'";
let user: String = py.eval(code, None, Some(&locals))?.extract()?;
println!("Hello {}, I'm Python {}", user, version);
Ok(())
})
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Just wondering if any examples of Python and Tauri are available.
Tauri looks great.
Thanks
Sai
Beta Was this translation helpful? Give feedback.
All reactions