[pygtk] adding a close button to a notebook
Tony Nelson
tonynelson at georgeanelson.com
Fri Oct 20 21:28:33 WST 2006
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.
--
____________________________________________________________________
TonyN.:' The Great Writ <mailto:tonynelson at georgeanelson.com>
' is no more. <http://www.georgeanelson.com/>
More information about the pygtk
mailing list