472,353 Members | 1,671 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,353 software developers and data experts.

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
1 2231
"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Doug Farrell | last post by:
Hi all, I just installed the wxPython-2.4.1.2 demo RPM on my RedHat Linux 9.0 machine, which has Python 2.2.2 on it, and I'm having a problem...
1
by: John Kinson | last post by:
Hi, I'm trying to get the wxPython demo to run on a Debian sarge testing installation, but encounter the following error when I run the demo...
3
by: Lo?c Mah? | last post by:
Hello I try to use a Validator for a TxtCtrl placed in a Panel with a Button in order to trigger the Validator and test the content of TxtCtrl. ...
3
by: Russ Phillips | last post by:
I'm just starting to learn Python & wxPython. I have a frame named frSend in a file fSend. On this frame is a wxTextCtrl named txtMsg. I have a...
5
by: fooooo | last post by:
This is a network app, written in wxPython and the socket module. This is what I want to happen: GUI app starts. User clicks a button to 'start'...
2
by: Nicolas Pourcelot | last post by:
Hello, my script worked well until today : when I tried to launch it, I got the following : frame =...
1
by: PeterG | last post by:
Hi, I am relatively new to Python, and am learning it as part of a university module... Im currently undertaking a project to create an IM...
2
by: KDawg44 | last post by:
Hi, I downloaded the wxPython demo and did an emerge wxpython (gentoo) to install. When I run the demo, I am getting this error: # python...
1
by: Steven W. Orr | last post by:
python-2.3.5 wx-2.6 I just bought the wxPython In Action book and I see that all the examples say to import wx All of our pre-existing code...
1
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand....
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.