wx error, I suspect my class

A

Alex Hall

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
res=xrc.XmlResource('dictionary.xrc')

#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"))
mf.Show()
#end def OnInit

def close(self):
mf.Close(True)
#end def close
#end class myapp

win=myapp(False)
win.MainLoop()

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,705
Latest member
Stefkari24

Latest Threads

Top