drey
February 25, 2026, 5:24am
1
Hi, I’m trying to refresh the vCortex Flow Diagram component from a button click.
I clear the nodes/edges and then call my loadFlow() function:
flow.props.nodes = []
flow.props.edges = []
flow.props.layouting.autoLayout = False
self.view.custom.flowNodes = []
time.sleep(0.1) # temporary delay
self.loadFlow()
Because Perspective property writes are async, the load runs before the clear finishes, causing inconsistent results.
invokeLater does not work in Perspective from this scope, and I know using sleep() is not ideal.
Question:
What is the correct or recommended way in Perspective to add a small delay or queue the load so it runs after the clear is applied?
Thanks!
Searching for the word “delay” in the forum brings up a lot of suggestions….some are better than others.
My favorite method when needing a timer on a Perspective view is to use a custom prop like this:
In Project Browser, select the root of your view.
In Perspective Property Editor scroll down to CUSTOM.
Create a new custom property startTime.
Create an expression binding on startTime with the expression, now(0). This will fire once when the popup opens and save the current timestamp in the custom property.
Create a second tag, timeout.
Add an expression binding,
(now(1000) - {this.custom.startTime}) > 5000
This will evaluate every 1000 ms and will return true when the popup has been …
it seems you have problem and need this delay to make autoLayouting work. In that you can use system.util.invokeAsynchronous() and add your sleep timer inside.
I believe in next release we can an event to fire when the Flow diagram internal loading of nodes and edges are finished.
It’d be nice if there was a first party way to submit functions to the back of the session’s queue.
invokeAsynchronous is pretty heavy handed when all you’re trying to do is run a function after property assignments are complete.
I have an unmerged system.perspective.queueSubmit function in Embr Periscope that does exactly this:
private fun queueSubmit(
function: PyFunction,
delay: Long,
key: String?,
scope: String,
sessionId: String?,
pageId: String?,
): ExecutionQueueScheduledRunnable? {
val executionContext =
PerspectiveExecutionContext(context.perspectiveContext, pageId, sessionId)
val scopeElement = getScope(executionContext, scope)
require(scopeElement != null) { "Failed to acquire scope \"$scope\"." }
if (!scopeElement.isRunning) {
log.debug("Scope element is not running.")
return null
}
This file has been truncated. show original
Unmerged because I got busy and never finished testing it all the way.
2 Likes