-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathdebug_exmpl.py
72 lines (50 loc) · 1.77 KB
/
debug_exmpl.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
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
import obspython as S
import debugpy
class Hotkey:
def __init__(self, callback, obs_settings, _id):
self.obs_data = obs_settings
self.hotkey_id = S.OBS_INVALID_HOTKEY_ID
self.hotkey_saved_key = None
self.callback = callback
self._id = _id
self.load_hotkey()
self.register_hotkey()
self.save_hotkey()
def register_hotkey(self):
description = "Htk " + str(self._id)
self.hotkey_id = S.obs_hotkey_register_frontend(
"htk_id" + str(self._id), description, self.callback
)
S.obs_hotkey_load(self.hotkey_id, self.hotkey_saved_key)
def load_hotkey(self):
self.hotkey_saved_key = S.obs_data_get_array(
self.obs_data, "htk_id" + str(self._id)
)
S.obs_data_array_release(self.hotkey_saved_key)
def save_hotkey(self):
self.hotkey_saved_key = S.obs_hotkey_save(self.hotkey_id)
S.obs_data_set_array(
self.obs_data, "htk_id" + str(self._id), self.hotkey_saved_key
)
S.obs_data_array_release(self.hotkey_saved_key)
class h:
htk_copy = None # this attribute will hold instance of Hotkey
def cb1(pressed):
debugpy.breakpoint()
if pressed:
print("callback1: " + e1.txt)
class e:
txt = "default txt"
e1 = e()
h1 = h()
def script_properties():
props = S.obs_properties_create()
S.obs_properties_add_text(props, "_text1", "_text1:", S.OBS_TEXT_DEFAULT)
return props
def script_update(settings):
_text1 = S.obs_data_get_string(settings, "_text1")
e1.txt = _text1
def script_load(settings):
h1.htk_copy = Hotkey(cb1, settings, "h1_id")
def script_save(settings):
h1.htk_copy.save_hotkey()