Dual Window behavior issue

So I have a script that works 100% of the time on the main screen but where systems with multiple monitors are involved the second monitor only opens the window I want but doesn’t set the list box indices the way I want them.. except when I have my debug message box running. I’ve swapped out using screen info for a client tag with the index I want thinking that was it and I tried a lot of things to no avail. Here is a screen shot. Thank you in advance, i have circled my little debug box.

def onDoubleClick(self, rowIndex, colIndex, colName, value, event):
    wlist = system.gui.getOpenedWindows()
    for w in wlist:
        system.gui.messageBox(str(w), "Derp")


    if rowIndex != -1:
        # Get the dataset from the table
        data = self.data
        # Get the value from the first column (index 0) of the clicked row
        value = data.getValueAt(rowIndex, 0)
        #Write this number to the list box on the drum inspection screen since its a list of drum starting at 1 and the index starts at zero the value needs to be -1
        system.tag.writeBlocking('[client]ScadaNavigation/DrumSelectLime', value)
        system.nav.openWindowInstance("Popup windows/Loft/DrumInspectionScreen")
        targetwindow = system.gui.getWindow("Popup windows/Loft/DrumInspectionScreen")
        drumno = targetwindow.getComponentForPath('Root Container.lbo_Drums')
        ds = system.tag.readBlocking('[client]ScadaNavigation/DrumSelectLime')
        drumno.selectedIndex = int(ds[0].value)-1

system.nav.openWindowInstance returns a reference to the newly opened window, use that reference instead of calling system.gui.getWindow, like such:

targetWindow = system.nav.openWindowInstance("Popup windows/Loft/DrumInspectionScreen")

Additionally, don't write to and then read from the same tag in the same script. Use variables to store temporary data, that's what they do. The assignment to drumno.selectedIndex can be simplified to drumno.selectedIndex = value - 1, and the call to system.tag.readBlocking can be removed.

Overall your code can be simplified to the following (with more descriptive names for the variables):

def onDoubleClick(self, rowIndex, colIndex, value, event):
	if rowIndex == -1:
		return

	tableData = self.data
	firstColValue = tableData.getValueAt(rowIndex, 0)
	system.tag.writeAsync(["[client]ScadaNavigation/DrumSelectLime"], [firstColValue])
	newPopup = system.nav.openWindowInstance("Popup windows/Loft/DrumInspectionScreen")
	drumNoComponent = newPopup.getComponentForPath("Root Container.lbo_Drums")
	drumNoComponent.selectedIndex = firstColValue - 1

Side note: Pictures are great for context, but post code as preformatted text. It makes it easier for others to parse and allows copy/paste instead of trying to decipher a picture. Please see Wiki - how to post code on this forum. You can edit your post by clicking the pencil icon in the bottom right.

EDIT: Added cleaned code, corrected selectedIndex assignment example

Actually, if you are going through the effort of opening a new window instance, why not pass the selected drum number to the new window instance via parameters? e.g.

system.nav.openWindowInstance(
	"Popup windows/Loft/DrumInspectionScreen", {"selectedDrum": value-1}
)

From there, bind your list box's selectedIndex to that parameter on the window.

This would simplify your code further to just

def onDoubleClick(self, rowIndex, colIndex, value, event):
	if rowIndex == -1:
		return

	# Grab Table data
	tableData = self.data
	# Grab value of first column in selected row
	firstColValue = tableData.getValueAt(rowIndex, 0)
	system.tag.writeAsync(["[client]ScadaNavigation/DrumSelectLime"], [firstColValue])
	system.nav.openWindowInstance(
		"Popup windows/Loft/DrumInspectionScreen", {"selectedDrum": firstColValue -1 }
	)

Thank you for your reply. I’m still new to ignition but have some familiarity with python 3 working backwards. I’ve tried your suggestions and there are some issues but its probably because I was too brief in my description. I have a main screen which is a drum status screen which has a table on it.

The idea is, id select from this and get the first column and it would populate the box here.

I havent tried the parameter yet because I didnt know I could do that.. but I like it.

The issue I have had is when I tried your suggestions a few things happened.
First I got rid of the getwindow line in lieu of keeping the WindowInstance line thinking that in my general fatigue I must be getting redundant but while this opens the window without both lines of code on the main screen it doesn’t select the drum clicked on the other page. To have it open and to select the drum I want it seems to require that I have both lines of code right now.

Next I tried the reading and writing on the same script and using a variable. I already had a variable so I used that and I didnt need all that extra, I was over thinking it, thank you.

I commented out my code block to try the one you did. Unfortunately, while there were no errors, nothing happened. I like the way it looks though and this is a good exercise for me so I’ll see what I can do with it.

Lastly, when I ran my edited code with everything I could make work, the secondary screen for the dual monitor set up only fully works when I have my screen noting message box running It will open the window but not select the right drum . I used this for the Main screen to make sure my docks are showing up right.
Thank you again for your help so far, I’ll continue working through this and am happy for any feedback.

Based on your description, this is the correct approach to this problem.

Ah, capitalization issue, I used Popup Windows where you are using Popup windows

1 Like

I found the issue. Yes that was it.

Also, if you haven't already, take a look at Inductive University, it has a lot of free videos that cover the basics of using and designing in Ignition

The user manual is also a good resource to crawl through

1 Like

Thank you again,

I might have missed something I went through and made the custom property for “selectedDrum” I bound it to the selected Index property. When I run it the screen doesnt recognize that it is there. Did I put it in the wrong place?

Check capitalization/spelling of the custom property, and ensure that the custom property is on the root container of the DrumInspectionScreen. Also make sure that you have saved the project after all these changes.

That was it . I put it on the listbox and not the root container. Thank you