Custom Parameters from a table

Hi guys

I’m trying to add custom parameters to a container, I was wondering if it is possible to add a menu parameter that gets all the menuNames and menuLabels automatically from a table. I was trying with the menuSource field but I can only get the parameters from another OP… I know I can watch the table and add parameters when the table changes but I don’t know if there is an easier and more direct way to do that.

Thanks in advance!

I think what you’re after is here:

viewtopic.php?f=17&t=8502&p=32243&hilit=menu+from+table#p32243

Thanks!, that’s exactly what I was looking for :slight_smile:

How would I delete a menu item (Name, Label) from a menu after it has been created using menuSource ?

What I wanted to do was create a new menu based on the serial port menu, deleting some entries that wouldn’t be needed in the new menu. Here is the code (thanks Greg !):

# get serial port menu names and labels
menuNamesSource = serial.par.port.menuNames
menuLabelsSource = serial.par.port.menuLabels
		
# create new menu
menuNames = []
menuLabels = []

for i in range(0, len(menuNamesSource)) :
		
	# if 'SLAB' or 'Dig' string is found in the names
	if ('SLAB' in menuNamesSource[i] or 'Dig' in menuNamesSource[i]) :
			
		# add these names and labels to the new menu
		menuNames.append(menuNamesSource[i])
		menuLabels.append(menuLabelsSource[i])
		
# store new menu as iCube port menu custom parameter
parent().par.Port.menuNames = menuNames
parent().par.Port.menuLabels = menuLabels

How is this going nowadays? It would be indeed be amazing to have a table with row or collumn header being menuNames and menuLabels and be able to use it as the menu source on the custom parameter page.

The link mr Ragan pointed to is broken so I cant really find a solution to create a custompar menu from a table :frowning:

Thanks!

Found it on this post

Using tdu module solved the issue

tdu.TableMenu(op('table1')) # use the first column of table1 as a list of menu names and labels
tdu.TableMenu(op('table2'), nameCol='names', labelCol='labels') # from table2, use the column labeled 'names' as menu names, and the column labeled 'labels' as menu names
tdu.TableMenu(op('table3'), labelCol=1, includeFirstRow=True) # from table3, use the first column as menu names and the second column as menu labels. Include the first row of the table in those lists