You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Seeing change_order.py, I realized that you used @contextmanager functions to use with statement. You didn't use them in other scripts. I would like to know why you used it. Is it better? Does it close automatically the reference or something like that?
@MarioMey I've used context managers a lot in Scripted-text. Yes, yes as soon as its leaves closure.
You might also want to use ExitStack since it can select context mangers based on condition. It also reduces nesting level e.g consider this code:
defsanic_effect(self):
"really fast speed text scrolling(filter)"# add filter scroll to source if not present,self.update_text(self._scripted_text)
withsource_ar(self.source_name) assource, filter_ar(
source, "py_scroll"
) asscroll:
ifscrollisNone:
withdata_ar() assettings:
obs.obs_data_set_int(settings, "speed_x", 5000)
withp_source_ar("scroll_filter", "py_scroll", settings) as_source:
obs.obs_source_filter_add(source, _source)
withdata_ar(scroll) asfilter_settings:
obs.obs_data_set_int(filter_settings, "speed_x", 5000)
obs.obs_source_update(scroll, filter_settings)
ifself.duration//self.refresh_rate<=3:
obs.obs_source_filter_remove(source, scroll)
self.duration=0
Activity
upgradeQ commentedon Jan 22, 2021
@MarioMey I've used context managers a lot in Scripted-text. Yes, yes as soon as its leaves closure.
You might also want to use
ExitStacksince it can select context mangers based on condition. It also reduces nesting level e.g consider this code:Using
ExitStackunreleased versionSure, I think we can try using
Discussions