O'Reilly logo

Mastering Perl/Tk by Nancy Walsh, Stephen Lidie

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Atom Methods

Atoms are an X11 concept. They map strings to an integer identifier allocated by the X server. In the context of Tk, each widget is assigned a pathname, which is stored as an atom. The atom has a string name (you can get it for each widget by using the PathName method) and a 32-bit ID. These methods are used internally to handle things such as the selection mechanism.

To get the 32-bit ID for a given widget, send the name of the widget to the atom method:

$id = $widget->atom($widget->PathName);

You can do the opposite and use the ID to get the name of the atom back. To do so, use the atomname method:

$name = $widget->atomname($id);

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required