Files
XtendR/example.py
2025-03-28 18:22:16 +01:00

32 lines
1.0 KiB
Python

import time
from xtendr.xtendrsystem import XtendRSystem
def my_callback():
print("'example_plugin is finished pre-loading")
if __name__ == "__main__":
"""Example usage of the PluginSystem.
Example:
>>> system = XtendR()
>>> system.attach("example_plugin")
Attached plugin 'example_plugin'.
>>> system.run("example_plugin")
ExamplePlugin is running!
>>> system.stop("example_plugin")
ExamplePlugin has stopped!
>>> system.detach("example_plugin")
Detached plugin 'example_plugin'.
"""
system = XtendRSystem()
system.attach("example_plugin", my_callback) # Assuming 'example_plugin/plugin_info.json' exists
for i in range(3):
print(f"Main program is running iteration {i+1}...")
time.sleep(2)
system.run("example_plugin", test="Hello!")
system.stop("example_plugin")
system.run("example_plugin", 25)
system.stop("example_plugin")
system.run("example_plugin", "Hello!", 25)
system.stop("example_plugin")
system.detach("example_plugin")