YourPaste - For your paste! Archive - Tools - Login

Posted by bed on Thu 9 Oct 2008 22:07 835 views - Syntax: Python - Expires: never - Report - IMG - Download -

  1. #!/usr/bin/env python
  2.  
  3. import pygtk
  4. pygtk.require('2.0')
  5. import gtk
  6.  
  7. class ComboBoxExample:
  8.     def __init__(self):
  9.         window = gtk.Window()
  10.         window.connect('destroy', lambda w: gtk.main_quit())
  11.         combobox = gtk.combo_box_new_text()
  12.         window.add(combobox)
  13.         combobox.append_text('Select a pie:')
  14.         combobox.append_text('Apple')
  15.         combobox.append_text('Cherry')
  16.         combobox.append_text('Blueberry')
  17.         combobox.append_text('Grape')
  18.         combobox.append_text('Peach')
  19.         combobox.append_text('Raisin')
  20.         combobox.connect('changed', self.changed_cb)
  21.         combobox.set_active(0)
  22.         window.show_all()
  23.         return
  24.  
  25.     def changed_cb(self, combobox):
  26.         model = combobox.get_model()
  27.         index = combobox.get_active()
  28.         if index:
  29.             print 'I like', model[index][0], 'pie'
  30.         return
  31.  
  32. def main():
  33.     gtk.main()
  34.     return
  35.  
  36. if __name__ == "__main__":
  37.     bcb = ComboBoxExample()
  38.     main()
  39.  

Comments

bed @ 9 Oct 2008 22:23:31

Oh, http ist im Kommentar nicht möglich, aber auch nicht nötig.
Viele Grüße von http://zockertown.de/s9y/

Name:
Comment:

© 2010 YourPaste.net - Disclaimer