Sophie

Sophie

distrib > Mandriva > 2008.1 > x86_64 > media > main-release > by-pkgid > 990acead62a7de528a3123eb93239584 > files > 108

pygtk2.0-demos-2.12.1-1mdv2008.1.x86_64.rpm

# A simple gtk.Conatiner subclassing example reimplementing gtk.Bin in python
import gtk

class Bin(gtk.Container):
    __gtype_name__ = 'PyGtkBin'
    def __init__(self):
        gtk.Container.__init__(self)
        self.child = None

    def do_add(self, child):
        child.set_parent(self)
        self.child = child

    def do_remove(self, child):
        widget_was_visible = child.flags() & gtk.VISIBLE
        child.unparent()
        self.child = None

        if widget_was_visible:
            self.queue_resize()

    def do_forall(self, internal, callback, data):
        if self.child:
            callback(self.child, data)

label = gtk.Label()
c = Bin()
c.add(label)
print c.get_children()
c.remove(label)