Accessing wx.TextCtrl after refactoring

alex alecla at bluewin.ch
Sat Mar 28 09:55:39 EDT 2009


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

I suppose that this has to do with the variables in my tuple or the
scope of the variables but for the moment I can't really figure out
what the problem is.

Maybe you can give me a hint. Again thank you.
Alex





More information about the Python-list mailing list