473,508 Members | 2,412 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2300
"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
1427
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 running the demo.py program. Here is a trace of the...
1
2094
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 script: # ./demo.py Traceback (most recent call...
3
7516
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. I have looked into wxPython documentation and...
3
2534
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 module named defs.py I would like to get the value...
5
10642
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' the work of the app. When start is pressed, a new...
2
2263
by: Nicolas Pourcelot | last post by:
Hello, my script worked well until today : when I tried to launch it, I got the following : frame = MyFrame(None,-1,"Geometrie",size=wx.Size(600,400)) File...
1
2779
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 server and IM gui client. I have a very basic...
2
2158
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 demo.py Traceback (most recent call last): File...
1
2365
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 was horribly doing a from wxPython import * I...
0
7233
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7342
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7505
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5060
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4729
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3201
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1570
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
774
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
440
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.