pytauri.ffi.lib
¶
Classes:
Name | Description |
---|---|
App |
|
AppHandle |
|
BuilderArgs |
|
Builder |
|
Context |
|
RunEvent |
|
RunEventEnum |
Functions:
Name | Description |
---|---|
builder_factory |
A factory function for creating a |
context_factory |
A factory function for creating a |
Attributes:
Name | Type | Description |
---|---|---|
RunEventEnumType |
TypeAlias
|
See RunEventEnum for details. |
__all__
module-attribute
¶
__all__ = ['App', 'AppHandle', 'Builder', 'BuilderArgs', 'Context', 'RunEvent', 'RunEventEnum', 'RunEventEnumType', 'builder_factory', 'context_factory']
RunEventEnumType
module-attribute
¶
RunEventEnumType: TypeAlias = Union[Exit, ExitRequested, WindowEvent, WebviewEvent, Ready, Resumed, MainEventsCleared, MenuEvent]
See RunEventEnum for details.
App
¶
Warning
This class is not thread-safe, and should not be shared between threads.
- You can only use it on the thread it was created on.
- And you need to ensure it is garbage collected on the thread it was created on, otherwise it will cause memory leaks.
Methods:
Name | Description |
---|---|
run |
Consume and run this app, will block until the app is exited. |
run_iteration |
Run this app iteratively without consuming it, calling |
cleanup_before_exit |
Runs necessary cleanup tasks before exiting the process. |
run
¶
Consume and run this app, will block until the app is exited.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
Optional[_AppRunCallbackType]
|
a callback function that will be called on each event. It will be called on the same thread that the app was created on, so you should not block in this function. |
None
|
Warning
If callback
is specified, it must not raise an exception,
otherwise it is undefined behavior, and in most cases, the program will panic.
Source code in python/pytauri/src/pytauri/ffi/lib.py
run_iteration
¶
Run this app iteratively without consuming it, calling callback
on each iteration.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
Optional[_AppRunCallbackType]
|
a callback function that will be called on each iteration. |
None
|
Warning
callback
has the same restrictions as App.run.
Tip
Approximately 2ms per calling in debug mode.
Source code in python/pytauri/src/pytauri/ffi/lib.py
cleanup_before_exit
¶
Runs necessary cleanup tasks before exiting the process.
You should always exit the tauri app immediately after this function returns and not use any tauri-related APIs.
AppHandle
¶
BuilderArgs
¶
Methods:
Name | Description |
---|---|
__new__ |
__new__
¶
__new__(*, context: Context, invoke_handler: Optional[_InvokeHandlerProto] = None) -> Self
Warning
The implementer of invoke_handler
must never raise an exception,
otherwise it is considered undefined behavior.
Additionally, invoke_handler
must not block.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
Context
|
use context_factory to get it. |
required |
|
Optional[_InvokeHandlerProto]
|
use Commands to get it. |
None
|
Source code in python/pytauri/src/pytauri/ffi/lib.py
Builder
¶
use builder_factory to instantiate this class.
Warning
This class is not thread-safe, and should not be shared between threads.
- You can only use it on the thread it was created on.
- And you need to ensure it is garbage collected on the thread it was created on, otherwise it will cause memory leaks.
Methods:
Name | Description |
---|---|
build |
Consume this builder and build an app with the given |
Context
¶
RunEvent
¶
Bases: PyMatchRefMixin['RunEventEnumType']
Methods:
Name | Description |
---|---|
match_ref |
Equivalent to |
RunEventEnum
¶
Classes:
Name | Description |
---|---|
Exit |
|
ExitRequested |
|
WindowEvent |
|
WebviewEvent |
|
Ready |
|
Resumed |
|
MainEventsCleared |
|
MenuEvent |
builder_factory
¶
A factory function for creating a Builder
instance.
This is the closure passed from the Rust side when initializing the pytauri pyo3 module.
args
and kwargs
will be passed to this closure.
Source code in python/pytauri/src/pytauri/ffi/lib.py
context_factory
¶
A factory function for creating a Context
instance.
This is the closure passed from the Rust side when initializing the pytauri pyo3 module.
args
and kwargs
will be passed to this closure.