Accessing wx.TextCtrl after refactoring

Rhodri James rhodri at wildebst.demon.co.uk
Sat Mar 28 19:14:07 EDT 2009


On Sat, 28 Mar 2009 13:55:39 -0000, alex <alecla at bluewin.ch> wrote:

> Rhodri
> thank you very much for your answer.
> I had read about setattr but the useage was not completely clear to
> me. Now I will study it again.
> I inserted it in "def createInput1"
>
>
>     def createInput1(self, label, pth_btn_label, txtctrl_path):
>         self.stattxt = wx.StaticText(self, -1, label)
>         self.pth_Btn = wx.Button(self, -1, pth_btn_label)
>         self.txtctrl = wx.TextCtrl(self, -1, "", size=(300, -1))
>         setattr(self, self.txtctrl_path, self.txtctrl)
>
> Unfortunately I get the following error
>
>   File "C:\Temp\Test\pydlg.py", line 22, in box1Labels
>     return (("Input Path:", "Browse", self.BrowseInDlg,
> txtctrl_inpath),
> NameError: global name 'txtctrl_inpath' is not defined

setattr() expects a string for the second parameter (which should be
just txtctrl_path, not self.txtctrl_path, by the way!).  So what
box1Labels needs to return is
  (("Input Path:", "Browse", self.BrowseInDlg, "txtctrl_inpath"), ...

-- 
Rhodri James *-* Wildebeeste Herder to the Masses



More information about the Python-list mailing list