/usr/share/doc/python-gtk2-tutorial/html/examples/comboboxwrap.py is in python-gtk2-tutorial 2.4-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 35 36 37 38 39 | #!/usr/bin/env python
import pygtk
pygtk.require('2.0')
import gtk
class ComboBoxWrapExample:
def __init__(self):
window = gtk.Window()
window.connect('destroy', lambda w: gtk.main_quit())
combobox = gtk.ComboBox()
liststore = gtk.ListStore(str)
cell = gtk.CellRendererText()
combobox.pack_start(cell)
combobox.add_attribute(cell, 'text', 0)
window.add(combobox)
combobox.set_wrap_width(5)
for n in range(50):
liststore.append(['Item %d'%n])
combobox.set_model(liststore)
combobox.connect('changed', self.changed_cb)
combobox.set_active(0)
window.show_all()
return
def changed_cb(self, combobox):
model = combobox.get_model()
index = combobox.get_active()
if index > -1:
print model[index][0], 'selected'
return
def main():
gtk.main()
return
if __name__ == "__main__":
bcb = ComboBoxWrapExample()
main()
|