Hello
Does anyone know how to limit the number of tabs in a notebook, much like gedit
does?
Here is a minimal example. Run it, and keep hitting the '+' button, and the
window just keeps growing to keep up with the number of tabs.
Cheers
Peyman Askari
#!/usr/bin/env python
import sys
try:
import pygtk
pygtk.require("2.0")
except:
pass
try:
import gtk
import gtk.glade
except:
sys.exit(1)
import gtksourceview
window=gtk.Window()
def make_notebook():
global topology_blocked
global window
window.connect('destroy',on_main_window_destroy)
window.connect('delete_event',on_main_window_delete_event)
vBox=gtk.VBox()
button=gtk.Button('+')
notebook=gtk.Notebook()
notebook.set_tab_pos(gtk.POS_TOP)
button.connect('clicked',add_tab,notebook)
vBox.pack_start(notebook,expand=True,fill=True,padding=5)
vBox.pack_start(button,expand=False,fill=False,padding=0)
window.add(vBox)
window.show_all()
def add_tab(button,notebook):
label=gtk.Label('Hola')
vBox=gtk.VBox()
notebook.append_page(vBox,label)
label.show()
vBox.show()
def on_main_window_delete_event(widget,data=None):
"""Return false so the window gets destroyed
"""
return False
def on_main_window_destroy(widget,data=None):
"""Return false so the window gets destroyed
"""
gtk.main_quit()
if __name__ == '__main__':
try:
make_notebook()
gtk.main()
except KeyboardInterrupt:
sys.exit(1)_______________________________________________
pygtk mailing list [email protected]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/