example: expand interactive

This commit is contained in:
Simon Renblad 2024-03-25 15:30:29 +08:00 committed by Sébastien Bourdeauducq
parent 329e7189cc
commit 5a8bc17e4d

View File

@ -7,14 +7,28 @@ class InteractiveDemo(EnvExperiment):
def run(self): def run(self):
print("Waiting for user input...") print("Waiting for user input...")
with self.interactive() as interactive: with self.interactive(title="Interactive Demo") as interactive:
interactive.setattr_argument("pyon_value",
PYONValue(self.get_dataset("foo", default=42)))
interactive.setattr_argument("number", NumberValue(42e-6, interactive.setattr_argument("number", NumberValue(42e-6,
unit="us", unit="us",
precision=4)) precision=4))
interactive.setattr_argument("integer", NumberValue(42, interactive.setattr_argument("integer", NumberValue(42,
step=1, precision=0)) step=1, precision=0))
interactive.setattr_argument("string", StringValue("Hello World")) interactive.setattr_argument("string", StringValue("Hello World"))
interactive.setattr_argument("scan", Scannable(global_max=400,
default=NoScan(325),
precision=6))
interactive.setattr_argument("boolean", BooleanValue(True), "Group")
interactive.setattr_argument("enum",
EnumerationValue(["foo", "bar", "quux"], "foo"),
"Group")
print("Done! Values:") print("Done! Values:")
print(interactive.pyon_value)
print(interactive.boolean)
print(interactive.enum)
print(interactive.number, type(interactive.number)) print(interactive.number, type(interactive.number))
print(interactive.integer, type(interactive.integer)) print(interactive.integer, type(interactive.integer))
print(interactive.string) print(interactive.string)
for i in interactive.scan:
print(i)