home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2006 November (DVD) / PCWELT_11_2006.ISO / casper / filesystem.squashfs / usr / share / doc / python-gnome2 / examples / gconf / simple-view.py < prev   
Encoding:
Python Source  |  2004-01-14  |  824 b   |  37 lines

  1. #!/usr/bin/env python
  2. #
  3. # A very simple program that monitors a single key for changes.
  4. #
  5.  
  6. import gtk
  7. import gconf
  8.  
  9. def key_changed_callback (client, cnxn_id, entry, label):
  10.     if not entry.value:
  11.     label.set ('<unset>')
  12.     else:
  13.     if entry.value.type == gconf.VALUE_STRING:
  14.         label.set_text (entry.value.to_string ())
  15.     else:
  16.         label.set ('<wrong type>')
  17.  
  18. client = gconf.client_get_default ()
  19.  
  20. window = gtk.Window ()
  21. window.set_default_size (120, 80)
  22. window.connect ('destroy', lambda w: gtk.mainquit ())
  23.  
  24. s = client.get_string ("/testing/directory/key")
  25.  
  26. label = gtk.Label (s or '<unset>')
  27. window.add (label)
  28.  
  29. client.add_dir ('/testing/directory',
  30.                 gconf.CLIENT_PRELOAD_NONE)
  31.  
  32. client.notify_add ("/testing/directory/key",
  33.                    key_changed_callback, label)
  34.  
  35. window.show_all ()
  36. gtk.main ()
  37.