What I'm trying to do is damn simple but it seems like Mathematica is extremely ill-designed for this ...
Here is a very simplified form of my code to show the basic idea. I have a variable number of tabs, depending on a dynamically set value, it already took me hours to find something that works :
Dynamic[TabView[
Table[
iTabIndex,
{iTabIndex, iTabCount}
],
Dynamic[iSelectedTab]
]]
where iTabCount is dynamically controlled by a slider in another part of the GUI. Now I want to have the content of each tab to contain dynamic controls (of course) over different parameters for each tab while sharing the same UI layout, but it just won't work ...
Dynamic[TabView[
Table[
Slider[ Dynamic[ someTable[[iTabIndex]] ], ... ],
{iTabIndex, Count}
],
Dynamic[iSelectedTab]
]]
===> Syntax error, iTabIndex is not connected anymore to the Table enumeration parameter when enclosed in Dynamic[] ... I NEED that Dynamic, otherwise controls nested in each tabs are pointless !
I tried working around by inserting a module (amongst other things) :
BuildTabUI[iTabIndex_] := (Dynamic)Module[
{},
Return[
Slider[ Dynamic[ someTable[[iTabIndex]] ], ... ]
]
];
Dynamic[TabView[
Table[
BuildTabUI[iTabIndex],
{iTabIndex, Count}
],
Dynamic[iSelectedTab]
]]
Which does avoid the syntax error, but the slider is now unresponsive, despite the Dynamic enclosures inside BuildTabUI !
This would take seconds to code in C++ for any decent GUI engine ... how such a simple task can be so over-complicated ?
Can anyone please help me and give me a proper method to do this in a clean, efficient and generic way ? Thanks a lot in advance !
PS : Don't go easy on me with the technical details, I'm new to Mathematica but I'm an extremely experienced C++ programmer ... ;)
@JM, Test example :
param1 = param2 = param3 = 1;
iSelectedTab = 1;
iTabCount = 1;
someTable = { param1, param2, param3 };
Slider[ Dynamic[iTabCount], {1,3,1} ]
Dynamic[TabView[
Table[
Slider[ Dynamic[ someTable[[iTabIndex]] ], {1,5} ],
{iTabIndex, iTabCount}
],
Dynamic[iSelectedTab]
]]
I expect a tabview of 1-3 tabs, depending on first slider, each containing a nested slider controlling param1, param2, param3 ... Hope this is straightforward enough ... Thank you for your attention !
Dynamic[TabView[ Table[Slider[Dynamic[someTable[[#]]], {1, 5}] &@ iTabIndex, {iTabIndex, iTabCount}], Dynamic[iSelectedTab]]]
$\endgroup$