You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+7-4Lines changed: 7 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -53,9 +53,13 @@ Javascript in [examples/plain-javascript](https://github.com/marcomq/tauri-plugi
53
53
These steps assume that you already have a basic tauri application available. Alternatively, you can immediately start with the application in "example" directory.
54
54
55
55
- run `npm run tauri add python`
56
-
- add `src-tauri/src-python/main.py` and modify it acording to your needs, for example add `def greet_python(intput): return str(input) + " from python"`
57
-
- modify `src-tauri/src/lib.rs` and change `.plugin(tauri_plugin_python::init())` to `.plugin(tauri_plugin_python::init_and_register(["greet_python"]))`; make sure you list all python functions you
58
-
want to call
56
+
- add `src-tauri/src-python/main.py` and modify it acording to your needs, for example add
57
+
```python
58
+
# src-tauri/src-python/main.py
59
+
_tauri_plugin_functions = ["greet_python"] # make "greet_python" callable from UI
60
+
defgreet_python(rust_var)
61
+
returnstr(rust_var) +" from python"
62
+
```
59
63
- add `"bundle": {"resources": [ "src-python/**/*"],` to `tauri.conf.json` so that python files are bundled with your application
60
64
- add the plugin in your js, so
61
65
- add `import { callFunction } from 'tauri-plugin-python-api'`
@@ -74,7 +78,6 @@ Tauri events and calling js from python is currently not supported yet. You woul
74
78
```python
75
79
# src-tauri/src-python/main.py
76
80
defgreet_python(rust_var)
77
-
print(rust_var)
78
81
returnstr(rust_var) +" from python"
79
82
```
80
83
- add `.plugin(tauri_plugin_python::init_and_register(vec!["greet_python"))` to `tauri::Builder::default()`, usually in `src-tauri/src/lib.rs`. This will initialize the plugin and make the python function "greet_python" available from javascript.
0 commit comments