[pygtk] emulate Live Bookmarks buttons?

BJörn Lindqvist bjourne at gmail.com
Thu Sep 11 06:26:46 WST 2008


Hello,

2008/9/6 Karl Ostmo <kostmo at gmail.com>:
> I would actually prefer for this button to be part of a gtk.Toolbar, such as
> a gtk.ToolButton.  However, gtk.MenuToolButton does not do what I want; that
> widget has the menu part split into a separate button, as in the "Recent
> pages" next to the Forward and Back buttons in Firefox 3 (Linux version).

You can manually tweak gtk.MenuToolButton to do what you want:

        menu_button = gtk.MenuToolButton(None, None)
        hbox = menu_button.get_child()
        button, toggle_button = hbox.get_children()
        hbox.remove(button)

        img = gtk.image_new_from_stock(gtk.STOCK_DIRECTORY,
                                       gtk.ICON_SIZE_SMALL_TOOLBAR)

        arrow = toggle_button.get_child()
        toggle_button.remove(arrow)
        hbox = gtk.HBox()
        hbox.add(img)
        hbox.add(gtk.Label('hello'))
        hbox.add(arrow)
        toggle_button.add(hbox)

> Trying to pack a gtk.Arrow into a gtk.Button gives unexpected results; the
> arrow always ends up between the label and the icon, even after applying
> "reorder_child(...)".  I am also not sure how to attach the menu to a button

Your code is wrong as you call container.reorder_child(arrow, -1)
before arrow is added to container. To get the arrow last you also
need to pack_end() add it, not pack_start(). Then you calling
container.reorder_child(arrow, -1) should work.


-- 
mvh Björn


More information about the pygtk mailing list