source | issues

pygtkhelpers.utils

Utilities for handling some of the wonders of PyGTK.

gproperty and gsignal are mostly taken from kiwi.utils

copyright:2005-2008 by pygtkhelpers Authors
license:LGPL 2 or later (see README/COPYING/LICENSE)
class pygtkhelpers.utils.GObjectUserDataProxy(widget)

Proxy the GObject data interface to attribute-based access

Parameters:widget – The widget for which to provide attribute access
>>> import gtk
>>> from pygtkhelpers.utils import GObjectUserDataProxy
>>> w = gtk.Label()
>>> data = GObjectUserDataProxy(w)
>>> data.foo = 123
>>> data.foo
123
>>> w.get_data('foo')
123
>>> w.set_data('goo', 456)
>>> data.goo
456
pygtkhelpers.utils.gproperty(name, ptype, default=None, nick='', blurb='', flags=3, **kwargs)

Add a GObject property to the current object.

Parameters:
  • name – name of property
  • ptype – type of property
  • default – default value
  • nick – short description
  • blurb – long description
  • flags – parameter flags, a combination of: - PARAM_READABLE - PARAM_READWRITE - PARAM_WRITABLE - PARAM_CONSTRUCT - PARAM_CONSTRUCT_ONLY - PARAM_LAX_VALIDATION

Optional, only for int, float, long types:

Parameters:minimum – minimum allowed value
Param :maximum: maximum allowed value
pygtkhelpers.utils.gsignal(name, *args, **kwargs)

Add a GObject signal to the current object.

It current supports the following types:
  • str, int, float, long, object, enum
Parameters:
  • name – name of the signal
  • args – types for signal parameters, if the first one is a string ‘override’, the signal will be overridden and must therefor exists in the parent GObject.

Note

flags: A combination of;

  • gobject.SIGNAL_RUN_FIRST
  • gobject.SIGNAL_RUN_LAST
  • gobject.SIGNAL_RUN_CLEANUP
  • gobject.SIGNAL_NO_RECURSE
  • gobject.SIGNAL_DETAILED
  • gobject.SIGNAL_ACTION
  • gobject.SIGNAL_NO_HOOKS
pygtkhelpers.utils.refresh_gui(delay=0.0001, wait=0.0001)

Use up all the events waiting to be run

Parameters:
  • delay – Time to wait before using events
  • wait – Time to wait between iterations of events

This function will block until all pending events are emitted. This is useful in testing to ensure signals and other asynchronous functionality is required to take place.

pygtkhelpers.utils.run_in_window(target, on_destroy=<built-in function main_quit>)

Run a widget, or a delegate in a Window