File: comboboxentrybasic.py

package info (click to toggle)
python-gtk2-tutorial 2.3-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 3,376 kB
  • ctags: 918
  • sloc: python: 5,731; makefile: 36
file content (34 lines) | stat: -rw-r--r-- 914 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env python

import pygtk
pygtk.require('2.0')
import gtk

class ComboBoxEntryExample:
    def __init__(self):
        window = gtk.Window()
        window.connect('destroy', lambda w: gtk.main_quit())
        comboboxentry = gtk.combo_box_entry_new_text()
        window.add(comboboxentry)
        comboboxentry.append_text('Apple')
        comboboxentry.append_text('Cherry')
        comboboxentry.append_text('Blueberry')
        comboboxentry.append_text('Grape')
        comboboxentry.append_text('Peach')
        comboboxentry.append_text('Raisin')
        comboboxentry.child.connect('changed', self.changed_cb)
        comboboxentry.set_active(0)
        window.show_all()
        return

    def changed_cb(self, entry):
        print 'I like', entry.get_text(), 'pie'
        return

def main():
    gtk.main()
    return

if __name__ == "__main__":
    bcb = ComboBoxEntryExample()
    main()