Open popup window in Perspective based on timer?

Greetings all! I am having a hard time getting this script to run as a Gateway Event Script/timer:

import time

#Speed tag that I am monitoring
badSpeed = system.tag.readBlocking('[default]SpeedTag')[0].value

#Set time allowed before script runs
maxTime = 20

#If max time
if badSpeed < 10:
	start = time.time()
	elapsed = 0
	while elapsed < maxTime:
		elapsed = time.time() - start

I am just trying to have a window pop up after x minutes that makes the user take an action. If the user doesn't take an action in x minutes after window is open, it closes automatically and sets a different tag to a default value.

I can't get the window to pop up?? Any help for a rookie or an idea?


Under no circumstances should burn CPU time in such a busy loop. Don't use Avoid using any form of .sleep(), either, as it will also lock up your user interface.

Wait. You are also trying to open a Vision window with system.nav. but your post is tagged Perspective.

Perspective is a bit more tolerant of .sleep(), but a state machine driven by timer events or time binding changes (using a now() expression) are far superior. And you can abort the action if conditions change.

Further, gateway events and tag change events do not have access to your user interfaces. Instead, in the user interface where you want the popup to open, bind that speed tag to a custom property. Then use an onChange action script to perform your other logic. I recommend saving a timestamp in another custom property and using that to determine if your minute has expired.

Yes, this will be in Perspective only. Ok thanks, I will try using the custom properties in the view I want the popup to occur. Thanks for the advice! I'll report back any results.