Tony Nelson schrieb:
At 8:36 AM +0200 10/20/06, N. Volbers wrote:
Hello everyone,
I am using a notebook for a sort of tabbed interface a la Firefox.
Currently, there is a close button for each tab, positioned in the tab
widget. However, I would like to have just a single close button at the
very right of the notebook (again, just like Firefox does). Is there a
way to add a widget inside the notebook tab box?
I use something like this:
class NotebookTabLabel(gtk.HBox):
'''Notebook tab label with close button.
'''
def __init__(self, on_close, owner_):
gtk.HBox.__init__(self, False, 0)
label = self.label = gtk.Label()
label.set_alignment(0.0, 0.5)
self.pack_start(label)
label.show()
close_image = gtk.image_new_from_stock(gtk.STOCK_CLOSE, gtk.ICON_SIZE_MENU)
image_w, image_h = gtk.icon_size_lookup(gtk.ICON_SIZE_MENU)
close_btn = gtk.Button()
close_btn.set_relief(gtk.RELIEF_NONE)
close_btn.connect('clicked', on_close, owner_)
close_btn.set_size_request(image_w+2, image_h+2)
close_btn.add(close_image)
self.pack_start(close_btn, False, False)
close_btn.show_all()
self.show()
tl = NotebookTabLabel(
lambda *args: self.owner.on_tab_close_doc(*args),
self )
I hacked this down from something fancier, but I think it's still all there.
Thanks for your reply!
The example you provide is very useful, even though it is not exactly
what I had in mind. I was looking for a single close button that belongs
to the notebook, and not a button for each tab. Yet your solution works
well for me, so unless someone suggests something different, I will use
your approach.
Best regards,
Niklas.
_______________________________________________
pygtk mailing list [email protected]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/