AttributeError: can't set attribute

I don't see my error despite looking and looking. Fresh eyes will probably
spot it at once.

   Two wx.TextCtrl() widgets defined in an init method for a class (line
numbers added by me):

584 nameLab = wx.StaticText(self, wx.ID_ANY, 'Set Name: ')
585 self.fsName = wx.TextCtrl(self, wx.ID_ANY, size=wx.Size(125, 25),
586 style=wx.TAB_TRAVERSAL|wx.RAISED_BORDER)
587 588 parLab = wx.StaticText(self, wx.ID_ANY, 'Parent Variable: ')
589 self.Parent = wx.TextCtrl(self, wx.ID_ANY, size=wx.Size(125, 25),
590 style=wx.TAB_TRAVERSAL|wx.RAISED_BORDER)

   When this method is called, python displays the following error message:

Traceback (most recent call last):
   File "/data1/eikos/fuzSetPage.py", line 454, in OnAdd
     newSet = setDlg()
   File "/data1/eikos/fuzSetPage.py", line 590, in __init__
     style=wx.TAB_TRAVERSAL|wx.RAISED_BORDER)
AttributeError: can't set attribute

   The error is not generated at line 586, but is at line 590. I can see no
difference in the syntax of the two assignments, and those styles are
accepted on other wx.TextCtrl widgets throughout the application.

Rich

···

--
Richard B. Shepard, Ph.D. | The Environmental Permitting
Applied Ecosystem Services, Inc. | Accelerators(TM)
<http://www.appl-ecosys.com> Voice: 503-667-4517 Fax: 503-667-8863

Found it: it was naming the widget 'Parent.' I thought that might be an
issue, and had changed it to 'fsParent' without seeing a difference. But,
changing the name to 'fsPar' fixed the problem. Interesting.

Rich

···

On Wed, 26 Sep 2007, Rich Shepard wrote:

I don't see my error despite looking and looking. Fresh eyes will probably
spot it at once.

--
Richard B. Shepard, Ph.D. | The Environmental Permitting
Applied Ecosystem Services, Inc. | Accelerators(TM)
<http://www.appl-ecosys.com> Voice: 503-667-4517 Fax: 503-667-8863

Rich Shepard wrote:

···

On Wed, 26 Sep 2007, Rich Shepard wrote:

I don't see my error despite looking and looking. Fresh eyes will probably
spot it at once.

  Found it: it was naming the widget 'Parent.' I thought that might be an
issue, and had changed it to 'fsParent' without seeing a difference. But,
changing the name to 'fsPar' fixed the problem. Interesting.

Parent is a Python property that maps to the GetParent getter method. Since there is not a setter given to the property it gives you that exception. There is no fsParent property so you may have done something like forgetting to save the file when you tested that change.

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Parent is a Python property that maps to the GetParent getter method.

Robin,

   I did not realize that the property began with an uppercase 'P' and
thought there might be a reserved word, 'parent.'

Since there is not a setter given to the property it gives you that
exception.

   That's what finally sunk in. The name was reserved for something other
than what I wanted. So a change was in order.

There is no fsParent property so you may have done something like
forgetting to save the file when you tested that change.

   That was my first thought, but emacs told me otherwise. Regardless,
changing it to fsPar conflicts with nothing. Another good lesson.

Thanks for the explanation,

Rich

···

On Wed, 26 Sep 2007, Robin Dunn wrote:

--
Richard B. Shepard, Ph.D. | The Environmental Permitting
Applied Ecosystem Services, Inc. | Accelerators(TM)
<http://www.appl-ecosys.com> Voice: 503-667-4517 Fax: 503-667-8863