Can TabStrip pass parameter to window?

I have a standard navigation window with the TabStrip on it, working fine.

I now want to add tabs for different production lines on it, e.g.
Line 1
Line 2
Line 3
Line 4
Line 5

However ideally I just want to create a single window for a Line and have a custom
property on it that is the Line Number.

Is there any way for the Tab Strip component to be able to display my common window but pass
the appropriate parameter to it?

Short answer: yes. Long answer: yeeeessssss… Sorry, long day. I’m getting loopy… :mrgreen:

Anyway, here’s a sample project:
[attachment=0]TabbedSingleWindow (2014-05-09).proj[/attachment]

This is a v7.2 project, so in case it doesn’t import for you, here’s an explanation.

I did this by disabling the Navigation Mode on the Tab strip, then putting this property change script instead:

system.nav.swapWindow("Window 1","Window 1",{"LineNumber" : event.source.selectedTab})

swapWindow works just like swapTo, except you can specify what windows to swap, along with parameters. I just swap the same window. :slight_smile:

Try this:

Change your tab strip so its navigationMode is Disabled
Add the following code to the mouseClicked event of the TabStrip
(NOTE: this only works for up to 9 lines)

sWinName = event.source.selectedTab
ds = system.dataset.toPyDataSet(event.source.tabData)

for row in ds:
	if row["NAME"] == sWinName:
		iLineNumber = int(row["DISPLAY_NAME"][-1:])
		#print "system.nav.swapTo(" + sWinName + ", {\"LineNumber\": " + str(iLineNumber) + "})"
		system.nav.swapTo(sWinName, {"LineNumber": iLineNumber})


I just noticed Jordan’s code and realized a flaw in my code.

You want to open the same window, but the Tab Strip Customizer forces the name of the tab to be the window you want to open. When you make all three the same name, my code will not work and it will look like all tabs are pressed. I think the best thing thing to do is include the line number as part of the name and then postfix the number to past through. So if the window to open is LineWindow then each tab name would be: LineWindow1, LineWindow2, LineWindow3… and you would use this code:

sWinName = event.source.selectedTab

iLineNumber = int(sWinName[-1:])
sWinName = sWinName[:-1]
#print "system.nav.swapTo(" + sWinName + ", {\"LineNumber\": " + str(iLineNumber) + "})"
system.nav.swapTo(sWinName, {"LineNumber": iLineNumber})

Thank you both. I will try your suggestions next week.

I did think it might involve changing the navigation mode and putting in the script manually.

Jordan - this might be a silly question but can I ask why you’ve used swapWindow rather than swapTo?

My situation is complicated slightly by the fact that there will be some tabs that will simply go to windows and other tabs that will be Line 1, Line 2, Line 3 etc. I believe I should be able to handle this by looking at the selectedTab property.

My only other issue is if someone switches windows without using the navigation bar (I have an option on a summary screen to double click and it jumps automatically to a detail screen).
By default, the selected tab would now not be correct.

I’m therefore looking at putting something in the internalFrameActivated script on a window to say

system.gui.getWindow("Nav").rootContainer.getComponent("Tab Strip").selectedTab= <<window name>>

Sure! They both work in similar fashion, but swapWindow will let you swap any window, not just the ‘main’ one.