| ICONS - Examples | ![]() |
||||||
|
| A Simple Example |
It is best to use a simple example to demonstrate the usage of the ICONS package:
# Request the ICONS package and import the "icons" command.
package require icons 1.0
namespace import icons::icons
# Use the "icons" command to create two icons "actreload16" and "navhome16".
# As no icon library file has been specified it is assumed that the required
# file is called "tkIcons" in the directory given by the "info library" command.
icons create {actreload16 navhome16}
# Create two buttons with the previously created icons.
# NOTE: When the icon images are created the names are prefixed with "::icon::".
button .b1 -relief flat -image ::icon::actreload16
button .b2 -relief flat -image ::icon::navhome16
# Pack the buttons into the window. The "-padx" options are simply to create a
# gap between the buttons.
pack .b1 -padx 2 -side left
pack .b2 -padx 2 -side left
The above script will create the following:
| Using Create |
Some examples using the ICONS create mode:
icons create {actreload16 navhome16}
Create images for the two specified icons (As in above "Simple Example") using the
default library.
icons create -file tkIcons.ikons {actreload16 navhome16}
Create images for the two specified icons using the "tkIcons.ikons" library
in the directory given by the "info library" command.
icons create -file /home/mydir/myIcons {myicon1 myicon2}
Create images for the two specified icons using the "/home/mydir/myIcons" library.
icons create -group edit
Create images for all icons belonging to the "edit" group using the default library.
icons create -group {edit file}
Create images for all icons belonging to the "edit" and "file" groups
using the default library.
icons create -group {edit file} {actreload16 navhome16}
Create images for all icons belonging to the "edit" and "file" groups
and the two specified icons using the default library.
icons create -file tkIcons.ikons -group {edit file}
Create images for all icons belonging to the "edit" and "file" groups
using the "tkIcons.ikons" library in the directory given by the "info
library" command.
icons create -group *
Create images for all icons in the default library.
| Using Delete |
An example using the ICONS delete mode:
icons delete {actreload16 navhome16}
Delete images for the two specified icons.
| Using Query |
Some examples using the ICONS query mode:
icons query {actreload16 navhome16}
Return default information for the two specified icons...
{actreload16 action photo 16x16} {navhome16 nav photo 16x16}
icons query -file tkIcons.ikons {actreload16 navhome16}
Return default information for the two specified icons using the "tkIcons.ikons" library
in the directory given by the "info library" command...
{actreload16 action photo 17x17} {navhome16 nav photo 16x16}
icons query -group connect
Return default information for all icons belonging to the "connect" group using the default library...
{connecting16 connect photo 16x16} {connectno16 connect photo 16x16} {connectyes16 connect photo 16x16}
icons query -group connect -items ns
Return name and size information for all icons belonging to the "connect" group using the default library...
{connecting16 16x16} {connectno16 16x16} {connectyes16 16x16}
NOTE: The default information is: ngts (name group type size)