-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExample.py
More file actions
80 lines (63 loc) · 2.68 KB
/
Example.py
File metadata and controls
80 lines (63 loc) · 2.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
from Form import *
class OptionFormExample:
settings = FormSettings()
settings.editSetting(FormSettings.Setting.HEADER, "+-+-+-+-+-+-+-+-+-")
settings.editSetting(FormSettings.Setting.SEPARATOR, "/*******************\\")
settings.editSetting(FormSettings.Setting.CLEAR_FORM_AFTER_FORM, True)
settings.editSetting(FormSettings.Setting.DEFAULT_CALLBACK, lambda: print("Default callback"))
settings.editSetting(FormSettings.Setting.OPTIONS_TEXT, "Pick an option!!!")
settings.editSetting(FormSettings.Setting.CLEAN_FAILED_RESPONSES, 2)
form = OptionForm(
title="Form Title",
body="This is a form with three options.",
settings=settings # Displays assigning settings after during creation
)
form.addOption(
name="Option 1",
callback=lambda: print("Option 1 selected"),
isDefault=True
)
form.addOption(
name="Option 2",
callback=lambda: print("Option 2 selected"),
tooltip="This is a tooltip for Option 2"
)
form.addSeparator()
form.addOption(
name="Option 3",
callback=lambda: print("Option 3 selected")
)
form.addSeparator("This is a separator with a tooltip")
form.send()
class InputFormExample:
form = InputForm(
title="Form Title",
body="This is a form with three inputs."
)
settings = FormSettings()
settings.editSetting(FormSettings.Setting.HEADER, "\\/\/\/\/\/\/\/\/\/")
settings.editSetting(FormSettings.Setting.SEPARATOR, "/*******************\\" + "\n" + "\\*******************/")
settings.editSetting(FormSettings.Setting.CLEAR_FORM_AFTER_FORM, True)
settings.editSetting(FormSettings.Setting.DEFAULT_CALLBACK, lambda: print("\nValue Entered\n"))
form.settings = settings # Displays assigning settings after form creation
form.registerTextInput(
name="Text Input",
tooltip="This is a tooltip for Text input",
validation=lambda response: False if response else "Please do not leave this field empty.",
# callback=lambda self: self.settings.editSetting(FormSettings.Setting.CLEAR_FORM_AFTER_ACTION, True)
)
form.registerBoolInput(
name="Bool input",
tooltip="This is a tooltip for Bool input",
default=True
)
form.addSeparator()
form.registerNumberInput(
name="Number Input",
tooltip="This is a tooltip for Number input",
numType=InputForm.NumConsts.NUM_FLOAT
)
response = form.send()
print("\n\nResponse:")
for key, value in response.items():
print(f"{key}: {value.get(InputForm.DataEntryConsts.RESPONSE, 'No response')} ({type(value.get(InputForm.DataEntryConsts.RESPONSE, None))})")