Hi

The only way I managed to do this was by placing Buttons in the tags. Attached is a simple example.

Hope this helps.

Regards

Paul Malherbe

+27 (0) 21 6711866
+27 (0) 82 9005260



Frédéric wrote:
Le 3/12/2008, "Paul Malherbe" <[EMAIL PROTECTED]> a écrit:

  
What exactly do you mean by 'disable all other pages' ?
Do you mean disable the tags or the pages.
    

I don't want the user to switch to other pages of the notebook.

--
   Frédéric

  
import gtk

class NoteBook:
    def __init__(self, tags):
        self.tags = tags
        self.mstFrame = gtk.VBox()
        # Create a new notebook and disable tags
        self.nb = gtk.Notebook()
        self.nb.set_tab_pos(gtk.POS_TOP)
        self.nb.unset_flags(gtk.CAN_FOCUS)
        self.nb.connect("button-press-event", lambda wid, ret=True: ret)
        self.mstFrame.pack_start(self.nb, False, False, 0)
        #=======================================================================
        # Append pages to the notebook
        #=======================================================================
        for num, tag in enumerate(self.tags):
            # Create buton for notebook tag
            but = gtk.Button(tag)
            but.connect("clicked", self.chgPage, num)
            # Create alignment
            alw = gtk.Alignment(0.5, 0.5, 0, 0)
            alw.set_padding(0, 0, 5, 5)
            # Create vbox
            vbx = gtk.VBox(False, 0)
            vbx.set_size_request(300, 200)
            alw.add(vbx)
            # Add alignment and vbox to notebook
            self.nb.append_page(alw, tab_label=but)
            # rename widgets for future access
            exec "self.nb.Tag%s = but" % num
            exec "self.nb.Page%s = vbx" % (num + 1)

    def chgPage(self, *args):
        wid, num = args
        if num != self.nb.get_current_page():
            wid.emit_stop_by_name("clicked")
            self.nb.set_current_page(num)
        for x in range(len(self.tags)):
            self.disableTag(x)

    def disableTag(self, num):
        exec "self.nb.Tag%s.set_sensitive(False)" % num

    def enableTag(self, num):
        exec "self.nb.Tag%s.set_sensitive(True)" % num

if __name__ == "__main__":
    win = gtk.Window()
    nb = NoteBook(("One", "Two", "Three"))
    win.add(nb.mstFrame)
    win.show_all()
    gtk.main()
_______________________________________________
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/

Reply via email to