Is a loading window possible?

Your function names and indenting don’t match up. Where’s updateMapRateInfo ?

The point is that you have to call updateUI multiple times from the background to keep the progress bar moving. You may need various different updateUI functions at different points to update different things in the foreground. You almost certainly need different updateUI functions to assign results to the foreground components, separate from the progress bar updates.

Consider using the helpers from later.py, as described in this thread, to simplify your code. Your actionPerformed event would end up something like this:

def updateMapRateInfo(ev):
	progress = ev.source.parent.getComponent("Progess Bar")
	shared.later.assignLater(progress, "indeterminate", True)
	shared.later.assignLater(progress, "visible", True)

	# Do initial queries that will let you predict the maximum
	# you should use for the progress bar.  Then show it with:
	shared.later.assignLater(progress, "maximum", someMaximum)
	done = 0
	shared.later.assignLater(progress, "value", done)
	shared.later.assignLater(progress, "indeterminate", False)

	# Start doing your work, looping or whatever, with occassional
	# calls to show "done" in the the progress bar.  It can be
	# every time if maximum is a small number, or every ten or
	# hundred otherwise.  You don't want to spend more time
	# notifying the foreground than actually doing work.
	for row in pyds:
		done += 1
		if not (done % 10):
			shared.later.assignLater(progress, "value", done)
		# Do something with the row

	# When calculations are done, assign the results in the
	# foreground, and hide the progress bar:
	table = ev.source.parent.getComponent("Table")
	shared.later.assignLater(table, "data", newTableData)
	shared.later.assignLater(progress, "visible", False)

shared.later.callAsync(updateMapRateInfo, event)
3 Likes