Changing the displayed value of a popup item by a call

Recently I am trying to create some interfaces for a few new instruments. 

The panels are mainly separated into two types, 
-instrument panels which talk directly to the hardware
-measurement panels which set up a procedure and execute the measurement

In this case, when a parameter is being set in the measurement panel, e.g. sampling frequency of Digitizer1, the corresponding item on the Digitizer1's instrument panel will be updated with the new sampling frequency, as well as applying the setting to the hardware. This is correctly implemented when a WMSetVariableAction is used, where the box on instrument panel will update. However, when it is a popup item, the popup box display won't change when I perform a WMPopupAction.

Is there a way to make it change when I perform a WMPopupAction elsewhere?

Thanks for the command, however, I tried and it did not update the popup item as expected. This is what I used:

ControlUpdate/W=panelName SampFreqStr

"panelName" is the string of the panel name, and SampFreqStr is the "Name" of the popup menu.

On reading the help file, it seems this commands actually update the popup by changing its underlying list of available popstr. In my case, I am not changing the list of pop string, instead I was trying to make it switch from one to another.

Roughly this is what I am trying to do:

>Set a value in the measurement panel, say SampFreq = 1e6
>It creates a string ("1e6") which matches the second one that is available in the instrument popup string list

"\"0.5e6;1e6;2e6;5e6;10e6;20e6;40e6;50e6;100e6;200e6\""

>The popup value in the instrument panel got updated to 1e6

The problem I have was that in SetVariable the box can be associated with a variable stored somewhere. If that variable is updated I can update the displayed value in the panel. But it seems popup menu doesn't have the same association with a certain string variable.

The only (and possible ugly) method I have now is to destroy the popup box and create a new one with the popstr set to what I want.

I believe that you want to use this approach.

string pvstr = "1e6"
Popupmenu SampFreqStr, window=panelname, popvalue=pystr

 

In reply to by Sandbo

The syntax for ControlUpdate is:

ControlUpdate [/A /W=winName ] [controlName ]

Note that those are names and not strings.

Usage example:
 

String winStr="Panel0"
String SampFreqStr = "sampFreq"
ControlUpdate/W=$winStr $sampFreqStr

 

In reply to by jjweimer

jjweimer wrote:

I believe that you want to use this approach.

string pvstr = "1e6"
Popupmenu SampFreqStr, window=panelname, popvalue=pystr

popMatch is more likely to work:

popmatch=matchStr    Sets mode to the enabled menu item that matches matchStr. matchStr may be a "wildcard" expression. See stringmatch. If no item is matched, mode is unchanged.

And window=panelName isn't right: wiin=panelName is right:

string pvstr = "1e6"
string SampFreqStr= "sampFreq" // assuming the name of the control is "sampFreq"
String panelNameStr= "Panel0" // assming the name of the panel is "Panel0"
Popupmenu $SampFreqStr, win=$panelNameStr, popmatch=pystr

 

In reply to by JimProuty

jjweimer wrote:

I believe that you want to use this approach.

string pvstr = "1e6"
Popupmenu SampFreqStr, window=panelname, popvalue=pystr

 

I also tried this, but strangely it didn't work (not updating the pop menu).
This can work if I added the optional argument mode=2:

string pvstr = "1e6"
Popupmenu SampFreqStr, win=panelname, popvalue=pystr, mode=2

JimProuty wrote:

 

jjweimer wrote:

 

I believe that you want to use this approach.

string pvstr = "1e6"
Popupmenu SampFreqStr, window=panelname, popvalue=pystr

 

 

popMatch is more likely to work:

popmatch=matchStr    Sets mode to the enabled menu item that matches matchStr. matchStr may be a "wildcard" expression. See stringmatch. If no item is matched, mode is unchanged.

And window=panelName isn't right: wiin=panelName is right:

string pvstr = "1e6"
string SampFreqStr= "sampFreq" // assuming the name of the control is "sampFreq"
String panelNameStr= "Panel0" // assming the name of the panel is "Panel0"
Popupmenu $SampFreqStr, win=$panelNameStr, popmatch=pystr

 

Thanks a lot for looking into the issue, the popmatch works and does exactly what I meant! 

I recently fixed a bug in which popMatch didn't update the displayed value. Please get the latest nightly build.