Add to dynamic menu...

A command in the File menu of the ScriptEditor.

With this command, you add a button to the dynamic menu in the Objects window. This button will only be visible if the specified combination of objects is selected. Clicking the button will invoke the specified Praat script.


Class 1
the name of the class of the object to be selected. For instance, if a button should only appear if the user selects a Sound, this would be “Sound”.
Number 1
the number of objects of class1 that have to be selected. For most built-in commands, this number is unspecified (0); e.g., the user can choose Draw... or To Spectrum regardless of whether she selected 1, 2, 3, or more Sound objects. If the number of selected objects is different from number1, the button will be visible but insensitive.
Class 2
the name of the class of the second object to be selected, different from class1. Normally the empty string (“”).
Number 2
the number of selected objects of class2.
Class 3
the name of the class of the third object to be selected, different from class1 and class2. Normally the empty string (“”).
Number 3
the number of selected objects of class3.
the title of the new command button (or label, or submenu title). To get a separator line instead of a command text (only in a submenu), you specify a unique string that starts with a hyphen (“-”); the ButtonEditor may contain some examples of this. If the command starts with Save as or Append to, it will be placed in the Save menu.
After command
a button title in the dynamic menu or submenu where you want your new button. If you specify the empty string (“”), your button will be put at the bottom. You can specify a push button, a label (subheader), or a cascade button (submenu title) here.
0 if you want your button in the main menu, 1 if you want it in a submenu.
the full path name of the script to invoke. If you saved the script you are editing, its name will already have been filled in here. If you do not specify a script, you will get a separating label or cascading menu title instead, depending on the depth of the following command.


If one object of class Sound is selected, you want a new submenu called “Filters” after the Convolve button, containing your new commands “Autocorrelation” and “Band filter...”, separated by a horizontal separator line:

    Add to dynamic menu: "Sound", 0, "", 0, "", 0, "Filters -",
    ... "Convolve", 0, ""
    Add to dynamic menu: "Sound", 1, "", 0, "", 0, "Autocorrelation",
    ... "Filters -", 1, "/u/praats/demo/autocorrelation.praat"
    Add to dynamic menu: "Sound", 0, "", 0, "", 0, "-- band filter --",
    ... "Autocorrelation", 1, ""
    Add to dynamic menu: "Sound", 1, "", 0, "", 0, "Band filter...",
    ... "-- band filter --", 1, "/u/praats/demo/bandFilter.praat"

Note that “Filters -” will be a submenu title, because it is followed by subcommands (depth 1). Note that number1 is 1 only for the executable buttons; for the cascade button and the separator line, this number is ignored.

Usage convention

Please adhere to the convention that command that take arguments, such as “Band filter...” above, end in three dots.

Using this command in a script

To add a dynamic button from a script (perhaps your initialization script or a plug-in), use the hidden shell command Add action command... instead.

Links to this page

© Paul Boersma 1998,2006,2011,2014,2023