On Wed, 2006-11-22 at 19:02 +0100, Marcin Lewandowski wrote:
> Hi,
> 
> I've created an Assistant. When I try to execute the following code:
<snip code>
> i get error:
> 
> Gtk-ERROR **: file gtkassistant.c: line 414 (compute_last_button_state):
> assertion failed: (page_info)
> aborting...
<snip>
> It's a bug, isn't it?

It sure is, only, it's located in your code ;)

There's a couple of thing wrong with it. For example you're
trying to add a gtk.Window subclass (gtk.Assistant) to another
gtk.Window. Why?

Anyway, the assertion you get is because the last page you add to
the assistant is not of the type gtk.ASSISTANT_PAGE_CONFIRM or
gtk.ASSISTANT_PAGE_SUMMARY. See the Note in the pygtk reference:
http://pygtk.org/docs/pygtk/gtk-constants.html#gtk-assistant-page-type-constants

I have attached an example that works.

HTH,
Dieter
#!/bin/env python

import gtk

class FunkyAssistant(gtk.Assistant):
    def __init__(self):
        gtk.Assistant.__init__(self)

        self.connect('delete_event', self.cb_on_delete)
        self.connect('close', self.cb_close)

        # Construct page 0
        vbox = gtk.VBox(False, 5)
        vbox.set_border_width(5)
        vbox.show()
        self.append_page(vbox)
        self.set_page_title(vbox, 'Page 0: Howto do absolutely nothing useful')
        self.set_page_type(vbox, gtk.ASSISTANT_PAGE_CONTENT)

        label = gtk.Label("Press the Execute button below to simulate some work. This enables the Forward button when done...")
        label.set_line_wrap(True)
        label.show()
        vbox.pack_start(label, True, True, 0)

        button = gtk.Button(stock=gtk.STOCK_EXECUTE)
        button.connect('clicked', self.cb_do_something)
        button.show()
        vbox.pack_end(button)

        # Construct page 1
        # As this is the last page needs to be of page_type
        # gtk.ASSISTANT_PAGE_CONFIRM or gtk.ASSISTANT_PAGE_SUMMARY
        label = gtk.Label('Thanks for using FunkyAssistant!')
        label.set_line_wrap(True)
        label.show()
        self.append_page(label)
        self.set_page_title(label, 'Page 1: byebye')
        self.set_page_type(label, gtk.ASSISTANT_PAGE_SUMMARY)

        self.show()

    def cb_on_delete(self, widget, event):
        gtk.main_quit()

    def cb_do_something(self, button):
        self.set_page_complete(button.get_parent(), True)

    def cb_close(self, assistant):
        self.emit('delete_event', gtk.gdk.Event(gtk.gdk.NOTHING))

if __name__ == '__main__':
    win = FunkyAssistant()
    win.show()
    gtk.main()

Attachment: signature.asc
Description: This is a digitally signed message part

_______________________________________________
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/

Reply via email to