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
using observeInBackground() with onAppear() and onVanish()
want to use Region.setInactive() and Region.setActive() to manage when what event should be observed
The problem: activation/deactivation of events did not work.
It is fixed now and additionally we have Event::setInactive() for use in a handler.
In the following workflow the image is not visible in the beginning and then appears and vanishes again and so on.
start = time.time()
def now():
return 0.01 * int(100 * (time.time() - start))
def handler(evt):
global stop
cnt = evt.getCount()
if evt.isAppear():
name = "ona"
evt.setInactive() # deactivate onAppear
evt.getRegion().setActive(onv) # activate onVanish
else :
name = "onv"
evt.setInactive() # deactivate onVanish
evt.getRegion().setActive(ona) # deactivate onAppear
print "in handler:", name, cnt, now() # activate onAppear
if cnt > 2: stop = True
img = "img.png"
ona = onAppear(img, handler)
print "ona:", ona
onv = onVanish(img, handler)
print "onv:", onv
setInactive(onv) # to avoid triggering onVanish at start
stop = False
observeInBackground(FOREVER)
while not stop:
wait(1)
While the script is running I am making the image hidden/visible manually.
... and the printout:
ona: 1576919468469
onv: 1576919468495
in handler: ona 1 2.68
in handler: onv 1 5.15
in handler: ona 2 7.58
in handler: onv 2 9.87
in handler: ona 3 11.7
The text was updated successfully, but these errors were encountered:
The test case:
observeInBackground()
withonAppear()
andonVanish()
Region.setInactive()
andRegion.setActive()
to manage when what event should be observedThe problem: activation/deactivation of events did not work.
It is fixed now and additionally we have Event::setInactive() for use in a handler.
In the following workflow the image is not visible in the beginning and then appears and vanishes again and so on.
While the script is running I am making the image hidden/visible manually.
... and the printout:
The text was updated successfully, but these errors were encountered: