gtk.Object
Prev | The gtk Class Reference | Next

## gtk.Object

gtk.Object — the base class of the PyGTK type hierarchy.

## Synopsis

    class gtk.Object(gobject.GObject):
        def flags()
        def set_flags(flags)
        def unset_flags(flags)
        def destroy()

    Functions

        def gtk.bindings_activate(object, keyval, modifiers)
        def gtk.bindings_activate_event(object, event)
        def gtk.binding_entry_add_signal(object, keyval, modifiers, signal_name, ...)
        def gtk.binding_entry_remove(class_type, keyval, modifiers)

## Ancestry

    +-- gobject.GObject
      +-- gtk.Object

## gtk.Object Properties

"user-data" | Read-Write | Anonymous User Data Pointer

## gtk.Object Signal Prototypes

gobject.GObject Signal Prototypes

"destroy" | `def callback(`object`, `user_param1`, `...`)`

## Description

`gtk.Object` is the base class for all widgets, and for a few non-widget objects such as `gtk.Adjustment`. `gtk.Object` predates `GObject`; non-widgets that derive from `gtk.Object` rather than `GObject` do so for backward compatibility reasons.

The "destroy" signal, emitted by the `destroy`() method asks all code owning a GTK reference to the object to release its GTK reference. So, for example, if you call `window.destroy`() where `window` is a `gtk.Window`, GTK will release the GTK reference count that it owns; if you call `button.destroy`() where button is a `gtk.Button`, `button` will be removed from its parent container and the parent container will release its GTK reference to `button`. Because these GTK references are released, calling `destroy`() should result in freeing all memory associated with an object (finalizing it) if the GTK reference count reaches zero. However, in PyGTK the GTK objects are wrapped in a Python object that has its own reference counting mechanism. The `destroy`() method does not affect the Python reference counts. The GTK object associated with a Python object will not be released until the Python object reference count reaches zero. Therefore, calling the `destroy`() method will not result in the finalization of the GTK object until the Python object is finalized. In the case mentioned above if a `gtk.Button` is destroyed using the `destroy`() method, it will be removed from its container and unmapped and unrealized but it will not be finalized because the Python wrapper object will still exist and hold a reference.

## Methods

### gtk.Object.flags

        def flags()

Returns : | the flags set for the object

The `flags`() method returns the value of the flags for the object. The flags returned will include both the `gtk.Object` flags and the `gtk.Widget` flags.

The `gtk.Object` flags are:

`gtk.IN_DESTRUCTION` | the object is currently being destroyed.
`gtk.FLOATING` | the object is orphaned.
`gtk.RESERVED_1` | reserved for future use
`gtk.RESERVED_2` | reserved for future use

The `gtk.Widget` flags are:

`gtk.TOPLEVEL` | widgets without a real parent (e.g. `gtk.Window` and `gtk.Menu`) have this flag set throughout their lifetime. Toplevel widgets always contain their own `gtk.gdk.Window`.
`gtk.NO_WINDOW` | a widget that does not provide its own `gtk.gdk.Window`. Visible action (e.g. drawing) is performed on the parent's `gtk.gdk.Window`.
`gtk.REALIZED` | the widget has an associated `gtk.gdk.Window`.
`gtk.MAPPED` | the widget can be displayed on the screen.
`gtk.VISIBLE` | the widget will be mapped as soon as its parent is mapped.
`gtk.SENSITIVE` | The sensitivity of a widget determines whether it will receive certain events (e.g. button or key presses). One requirement for the widget's sensitivity is to have this flag set.
`gtk.PARENT_SENSITIVE` | This is the second requirement for the widget's sensitivity. Once a widget has `gtk.SENSITIVE` and `gtk.PARENT_SENSITIVE set`, its state is effectively sensitive.
`gtk.CAN_FOCUS` | the widget is able to handle focus grabs.
`gtk.HAS_FOCUS` | the widget has the focus - assumes that `gtk.CAN_FOCUS` is set
`gtk.CAN_DEFAULT` | the widget is allowed to receive the default action.
`gtk.HAS_DEFAULT` | the widget currently will receive the default action.
`gtk.HAS_GRAB` | the widget is in the grab_widgets stack, and will be the preferred one for receiving events.
`gtk.RC_STYLE` | the widgets style has been looked up through the RC mechanism. It does not imply that the widget actually had a style defined through the RC mechanism.
`gtk.COMPOSITE_CHILD` | the widget is a composite child of its parent.
`gtk.NO_REPARENT` | unused
`gtk.APP_PAINTABLE` | set on widgets whose window the application directly draws on, in order to keep GTK from overwriting the drawn stuff.
`gtk.RECEIVES_DEFAULT` | the widget when focused will receive the default action and have `gtk.HAS_DEFAULT` set even if there is a different widget set as default.
`gtk.DOUBLE_BUFFERED` | exposes done on the widget should be double-buffered.

### gtk.Object.set_flags

        def set_flags(flags)

`flags` : | the `gtk.Object` and `gtk.Widget` flags to be set on this object

The `set_flags`() method sets the object flags according to the value of `flags`. See `flags`() for a description of the `gtk.Object` and `gtk.Widget` flags that can be set.

### gtk.Object.unset_flags

        def unset_flags(flags)

`flags` : | the `gtk.Object` and `gtk.Widget` flags to be unset on this object

The `unset_flags`() method unsets the object flags according to the value of `flags`. See `flags`() for a description of the `gtk.Object` and `gtk.Widget` flags that can be unset.

### gtk.Object.destroy

        def destroy()

The `destroy`() method emits the "destroy" signal notifying all reference holders that they should release the `gtk.Object`.

## Functions

### gtk.bindings_activate

        def gtk.bindings_activate(object, keyval, modifiers)

`object` : | the `gtk.Object` to activate the bindings on
`keyval` : | a key value
`modifiers` : | a modifier mask
`` : |
Returns : | `True` if the binding could be activated

The `gtk.bindings_activate`() function activates the bindings associated with the `gtk.Object` specified by object with the key value specified by `keyval` and the modifier mask specified by `modifiers`.

### gtk.bindings_activate_event

        def gtk.bindings_activate_event(object, event)

`object` : | the `gtk.Object` to activate the bindings on
`event` : | a `gtk.gdk.Event`
Returns : | `True` if a matching key binding was found

The `gtk.bindings_activate_event`() function looks up key bindings for the `gtk.Object` specified by `object` to find one matching the key `gtk.gdk.Event` specified by `event`, and if one was found, activate it.

### gtk.binding_entry_add_signal

        def gtk.binding_entry_add_signal(object, keyval, modifiers, signal_name, ...)

`object` : | the `gtk.Object` class the binding entry will be associated with
`keyval` : | the key value
`modifiers` : | the modifier mask
`signal_name` : | the signal name
`...` : | zero or more pairs of value type-value pairs

The `gtk.binding_entry_add_signal`() function adds a binding (specified by `keyval` and `modifiers`) to the binding set of the object class derived from `object`. The signal specified by `signal_name` will be emitted with the optional arguments specified by the argument pairs denoted by ... that are value type and value. This function is used when creating a new widget class to set up key bindings.

### gtk.binding_entry_remove

        def gtk.binding_entry_remove(class_type, keyval, modifiers)

`class_type` : | the `gtk.Object` class the binding entry will be removed from
`keyval` : | the key value
`modifiers` : | the modifier mask

### Note

This function is available in PyGTK 2.2 and above.

The `gtk.binding_entry_remove`() function removes the binding (specified by `keyval` and `modifiers`) from the binding set of the object class specified by `class_type`.

## Signals

### The "destroy" gtk.Object Signal

        def callback(object, user_param1, ...)

`object` : | the object that received the signal
`user_param1` : | the first user parameter (if any) specified with the `connect`() method
`...` : | additional user parameters (if any)

The "destroy" signal is emitted when the references for the object should be destroyed.

Prev | Up | Next
gtk.Notebook | Home | gtk.OptionMenu