typestar

Enabling and disabling in Igor Pro

Every control takes disable, and using it is how a panel explains itself.

Function SyncPanel()
    ControlInfo/W=AnalysisPanel smoothChk
    Variable smoothing = V_value

    Button runBtn, win=AnalysisPanel, disable=(smoothing ? 0 : 2)
    SetVariable thrSet, win=AnalysisPanel, disable=(smoothing ? 0 : 2)

    ControlUpdate/W=AnalysisPanel thrSet
    DoUpdate/W=AnalysisPanel
End

How it works

  1. disable=0 is normal, 1 hides it, 2 grays it out.
  2. Gray out what cannot apply yet rather than letting it fail.
  3. ControlUpdate redraws one control after its backing value changed.

Keywords and builtins used here

The run, in numbers

Lines
10
Characters to type
284
Tokens
55
Three-star pace
90 tpm

At the three-star pace of 90 tokens a minute, this run takes about 37 seconds.

Type this snippet

Step 2 of 5 in Wiring it up, step 14 of 18 in Panels & GUI.

← Previous Next →