Implicit Settings on Button Callback #24
Replies: 4 comments
-
As an update, I can see that |
Beta Was this translation helpful? Give feedback.
-
What are you trying to do? Have you found a post from @bfxdev about properties ? Maybe this is what are you looking for. The import obspython as obs
from itertools import count
G = lambda: ...
G.settings = None
G.n = 0
G.counter = count()
def refresh_pressed(props, prop, *args): # pass settings implicitly
print("refresh pressed")
if args:
G.counter = count(obs.obs_data_get_int(args[0], "saved_int"))
G.n = next(G.counter)
p = obs.obs_properties_get(props, "button")
obs.obs_property_set_description(p, f"refresh pressed {G.n} times")
return True
def script_description():
return "Modify property and save/load from settings "
def script_load(settings):
G.settings = settings
def script_save(settings):
obs.obs_data_set_int(settings, "saved_int", G.n)
G.settings = settings
def script_properties():
props = obs.obs_properties_create()
b = obs.obs_properties_add_button(
props, "button", "refresh pressed m times", refresh_pressed
)
obs.obs_property_set_modified_callback(b, refresh_pressed)
obs.obs_properties_apply_settings(props, G.settings)
return props In order to access settings in callback they must be global. |
Beta Was this translation helpful? Give feedback.
-
Thank you! On button press, I'm looking to auto-iterate integer counter widgets. Been using the global solution, but seems in |
Beta Was this translation helpful? Give feedback.
-
@jdbodyfelt if you have more questions, ask them in Discussion section. There is where I ask my doubts 😉. |
Beta Was this translation helpful? Give feedback.
-
Hi, sorry to bother it's me again. I have another question popping up in the
property_modification.py
example. Namely, incallback
you mention that settings are passed implicitly, however, how do you access them within the callback? I've tried afor key, val in kwargs.items(): print(key, val)
, but it does not produce anything. Thank you!Beta Was this translation helpful? Give feedback.
All reactions