Hi Vinay Reddy,
Do you only want a close symbol on the right corner of the tabLabel or
furthermore the capability to close the page of the notebook when it is clicked?
If you want callback also here is the code i use:
Make sure the path for your icon file is correct. (I'm using a relative path
perhaps you will have to complete it.)
import pygtk
pygtk.require('2.0')
import gtk
def add_icon_to_button(self,button,iconFilename):
iconBox = gtk.HBox(False, 0)
image = gtk.Image()
fc=filenameChecker()
image.set_from_file(iconFilename)
image.show()
iconBox.pack_start(image, True, False, 0)
button.add(iconBox)
iconBox.show()
return
def create_custom_tab(self,text):
iconFile = "hmi\\images\\close.xpm"
#create a custom tab for notebook containing a label and a button with
picture on it
eventBox = gtk.EventBox()
tabBox = gtk.HBox(False, 2)
tabLabel = gtk.Label(text)
tabButton=gtk.Button()
tabButton.connect('clicked',self.on_tabButton_clicked)
#Add a picture on a button
self.add_icon_to_button(tabButton,iconFile)
iconBox = gtk.HBox(False, 0)
eventBox.show()
tabButton.show()
tabLabel.show()
tabBox.pack_start(tabLabel, False)
tabBox.pack_start(tabButton, False)
# needed, otherwise even calling show_all on the notebook won't
# make the hbox contents appear.
tabBox.show_all()
eventBox.add(tabBox)
return eventBox
and in your main function, just call it with :
eventBox=create_custom_tab("Hello")
#Add your_widget in the page and eventBox as tabLabel
self.notebook.append_page(your_widget,eventBox)
_______________________________________________
pygtk mailing list [email protected]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/