How To: Apply an icon to a button using Avenue


This article explains how to set the icon for a new button. An icon can be any size, but the IconMgr shows only those that are less than 24x24 pixels by default. The script below opens an Icon manager that displays icons of all sizes.


  1. Open a new script window

    A. Activate the Project window.
    B. Click the Scripts icon.
    C. Click New.

  2. Paste the following code into the new script window:

    '-- Create a button and prompt the user to choose an icon for it
    newButton = Button.Make
    newButton.SetIcon(IconMgr.Show(0)) '<-- IconMgr.ShowWithDefault can be used as well

    av.GetActiveGUI.GetButtonBar.Add(newButton, -1)

    Refer to ArcView Help for more information on the class IconMgr and the requests ShowWithDefault or Show.

  3. Replace the text "Script" with the name of the scripts you would like to attach to the button.
  4. Select Compile from the Script menu or click the
    [O-Image] Script compile button
  5. Click the
    [O-Image] Run compiled script button
    button to run the script.

Last Published: 5/5/2016

Article ID: 000003997