# Loading like symbol in vision

**URL:** <https://forum.inductiveautomation.com/t/loading-like-symbol-in-vision/68489>\
**Category:** Ignition\
**Tags:** vision\
**Created:** [January 11, 2023, 3:35pm UTC](https://forum.inductiveautomation.com/t/loading-like-symbol-in-vision/68489 "2023-01-11T15:35:33Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dharani\_T](https://avatars.discourse-cdn.com/v4/letter/d/bc8723/32.png) [@Dharani\_T](https://forum.inductiveautomation.com/u/Dharani_T)\
**Post date:** [January 11, 2023, 3:35pm UTC](https://forum.inductiveautomation.com/t/loading-like-symbol-in-vision/68489/1 "2023-01-11T15:35:33Z")

</div>

Hi,

I would like to know whether there is an option vision to display 'loading' like toastr whenever we click on search/load button.  
I have tried using a label to make it appear for few seconds but i would like to explore toastr kinda thing.

Any suggestions?

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [January 11, 2023, 4:25pm UTC](https://forum.inductiveautomation.com/t/loading-like-symbol-in-vision/68489/2 "2023-01-11T16:25:38Z")

</div>

Properly doing this is somewhat complicated.

The only "off the shelf" component to display a "loading" message is the progress bar, set to "indeterminate". If you don't want to use that, you could set up a label or image component with a loading GIF or whatever else you want.

Then the trick becomes _safely_ using a background thread to perform any long-running calculation without any risk of deadlocking the UI.

I would start by reading up on Swing's "Event Dispatch Thread", both externally and on this forum.  
The general pattern for a complex operation like this is:

1. Do it all through scripting, so you have control over order of operations and flow.
2. At the beginning of your script, while you're still on the EDT, show your "loading" indicator.
3. Launch an asynchronous script (`system.util.invokeAsynchronous`) so you're moved off the EDT.
4. Every time you want to indicate progress, including the final completion, move _back_ to the EDT by calling `system.util.invokeLater` from your async thread.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [January 11, 2023, 4:35pm UTC](https://forum.inductiveautomation.com/t/loading-like-symbol-in-vision/68489/3 "2023-01-11T16:35:51Z")

</div>

> [@paul-griffith](#):
>
> The only "off the shelf" component to display a "loading" message is the progress bar

No, the EasyChart has a "Loading" indicator that you can enable.

> [@Dharani\_T](#):
>
> Any suggestions?

Further to Paul's suggestions, you might find this topic helpful (old but still valid):

> [@Update GUI via Asynchronous thread](https://forum.inductiveautomation.com/t/update-gui-via-asynchronous-thread/9666):
>
> I’ve got a script I am experimenting with that can take a lot of time to execute, so I now use the system.util.invokeAsynchronous to run the script in a separate thread to keep the GUI from locking up. I am using the asynchronous thread to copy files from one place to another, and I would like to show the progress of the file copy with a progress bar. How would I go about this? I am importing a few python libraries to do this. import shutil def fileTransfer(): path = system.file.openFile() …

---

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [January 11, 2023, 4:39pm UTC](https://forum.inductiveautomation.com/t/loading-like-symbol-in-vision/68489/4 "2023-01-11T16:39:09Z")

</div>

What is loading, a dataset(s)? I use something like this (only works because I know each dataset MUST have more than one row) to let me know when some data is loading for a window

```auto
len({Root Container.purchaseOrderData})>0
&&
len({Root Container.projectData})>0
&&
len({Root Container.locationChoices})>0
&&
len({Root Container.initialData})>0

```

as an expression. Then bind this to some visibility of a loading image/gif or progress bar or whatever you are trying to show while things load.

Alternatively if its a table, there is a `.propertiesLoading`, that is helpful as well. I've used that before to turn on a "Loading..." image based on if it is true or false.

---

<div class="post-metadata">

**Author:** ![Dharani\_T](https://avatars.discourse-cdn.com/v4/letter/d/bc8723/32.png) [@Dharani\_T](https://forum.inductiveautomation.com/u/Dharani_T)\
**Post date:** [February 21, 2023, 10:00am UTC](https://forum.inductiveautomation.com/t/loading-like-symbol-in-vision/68489/5 "2023-02-21T10:00:55Z")

</div>

But i would like to display a symbol like below,

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/b/5b069633bd7fe09f61059b80d00ba7ebea44153c.png)  
What i am trying to do here?:  
I have created a template with the shapes and timer with below script:

```auto
vTimer = event.source.value

from java.awt import Color
if (vTimer % 2) == 0:
	event.source.parent.getComponent('Tick marks').getComponent('Group_Tick_Mark_Major').getComponent('Path').fillPaint = Color.BLACK
	event.source.parent.getComponent('Tick marks').getComponent('Group_Tick_Mark_Major').getComponent('Path 1').fillPaint = Color.BLACK
	event.source.parent.getComponent('Tick marks').getComponent('Group_Tick_Mark_Major').getComponent('Path 2').fillPaint = Color.BLACK
	event.source.parent.getComponent('Tick marks').getComponent('Group_Tick_Mark_Major').getComponent('Path 3').fillPaint = Color.BLACK
	event.source.parent.getComponent('Tick marks').getComponent('Group_Tick_Mark_Minor').getComponent('Path').fillPaint =Color.BLACK
	event.source.parent.getComponent('Tick marks').getComponent('Group_Tick_Mark_Minor').getComponent('Path 1').fillPaint =Color.BLACK
	event.source.parent.getComponent('Tick marks').getComponent('Group_Tick_Mark_Minor').getComponent('Path 2').fillPaint =Color.BLACK
	event.source.parent.getComponent('Tick marks').getComponent('Group_Tick_Mark_Minor').getComponent('Path 3').fillPaint =Color.BLACK
else:
	event.source.parent.getComponent('Tick marks').getComponent('Group_Tick_Mark_Major').getComponent('Path').fillPaint = Color.WHITE
	event.source.parent.getComponent('Tick marks').getComponent('Group_Tick_Mark_Major').getComponent('Path 1').fillPaint = Color.WHITE
	event.source.parent.getComponent('Tick marks').getComponent('Group_Tick_Mark_Major').getComponent('Path 2').fillPaint = Color.WHITE
	event.source.parent.getComponent('Tick marks').getComponent('Group_Tick_Mark_Major').getComponent('Path 3').fillPaint = Color.WHITE
	event.source.parent.getComponent('Tick marks').getComponent('Group_Tick_Mark_Minor').getComponent('Path').fillPaint =Color.WHITE
	event.source.parent.getComponent('Tick marks').getComponent('Group_Tick_Mark_Minor').getComponent('Path 1').fillPaint =Color.WHITE
	event.source.parent.getComponent('Tick marks').getComponent('Group_Tick_Mark_Minor').getComponent('Path 2').fillPaint =Color.WHITE
	event.source.parent.getComponent('Tick marks').getComponent('Group_Tick_Mark_Minor').getComponent('Path 3').fillPaint =Color.WHITE

```

Running status of timer has been binded to a vision client tag.  
So whenever u hit on load button , this symbol will be displayed by enabling the vision tag,  
But this symbol should go off only when after the data to table has been loaded.  
I have tried the same functionality with a label , but it is not displaying as expected, even tried the same with indeterminate progress bar.  
Any ideas to achieve this

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [February 21, 2023, 10:40am UTC](https://forum.inductiveautomation.com/t/loading-like-symbol-in-vision/68489/6 "2023-02-21T10:40:28Z")

</div>

During the "loading" process, is the gui locked? What exactly is being loaded, and how is it being called?

---

<div class="post-metadata">

**Author:** ![Dharani\_T](https://avatars.discourse-cdn.com/v4/letter/d/bc8723/32.png) [@Dharani\_T](https://forum.inductiveautomation.com/u/Dharani_T)\
**Post date:** [February 21, 2023, 10:45am UTC](https://forum.inductiveautomation.com/t/loading-like-symbol-in-vision/68489/7 "2023-02-21T10:45:16Z")

</div>

Below is the code i have used in load button

```auto
event.source.parent.parent.getComponent('Load').visible = True
system.tag.writeBlocking("[client]Load",[1])
event.source.parent.parent.stDate =event.source.parent.getComponent('StartDate_dropdown').date
event.source.parent.parent.endDate =event.source.parent.getComponent('EndDate_dropdown').date

vData=event.source.parent.parent.getComponent('Overall_Loss_Time_Table').data
vProcessArea = event.source.parent.parent.Process
vStartDate = event.source.parent.getComponent('StartDate_dropdown').date
vEndDate =event.source.parent.getComponent('EndDate_dropdown').date
vEqId = event.source.parent.parent.MachineNo
vMinutes = event.source.parent.getComponent('Filter_Dropdown').selectedValue
vShift =event.source.parent.getComponent('Shift_dropdown').selectedStringValue
vState=event.source.parent.getComponent('State_Dropdown').selectedStringValue

params = {"iProcessArea":vProcessArea,"iState":vState, "SDate":vStartDate, "EDate":vEndDate , "iEqId":vEqId,"iMinute":vMinutes,"iShift":vShift}
dataSet = system.db.runNamedQuery("MachineBoard/getLossTime", params)

#bind data set to table
#event.source.parent.parent.getComponent('Table').data= dataSet
event.source.parent.parent.getComponent('Overall_Loss_Time_Table').data= dataSet
event.source.parent.parent.getComponent('Load').visible = False
system.tag.writeBlocking("[client]Load",[0])

```

---

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [February 21, 2023, 1:12pm UTC](https://forum.inductiveautomation.com/t/loading-like-symbol-in-vision/68489/8 "2023-02-21T13:12:24Z")

</div>

Yea I would not do it like this. It looks like you are just supplying components from your filters to the parameters of a named query - which is a good start.

However, then you are just assigning it to a table data property.

Why not

1. Bind your table data property to your named query and bind the parameters to your various component values? Then you won't have to manually script this (and imo it is better to bind over script where possible and this is certainly one of those times).
2. Your table should have a `.propertiesLoading` property. Bind your loading GIF visibility to property to `Root Container.table.propertiesLoading` or whatever the path may be - therefore if your data is in the process of being built, your loading symbol appears.
3. You can also bind your table visibility to `!{Root Container.table.propertiesLoading}` if you want - therefore only either your loading GIF or your table will be viewable, but not both at the same time.
