ocarina/ocarina/tabs.py

32 lines
752 B
Python

# Bryan Schumaker (8/13/2010)
import ocarina
libsaria = ocarina.libsaria
gtk = ocarina.gtk
class Tabs(gtk.Notebook):
def __init__(self):
gtk.Notebook.__init__(self)
self.set_tab_pos(gtk.POS_LEFT)
self.connect("switch-page", self.switch_page)
self.cur_page = 0
self.show()
def append_page(self, content, text):
label = gtk.Label(text)
label.set_angle(90)
gtk.Notebook.append_page(self, content, label)
self.set_tab_label_packing(content, True, True, gtk.PACK_START)
def switch_page(self, notebook, page, page_num):
old = notebook.get_nth_page(self.cur_page)
if hasattr(old, "invisible"):
old.invisible()
new = notebook.get_nth_page(page_num)
if hasattr(new, "visible"):
new.visible()
self.cur_page = page_num