On Fri, 27 Mar 2009 21:51:19 -0000, alex <ale...@bluewin.ch> wrote:

Hi all
I am working on a Dialog window for a gui in wxPython and started
refactoring it, below code is a simplified version of it.
"def createInput1" should create a static text, a button and a
textcontrol using the information in "def box1Labels".
"def makeStaticBox1" then arranges all widgets in staticbox1.

My problem is that it works fine for the static text and the button
label but I cant "rename" self.txtctrl that it
becomes self.txtctrl_inpath or self.txtctrl_outpath for getting the
path from either "def BrowseInDlg" or "def BrowseOutDlg".

You need the special __setattr__ method.  A normal object attribute
assignment like:

  self.wombat = "go"

is equivalent to a call of

  self.__setattr__("wombat", "go")

So in your createInput1 method, once the widgets have been created
and all the dust has settled, if you add the line:

  self.__setattr__(txtctrl_path, self.txtctrl)

it will do exactly what you're after!

--
Rhodri James *-* Wildebeeste Herder to the Masses
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to