2.7's properties and class definition order

Paul McNett p at ulmcnett.com
Wed Oct 25 13:11:38 PDT 2006


Hi,

It seems that wxPython's properties are trumping Dabo's properties. It seems to come down to the order in which we list the superclasses in our class definitions. If I list wxPython's class last, then the particular problem goes away and Dabo's properties now trump wx's. However, wasn't there a different reason to declare the wxPython class first?

Here's the test code I'm working off of:

#-- begin sample code
import wx

class TestMixin(object):
	def _getTitle(self):
		val = getattr(self, "_title", "")
		print "In _getTitle, self._title=%s" % val

	def _setTitle(self, val):
		self._title = val

	Title = property(_getTitle, _setTitle)

class TestFrame1(wx.Frame, TestMixin): pass
class TestFrame2(TestMixin, wx.Frame): pass

app = wx.App()
frm1 = TestFrame1(None)
frm1.Show()
print 1, frm1.Title
frm1.Title = "pkm"
print 2, frm1.Title
frm2 = TestFrame2(None)
frm2.Show()
print "---"
print 1, frm2.Title
frm2.Title = "pkm"
print 2, frm2.Title
app.MainLoop()
#-- end sample code

Here's my output:
pmcnett at sol:~/projects/dabodemo$ python wxPropTest.py 
1 
2 pkm
---
1 In _getTitle, self._title=
None
2 In _getTitle, self._title=pkm
None

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. 

Thanks!
Paul




More information about the wxpython-dev mailing list