From: Alex Hall on
Hello all,
I am trying to make a gui out of xrc and wxpython, but I think my
understanding of Python's class/method structure is causing problems.
The below code returns an error on the line
panel=xrc.XRCCTRL(mf, "dl")
The error goes back to wxPython itself and says "attribute error:
'none' type object has no attribute 'FindWindowById'"
Here is my complete code:

import wx
from wx import xrc

class myapp(wx.App):
def OnInit(self):
#load the xrc file

#load the frame containing everything else
mf=res.LoadFrame(None, "mainframe")

#assign all necessary controls to variables (text boxes and buttons)
for easier binding
#format: varName=xrc.XRCCTRL(parent, IDFromXRCFile)
panel=xrc.XRCCTRL(mf, "dl")
btn_go=xrc.XRCCTRL(panel, "btn_go")
btn_close=xrc.XRCCTRL(panel, "btn_close")

#now bind the gui controls to functions
mf.Bind(wx.EVT_BUTTON, close, id=xrc.XRCID("btn_close"))
#end def OnInit

def close(self):
#end def close
#end class myapp


That is all there is to it. I made the xrc file with XRCed, so I know
it is properly formatted. I always see Python methods and classes
using the "self" keyword, but I never understood why or when to/not to
use it. I probably need it in the above code, but I am not sure how to
insert it correctly. I have been fighting with this code for the last
two days with no progress, so I would greatly appreciate any help you
can provide. Thanks.

Have a great day,
Alex (msg sent from GMail website)