-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsave_json_data.py
36 lines (27 loc) · 974 Bytes
/
save_json_data.py
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
import obspython as S
from pathlib import Path
class Data:
_text_ = None
_int_ = None
_settings_ = None
def save(prop, props):
if not Data._settings_:
return
p = Path(__file__).absolute() # current script path
file = p.parent / "saved_settings.json"
try:
content = S.obs_data_get_json(Data._settings_)
with open(file, "w") as f:
f.write(content)
except Exception as e:
print(e, "cannot write to file")
def script_properties():
props = S.obs_properties_create()
S.obs_properties_add_text(props, "_text", "text", S.OBS_TEXT_DEFAULT)
S.obs_properties_add_int(props, "_int", "int", 1, 100, 1)
S.obs_properties_add_button(props, "save", "Save", save)
return props
def script_update(settings):
Data._text_ = S.obs_data_get_string(settings, "_text")
Data._int_ = S.obs_data_get_int(settings, "_int")
Data._settings_ = settings