I want to use an expression binding on the dataset of a tab strip. Why is the tab data not exposed to the expression binding editor?
I'm trying to get the "tab index" for the selected tab. Any thoughts?
I want to use an expression binding on the dataset of a tab strip. Why is the tab data not exposed to the expression binding editor?
I'm trying to get the "tab index" for the selected tab. Any thoughts?
Add a custom property to your tab strip called 'selectedTabIndex.'
Then, use a propertyChange script to set the index any time a different tab is selected. You could then bind anything you want to the custom property.
The script would look something like this:
# Made for the propertyChange event handler of the tab strip
# Only fire the script if the selected tab property changes
if event.propertyName == 'selectedTab':
#Retrieve the tabData dataset
tabData = event.source.tabData
# Iterate through the dataset to look for the matching tab
for row in range(tabData.rowCount):
# Define the selected index property as the row in the dataset where the newly selected tab is found
if event.newValue == tabData.getValueAt(row, 0):
event.source.selectedTabIndex = row
break
I'm using a couple different tab strips and showing/hiding them conditionally.
Would adding an "or visible" to the property change script work?
I'm not sure what this means. Are you toggling the bool for the hidden
column on some of the tabs?
The visible property for the entire tab strip
If you need to trigger something off of a visibility property change, it will be this:
if event.propertyName == 'visible':
...but if you are simply trying to show or hide a tab strip when a certain tab is selected, then you could do it all from the propertyChange script. That script would look more like this:
# Only fire the script if the selected tab property changes
if event.propertyName == 'selectedTab':
if event.newValue == 'tabName':
# Toggle visibility off using the tab strip's visible property
else:
# Toggle visibility on using the tab strip's visible property