blob: 407120db51faae508ee0cba2bee073a674ecaecf (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# A simple gtk.Conatiner subclassing example reimplementing gtk.Bin in python
import pygtk
pygtk.require('2.0')
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)
|