From 9f49cb04a71e8cfc3499b13c1720a0dcac2f1267 Mon Sep 17 00:00:00 2001 From: Joel Collins Date: Wed, 15 Jan 2020 15:32:23 +0000 Subject: [PATCH] Changed example to identify and rename --- docs/source/plugins/structure.rst | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/docs/source/plugins/structure.rst b/docs/source/plugins/structure.rst index f1014870..c5f1c53f 100644 --- a/docs/source/plugins/structure.rst +++ b/docs/source/plugins/structure.rst @@ -27,12 +27,15 @@ A simple extension file, with no API views but application-available methods may parent_stage) return response - def hello_world(): + def rename(new_name): """ - Demonstrate passive method + Rename the microscope """ - return "Hello world!" + microscope = find_component("org.openflexure.microscope") + + microscope.name = new_name + microscope.save_settings() # Create your extension object @@ -40,7 +43,7 @@ A simple extension file, with no API views but application-available methods may # Add methods to your extension my_extension.add_method(identify, "identify") - my_extension.add_method(hello_world, "hello_world") + my_extension.add_method(hello_world, "rename") Once this extension is loaded, any other extensions will have access to your methods: