Repository navigation
Implicit Settings on Button Callback #13
Description
Activity
As an update, I can see that
args[0]holds anobs_data_tobject initially (assuming it'ssettings), but after pushing the button, it's emptied (as well askwargs).What are you trying to do? Have you found a post from @bfxdev about properties ? Maybe this is what are you looking for.

Also a page on the wiki
The
property_modification.pyexample snippet was written in June 2020, and there was no intention to access settings in callback. They are passed implicitly using star arguments because later you cannot access it ( as you confirmed it ).**kwargswere passed just to make sure nothing breaks.
Take a look to a new example: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.
Reacted by Joshua Bodyfelt, PhD- addedquestionFurther information is requestedFurther information is requested
on Feb 10, 2021 Thank you! On button press, I'm looking to auto-iterate integer counter widgets. Been using the global solution, but seems in
script_updateI may have been assigning in the wrong direction (settings = G.settings). I'll play some more with it, and if I get it working I'll post my solution...@jdbodyfelt if you have more questions, ask them in Discussion section. There is where I ask my doubts 😉.
- Repository owner locked and limited conversation to collaborators
on Jul 8, 2021
Hi, sorry to bother it's me again. I have another question popping up in the
property_modification.pyexample. Namely, incallbackyou 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!