I fiddled with your test program and added a list of ColorWdigets to the StyleBox instance - this seemed to fix things but I don't know exactly why. It's a hack but may be a workaround.
John
Ava Arachne Jarvis wrote:
I'm using python 2.2 and pygtk 1.99.14, gtk 2.2.0 and friends.
I'm running across an odd problem when I use a large number of widgets,
and some of them are ones that inherit from original gtk widgets. When
first created, these objects seem intact; however, the first time a
signal callback is called, the objects' attribute dictionaries are
empty.
I'm attaching a version of the program that I stripped down to about 50
lines. Instruction for running this:
python stripped.py <num of ColorWidgets>
#!/usr/bin/python import pygtk pygtk.require('2.0') import gtk, sys, string
class ColorWidget(gtk.Button): def __init__(self, stylebox): gtk.Button.__init__(self) self.stylebox = stylebox self.color = gtk.gdk.color_parse('white') self.set_size_request(30, 30) self.connect("clicked", self.setColor) def setBackground(self, gdkcolor = None): if gdkcolor: self.color = gdkcolor for state in [gtk.STATE_ACTIVE, gtk.STATE_NORMAL, gtk.STATE_PRELIGHT, gtk.STATE_SELECTED]: self.modify_bg(state, self.color) def setColor(self, w): print '__dict__:', self.__dict__ self.setBackground(self.stylebox.getColor(self.color)) class StyleBox(gtk.Window): def __init__(self, numwidgets = 10): gtk.Window.__init__(self) self.connect("destroy", lambda w: gtk.main_quit()) self.widgets = [] self.cdg = gtk.ColorSelectionDialog('Select Color') self.notebook = gtk.Notebook() self.notebook.set_show_tabs(0) self.add(self.notebook) for i in range(0, numwidgets): self.createTestPanel() def getColor(self, prev_color = None): if prev_color: self.cdg.colorsel.set_current_color(prev_color) color = None if self.cdg.run() == gtk.RESPONSE_OK: color = self.cdg.colorsel.get_current_color() self.cdg.hide() return color def createTestPanel(self): panel = gtk.Frame() self.notebook.append_page(panel, gtk.Label('Test')) w = ColorWidget(self) self.widgets.append(w) panel.add(w) s = StyleBox(string.atoi(sys.argv[1])) s.show_all() gtk.main()