Open additional instance of view(popup) in perspective

How do I open additional instance of view(popup) in perspective? Like additional instance in vision.

You can open as many instances as you need, as long as each one has a unique id supplied.

Pseudo-code:

for i in range(4):
    system.perspective.openPopup(id=i, title='Popup #{0}',format(i))

Should open four popups. They’ll all be on top of each other since I’ve not provided differing open locations, but if you drag the top one, you’ll see another beneath it.

The problem of this solution is I can’t track the id number I used before. For example I create embedded view of pump with popup. each time the user click on each pump the popup will open and I have to assign unique id to each ooened popup.
I wish this handle in perspective like vision In vision I just click multi instance option and vision keep track of assign id.

You can very easily provide the id of the popup to the View as a parameter.

for i in range(4):
    system.perspective.openPopup(id=i, title='Popup #{0}',format(i),params={'id':i})

Doing this allows the Popup itself to track its id, so that you can also allow for closing the popup from within the popup.

To set up a Popup close action, for example:

  1. In the View used for the Popup, create a new property: View.params.id
  2. Place some button in the View.
  3. Provide anew onClick event for the button which invokes a Popup Action which will close a Popup, and bind the id attribute of this action to View.params.id.

From your use-case, it sounds like each pump should have its own unique identifier already ie: “pump_A”, “pump_B”. So the specific pump should be able to supply whatever unique identifier was used to create the Embedded View as an id for the Popup.

my_pump_id = self.view.params.pump_id
system.perspective.openPopup(id=my_pump_id, params={'id':my_pump_id})
1 Like

I just use the TagPath for the tag in template.

set the Identifier to {view.params.TagPath}

Can have as many popup as i want and no need for script.

1 Like

I don’t understand the reasoning behind passing the id as a parameter, I was under the impression that using the syntax provided in the user manual would assign it a unique ID:

`# Opens a popup view. We are passing in two parameters, called "myParam" and "myParam2". We also set some additional properties of the popup.`

`system.perspective.openPopup(` `"myPopupId"` `,` `'folder/myView'` `, params ` `=`   `{` `'myParam'` `:` `1` `,` `'myParam2'` `:` `'Test'` `}, showCloseIcon ` `=`   `False` `, resizable ` `=`   `True` `)`

I’ve noticed when I try to open two different popups, one from within the other, it closes my first popup.
They have unique IDs:

#First Popup Opening:
tagsToTrend = 'sometagPath'
system.perspective.openPopup(id = "north_douglas_tanks",view ='Compressors/North Douglas Tanks',params={'tagsToTrend':tagsToTrend}, resizable = True, draggable = True)'

#Second popup Opening within the first, both with unique IDs:
tagList = 'someArray'
if len(tagList) == 0:
	tagList = self.view.custom.tagsToTrend
	system.perspective.openPopup(id = "CompTrend",view ='Trending/trendView',params={'tagList':tagList}, resizable = True, draggable = True, showCloseIcon=False)
else:
	tagList = self.view.custom.tagsToTrend
	system.perspective.closePopup(id = "CompTrend")
	system.perspective.openPopup(id = "CompTrend", view ='Trending/trendView',params={'tagList':tagList}, resizable = True, draggable = True, showCloseIcon=False)

I know in my script there is a closepopup command depending on the size of the array I’m passing into it. But, the popup with the ID ‘north_douglas_tanks’ should not be closing even if that condition is met correct?

Also, what does perspective do when you call for a popup to be closed when there is no popup with that ID? Could that somehow be causing it to close my first popup?

Thanks

Yes. It closes any random other popup. This was recently fixed, IIRC.

This is true, but you are not supplied with the ID, so when this thread was initially opened you could not target the popup you just opened with future closePopup invocations (what would you supply for the id argument?).

I just tested this on a nightly build because that should not be happening, and I did not encounter the issue even while the popups were created as modals.

This screenshot contains two popups - one of which was opened from within a different popup.

THIS is the crux of your problem. Before the upcoming 8.0.13 release, if Perspective could not locate a Popup with a specified id, it would close the most recently focused Popup. This was undesirable, and so we fixed the behavior. I verified it’s working as expected in the nightly build. if you take this nightly you should no longer encounter this behavior with one exception: id arguments supplied with empty strings.

We’re aware some users would prefer to just close any open Popup without wanting to track the id, so

system.perspective.closePopup(id='')

will close the most recently focused popup in 8.0.13.

Thank you.