Column-specific listbox list wave

Hi, I have a listbox in a GUI that holds the names of waves. The waves in the listbox are the ones I am currently performing routines/analysis on. I want to display the names of the waves in the list box without their full paths, but I need the full paths available somewhere so that I can perform routines on the waves in the list box. Right now, my solution is to have two different waves, one just with wave names and the other with their full paths. These waves get updated and changed pretty dynamically, so when one wave changes I have to remember to always make identical changes in the other wave.

Ideally I'd like to instead have a 2D wave (one column with names, the other with the full path), but only display one of the columns in the list box. Is there any syntax that would make this type of thing possible? The code below is my main attempt, where myListWave is a 2 column text wave, but it doesn't work. 

ListBox matchListBox win=NT,listWave=myListWave[][0],selWave=mySelWave

I also tried using a 2D wave to hold the names and paths, but then tethering the column with the wave names to a 1D wave that will be used in the list box.

Make/T/N=(10,2) listWave_2D
Make/T/N=10 listWave_1D

listWave_1D := listWave_2D[p][0]

ListBox matchListBox win=NT,listWave=listWave_1D,selWave=mySelWave

This actually works, but the problem is that listWave_2D gets redimensioned all the time, and the slave 1D wave doesn't actually mirror the dimensions, only the content. Any other suggestions? 

I have something similar, and I also work with two waves: A wave reference wave and a separate text wave for the listbox.

The wave reference wave is the master and all changes are done in that wave. I then have an update function which updates the listbox, graph, buttons and other stuff which might need updating every time the user makes a change. One of the things this update function does is to recreate the listbox text wave based on the content in the wave reference wave.

I find that working with one universal update function like that is really useful, especially when your procedure becomes more and more complicated. I would also really recommend using wave reference waves instead of full-path text waves.

PS

It the above example you have a selwave as well as a listwave. Are up updating the length of the selwave to match the listwave?

You could use the widths keyword to make the column containing full paths effectively invisible. Here is an example:

make/n=(10,2) selWave
make/n=(10,2)/T listWave
•listWave[][0] = "wave" + num2istr(p)
•listWave[][1] = "root:wave" + num2istr(p)
newpanel
ListBox list0 listWave=listWave, selWave=selWave, widths={100,0}, size={175,75}

 

Another approach would be to use a 3D listWave. As far as I am aware, the ListBox control only uses the data in the first layer of the wave, so you could store the full paths in layer 1. Here is an example:

make/n=(10,2) selWave
make/n=(10,1, 2)/T listWave
•listWave[][0][0] = "wave" + num2istr(p)
•listWave[][0][1] = "root:wave" + num2istr(p)
newpanel
ListBox list0 listWave=listWave, selWave=selWave, size={175,75}

Yet another approach would be to use SetFormula to create the dependency. We usually suggest that if you think you need to use a dependency, you think again, since future you will hate past you for having used a dependency. Here is an example of how you could do this:

make/N=(10,1)/O/T listWave
Make/N=(10,1)/O selWave
NewPanel
ListBox list0 listWave=listWave, selWave=selWave, size={175,75}
make aaa, bbb, ccc
•waveRefWave[0]=aaa; waveRefWave[1]=bbb; waveRefWave[2]=ccc
SetFormula root:listWave, "UpdateListWave(root:waveRefWave, p)"
// Note that the ListBox now contains only 3 entries, "aaa", "bbb", and "ccc"
// Now execute these statements
make ddd
•waveRefWave[3]=ddd
// The ListBox now shows "ddd" as well

There is at least one potential issue with this approach. For example, after executing the block above, execute:

Rename ccc, oldccc

You might expect that the ListBox now shows oldccc, but it doesn't. It still shows ccc. This is because the wave reference wave root:waveRefWave did not change as a result of the Rename command, since it is still storing the same wave reference.

Hi, I'm more or less Mr. Listbox these days... The 3D wave is the approach I use, as in aclight's second example. That technique has the advantage of using just one wave to hold the wave names, and avoids pesky dependencies. A listbox uses just the rows and columns and ignores any layer past layer 0. I'm not sure that's documented, but since it would break my procedures, it's never going away!

Thanks for the advice everyone, using the 3D wave is working great! Should make the code a fair bit cleaner.