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?
Perhaps your update code needs to run ControlUpdate/W=panelName popupControlName
January 21, 2019 at 04:01 pm - Permalink
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.
January 22, 2019 at 08:31 am - Permalink
I believe that you want to use this approach.
January 22, 2019 at 09:35 am - Permalink
In reply to Thanks for the command,… by Sandbo
The syntax for ControlUpdate is:
ControlUpdate [/A /W=winName ] [controlName ]
Note that those are names and not strings.
Usage example:
String SampFreqStr = "sampFreq"
ControlUpdate/W=$winStr $sampFreqStr
January 22, 2019 at 10:00 am - Permalink
In reply to I believe that you want to… by jjweimer
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 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
January 22, 2019 at 10:04 am - Permalink
In reply to jjweimer wrote: I… by JimProuty
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:
Popupmenu SampFreqStr, win=panelname, popvalue=pystr, mode=2
Thanks a lot for looking into the issue, the popmatch works and does exactly what I meant!
January 22, 2019 at 10:08 am - Permalink
I recently fixed a bug in which popMatch didn't update the displayed value. Please get the latest nightly build.
January 22, 2019 at 10:56 am - Permalink
In reply to I recently fixed a bug in… by johnweeks
In my case the bug didn't seem to kick in, I am using Version: 8.0.2.1 (Build 32405)
The popmatch command works for me.
January 22, 2019 at 12:46 pm - Permalink
Thanks John for the corrections and other recommendations!
January 23, 2019 at 06:24 am - Permalink