HOW TO

Apply an icon to a button using Avenue

Last Published: April 25, 2020

Summary

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.

Procedure



  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:

    Code:
    '-- 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
    newButton.SetClick("Script")
    newButton.SetUpdate("Script")

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


    Note:
    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.

Article ID:000003997

Software:
  • Legacy Products

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options

Discover more on this topic