467,906 Members | 1,590 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,906 developers. It's quick & easy.

wxpython AttributeError!

need help with wxpython.
wxpython code is made with boa-constructor

when i run the code i get this error message:

Traceback (most recent call last):
File "wxApp1.py", line 24, in ?
main()
File "wxApp1.py", line 20, in main
application = BoaApp(0)
File "K:\Python23\lib\site-packages\wxPython\wx.py", line 1945, in __init__
_wxStart(self.OnInit)
File "wxApp1.py", line 13, in OnInit
self.main = wxFrame1.create(None)
File "wxFrame1.py", line 12, in create
return wxFrame1(parent)
File "wxFrame1.py", line 220, in __init__
self._init_ctrls(parent)
File "wxFrame1.py", line 157, in _init_ctrls
EVT_RIGHT_DOWN(self.treeCtrl1, self.OnTreectrl1RightDown)
AttributeError: wxFrame1 instance has no attribute 'OnTreectrl1RightDown'
23:06:44: Debug: c:\PROJECTS\wx\src\msw\app.cpp(439):
'UnregisterClass(canvas)' failed with error 0x00000584 (class still has open
windows.).

this is the code have this code:

self.treeCtrl1 = wxTreeCtrl(id=wxID_WXFRAME1TREECTRL1, name='treeCtrl1',
parent=self.splitterWindow1, pos=wxPoint(2, 2),
size=wxSize(200,
610), style=wxTR_HAS_BUTTONS, validator=wxDefaultValidator)
self.treeCtrl1.SetFont(wxFont(10, wxSWISS, wxNORMAL, wxNORMAL,
False,
'Microsoft Sans Serif'))
EVT_RIGHT_DOWN(self.treeCtrl1, self.OnTreectrl1RightDown)
EVT_TREE_SEL_CHANGED(self.treeCtrl1, wxID_WXFRAME1TREECTRL1,
self.OnTreectrl1TreeSelChanged)

and the event EVT_RIGHT_DOWN code is:

def OnTreectrl1RightDown(self, event):
dosomething()
event.Skip()

the "OnTreectrl1RightDown" is in the wxframe class
what to do?
thanx in advance
Jul 18 '05 #1
  • viewed: 2066
Share:
1 Reply
"frank" <fr***@pc-nett.no> writes:
need help with wxpython.
wxpython code is made with boa-constructor

when i run the code i get this error message: (...) File "wxFrame1.py", line 157, in _init_ctrls
EVT_RIGHT_DOWN(self.treeCtrl1, self.OnTreectrl1RightDown)
AttributeError: wxFrame1 instance has no attribute 'OnTreectrl1RightDown' (...)
this is the code have this code:

self.treeCtrl1 = wxTreeCtrl(id=wxID_WXFRAME1TREECTRL1, name='treeCtrl1',
parent=self.splitterWindow1, pos=wxPoint(2, 2),
size=wxSize(200,
610), style=wxTR_HAS_BUTTONS, validator=wxDefaultValidator)
self.treeCtrl1.SetFont(wxFont(10, wxSWISS, wxNORMAL, wxNORMAL,
False,
'Microsoft Sans Serif'))
EVT_RIGHT_DOWN(self.treeCtrl1, self.OnTreectrl1RightDown)
EVT_TREE_SEL_CHANGED(self.treeCtrl1, wxID_WXFRAME1TREECTRL1,
self.OnTreectrl1TreeSelChanged)

and the event EVT_RIGHT_DOWN code is:

def OnTreectrl1RightDown(self, event):
dosomething()
event.Skip()

the "OnTreectrl1RightDown" is in the wxframe class
what to do?


First is not to snip so much code for your post that context is lost :-)

It's not clear from the above code whether or not your initialization
code and the function definition are within the same class (especially
with the different indentation levels). If in fact the initialization
code is part of your __init__ definition in wxFrame1, which also holds
the callback function definition, at first glance it looks like it
should be ok. Or, if the callback definition is in a subclass of
wxFrame1 then you should be ok as well. But the error you are getting
would imply that 'self' in your initialization code is not the same
object as that which contains the callback definition.

If you could post a more complete snippet of the code (in particular,
at a minimum an unchanged copy of the entire __init__ (or other
function) containing the initialization code, including its enclosing
class definition, as well as the same for the callback function), it
might be easier to see what problem exists.

-- David
Jul 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by John Kinson | last post: by
3 posts views Thread by Russ Phillips | last post: by
2 posts views Thread by Nicolas Pourcelot | last post: by
1 post views Thread by PeterG | last post: by
2 posts views Thread by KDawg44 | last post: by
1 post views Thread by Steven W. Orr | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.