How do I put a scrollbar inside of a gtk.ComboBoxEntry?
-
22-08-2019 - |
Question
I have a Combobox with over a hundred of entries and it is very awkward to skim through with out a scrollbar.
alt text http://img211.imageshack.us/img211/6972/screenshotprubapy.png
I want to do exactly what is in the picture. With the scrollbar on the right so It'd be easier to move through the entries. I used gtk.Combo to make that example but the problem is that is deprecated.
I need an example of how would you do what is exactly the picture.
Solution
import pygtk
import gtk
import gobject
def window_delete_event(*args):
return False
def window_destroy(*args):
gtk.main_quit()
if __name__ == '__main__':
win = gtk.Window()
# combo's model
model = gtk.ListStore(gobject.TYPE_STRING)
for n in xrange(100):
model.append([str(n)])
# combo
combo = gtk.ComboBoxEntry(model)
win.add(combo)
# combo's style
style = gtk.rc_parse_string('''
style "my-style" { GtkComboBox::appears-as-list = 1 }
widget "*.mycombo" style "my-style"
''')
combo.set_name('mycombo')
combo.set_style(style)
win.show_all()
win.connect('delete-event', window_delete_event)
win.connect('destroy', window_destroy)
gtk.main()
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow