gtk.gdk.Atom
Prev | The gtk.gdk Class Reference | Next

## gtk.gdk.Atom

gtk.gdk.Atom — an object representing an interned string

## Synopsis

    class gtk.gdk.Atom:
        gtk.gdk.atom_intern(name, only_if_exists=False)

## Description

`gtk.gdk.Atom` is a `PyGTK` class that wraps the `GTK`+ GdkAtom - an unsigned integer representing an interned string. An interned string is a string that has an internal `GTK`+ mapping between an atom and a string. `gtk.gdk.Atom` has no methods. A copy of the interned string can be retrieved by using the Python `str()` function. gtk.gdk.atom_intern() will return a `gtk.gdk.Atom` referencing an existing interned string but will intern a string if it isn't already interned.

`gtk.gdk.Atom` objects are used to provide the targets for `gtk.SelectionData` objects that are used by `gtk.Clipboard` and `gtk.TreeView`, objects and for drag and drop (see `gtk.gdk.DragContext`, `gtk.gdk.Window` and `gtk.TreeDragSource` and `gtk.Widget` for more information). The advantage of the interned string is that it is easy to pass between processes and even systems since only an integer value is passed.

`PyGTK` 2.4 has a number of pre-defined atoms that map to builtin `GTK+` interned string atoms. The interned strings and the `PyGTK` 2.4 `gtk.gdk.Atom` objects are:

"PRIMARY" | `gtk.gdk.SELECTION_PRIMARY`
"SECONDARY" | `gtk.gdk.SELECTION_SECONDARY`
"CLIPBOARD" | `gtk.gdk.SELECTION_CLIPBOARD`
"ATOM" | `gtk.gdk.SELECTION_TYPE_ATOM`
"BITMAP" | `gtk.gdk.TARGET_BITMAP` or `gtk.gdk.SELECTION_TYPE_BITMAP`
"COLORMAP" | `gtk.gdk.TARGET_COLORMAP` or `gtk.gdk.SELECTION_TYPE_COLORMAP`
"DRAWABLE" | `gtk.gdk.TARGET_DRAWABLE` or `gtk.gdk.SELECTION_TYPE_DRAWABLE`
"PIXMAP" | `gtk.gdk.TARGET_PIXMAP` or `gtk.gdk.SELECTION_TYPE_PIXMAP`
"STRING" | `gtk.gdk.TARGET_STRING` or `gtk.gdk.SELECTION_TYPE_STRING`
"WINDOW" | `gtk.gdk.SELECTION_TYPE_WINDOW`

Also in `PyGTK` 2.4, comparison between a string and a `gtk.gdk.Atom` is supported.

## Constructor

        gtk.gdk.atom_intern(name, only_if_exists=False)

`name` : | the string to be interned or retrieved
`only_if_exists` : | this value is ignored
Returns : | a new `gtk.gdk.Atom` or `None`

Creates a `gtk.gdk.Atom` referencing the interned string specified by `name`. An interned string is a string that has a `GTK`+ mapping to an unsigned integer value. This constructor will intern the string and create a `gtk.gdk.Atom` if it does not already exist. `only_if_exists` is ignored and essentially is always `False`.

Prev | Up | Next
The gtk.gdk Class Reference | Home | gtk.gdk.CairoContext