[wxPython-dev] 2.7's properties and class definition order

Paul McNett p at ulmcnett.com
Fri Nov 17 23:51:17 PST 2006


Paul McNett wrote:
> Robin Dunn wrote:
>> Paul McNett wrote:
>>
>>> Robin, if you could just assure me that there isn't a reason to name
>>> the wx class first in the class definition, then I have no problem
>>> going through all our class definitions and swapping the order to put
>>> the wx class last.
>>
>> I think it should be okay.
> 
> Hi Robin,
> 
> We at Dabo are running into problems with reordering the class 
> definitions. To recap the problem, we used to define our dabo classes like:
> 
> class dForm(wx.Frame, dPemMixin):
> 
> This worked great, until wx2.7's addition of properties, when wx's 
> property definitions started overwriting dabo's. IOW, if dabo defined 
> Font = property(...), wx's Font property completely overwrites Dabo's. 
> The quick fix was to reorder the definition like:
> 
> class dForm(dPemMixin, wx.Frame):
> 
> However, now we are running into problems with Destroy(). Here's a 
> traceback. This is with wxPython 2.6.3.3. Any help would be appreciated!
> 
> Traceback (most recent call last):
>   File 
> "/usr/lib/python2.4/site-packages/wx-2.6-gtk2-unicode/wx/_core.py", line 
> 13535, in <lambda>
>     lambda event: event.callable(*event.args, **event.kw) )
>   File "montana.py", line 584, in startGame
>     self.gameBoard.newGame()
>   File "montana.py", line 145, in newGame
>     self.createSizer()
>   File "montana.py", line 124, in createSizer
>     self.gridSizer.release()
>   File 
> "/home/pmcnett/projects/dabo-full/branches/wx2.7/dabo/ui/uiwx/dSizerMixin.py", 
> line 259, in release
>     self.Destroy()
>   File 
> "/usr/lib/python2.4/site-packages/wx-2.6-gtk2-unicode/wx/_core.py", line 
> 707, in Destroy
>     return _core_.Object_Destroy(*args, **kwargs)
> TypeError: __class__ assignment: 'dGridSizer' object layout differs from 
> '_wxPyDeadObject'
> 
> ...and with wxPython2.7.2 I get a segfault when starting my Dabo app. 
> Any ideas?

Okay, if I override Destroy() in my mixin class like so:

	def Destroy(self, *args, **kwargs):
		# wxPython 2.7 bug workaround:
		try:
			super(dPemMixin, self).Destroy(*args, **kwargs)
		except TypeError:
			pass

It appears the object does get destroyed by the time the TypeError is 
raised. Can this be a workaround for now or are things not being 
properly cleaned up?

-- 
pkm ~ http://paulmcnett.com





More information about the wxpython-dev mailing list