Skip to content

Commit 1ffd68d

Browse files
promotion table drop as MenuSource
1 parent 8f24eff commit 1ffd68d

File tree

4 files changed

+29
-1
lines changed

4 files changed

+29
-1
lines changed
440 Bytes
Binary file not shown.
24 Bytes
Binary file not shown.
-16 Bytes
Binary file not shown.

scripts/CustomParPromoter/customParPromoterExt.py

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,34 @@ def OnCustomizeCallback(self, info):
350350
self.PromotePar(par, None, parName=nameEntry, parLabel=labelEntry, parMin=minEntry, parMax=maxEntry, clamp=chekcboxClamp, parDefault=default)
351351

352352

353-
353+
def SetTableMenu(self, _table, _target):
354+
_page = self._getTargetPage(None, _target, None)
355+
_target.currentPage = _page
356+
table_name = _table.name.replace('_', '').title()
357+
par_name = self.parNameCheck(table_name)
358+
new_par = _page.appendMenu(par_name, replace=False)
359+
360+
# Check first row for label and name columns
361+
label_col = -1
362+
name_col = -1
363+
if _table.numRows > 0 and _table.numCols > 0:
364+
for col in range(_table.numCols):
365+
header = str(_table[0, col]).lower()
366+
if 'label' in header:
367+
label_col = col
368+
elif 'name' in header:
369+
name_col = col
370+
371+
if _table.numCols > 1 and (name_col != -1 or label_col != -1):
372+
# Use the found label column if available, otherwise default to 1
373+
name_col = name_col if name_col != -1 else 0
374+
label_col = label_col if label_col != -1 else 1
375+
expression = f'tdu.TableMenu({TDF.getShortcutPath(_target, _table)}, nameCol={name_col}, labelCol={label_col}, includeFirstRow=False)'
376+
else:
377+
if _table.numCols > 1:
378+
expression = f'tdu.TableMenu({TDF.getShortcutPath(_target, _table)}, nameCol=0, labelCol=1, includeFirstRow=True)'
379+
elif _table.numCols == 1:
380+
expression = f'tdu.TableMenu({TDF.getShortcutPath(_target, _table)}, includeFirstRow=True)'
381+
new_par.menuSource = expression
354382

355383

0 commit comments

Comments
 (0)