Python PyGTK. What's this component?
I'm trying to write a simple GTD-style todo list app with python and gtk to learn python. I want a container that can select an individual list from a lot of choices. It would be something like the list of notebooks area in tomboy. Not a combobox.
As you can probably tell I'm a beginner and the 开发者_JS百科terminology is probably off.
Can you please tell me what it is I'm looking for and an overview of how to implement it?
It sounds like you just want a listbox, unless you're describing something more complex than I'm picturing.
Wikipedia has a list of GUI widgets that you may find informative.
You mean a widget to filter a large collection into multiple subsets / views?
I would guess you have to implement this yourself - a list of options on the left and filtered results on the right, I don't know of any existing (gtk) widgets.
The 'Notebooks' button in Tomboy is a gtk.MenuToolItem
with a gtk.Menu
containing gtk.RadioMenuItem
s.
Here is a short example:
import gtk
window = gtk.Window()
box = gtk.VBox()
toolbar = gtk.Toolbar()
toolbutton = gtk.MenuToolButton(gtk.STOCK_FLOPPY)
menu = gtk.Menu()
labels = ['Disk 1', 'Disk 2', 'Disk 3']
items = [gtk.RadioMenuItem(label=l) for l in labels]
window.set_default_size(300, 300)
window.add(box)
box.pack_start(toolbar, expand=False, fill=True)
toolbar.insert(toolbutton, 0)
toolbutton.set_menu(menu)
for item in items:
if item is not items[0]:
item.set_group(items[0])
item.show()
menu.append(item)
window.show_all()
window.connect('destroy', gtk.main_quit)
gtk.main()
精彩评论