me@here:~$ python keyEvents.py
Traceback (most recent call last):
File "keyEvents.py", line 34, in ?
MyApp(0).MainLoop()
File "/usr/lib/python2.3/site-packages/wxPython/wx.py", line 1951, in __init__
_wxStart(self.OnInit)
File "keyEvents.py", line 15, in OnInit
textCtrl.Bind(wx.EVT_CHAR, self.OnKeyEvent1)
AttributeError: wxTextCtrl instance has no attribute 'Bind'
···
"Peter Damoc" <pdamoc@gmx.net> wrote:
On Mon, 06 Sep 2004 02:14:44 -0400, <jahurt644@netscape.net> wrote:
Hello. I'm a newbie to wxPython and GUI programming in general (although
I have encountered Python before, but I'm by no means an expert). I'm
trying to write a very simple application that does the following...
Initially displays a window containing a button and a text window. The
text window should display numeric keycodes as keys on the keyboard are
pressed. Pressing the button should kill the current form and create
another form with the same controls (the form positions are offset a bit
to verify this is happening). I haven't had any luck with the keyboard
event handler, so I'm likely doing something very fundamentally wrong.
Anyway, here's the code... please keep in mind I'm new to this, so try
not to laugh too hard Again, any (constructive) criticism is greatly
appreciated.
Ok... some constructive (hopefully) criticism:
- look into the new wx namespace
Now about the keyEvents... they are delivered to the focused component.
I have attached a small script demonstrating that;
click the red panel, the button, the textctrl and the gray area and each
time you'll see that the focus moves and the component that receives the
key events is different (different event handlers are called).
Notice that if you don't call evt.Skip() in the textCtrl's handler the
keyEvents don't get to the textCtrl default handler and they don't get
printed (chars don't get inserted in the textCtrl).
__________________________________________________________________
Switch to Netscape Internet Service.
As low as $9.95 a month -- Sign up today at AOList Teil der Yahoo Markenfamilie
Netscape. Just the Net You Need.
New! Netscape Toolbar for Internet Explorer
Search from anywhere on the Web and block those annoying pop-ups.
Download now at AOList Teil der Yahoo Markenfamilie
On Mon, 06 Sep 2004 02:14:44 -0400, <jahurt644@netscape.net> wrote:
Hello. I'm a newbie to wxPython and GUI programming in general (although I have encountered Python before, but I'm by no means an expert). I'm trying to write a very simple application that does the following...
Initially displays a window containing a button and a text window. The text window should display numeric keycodes as keys on the keyboard are pressed. Pressing the button should kill the current form and create another form with the same controls (the form positions are offset a bit to verify this is happening). I haven't had any luck with the keyboard event handler, so I'm likely doing something very fundamentally wrong. Anyway, here's the code... please keep in mind I'm new to this, so try not to laugh too hard Again, any (constructive) criticism is greatly appreciated.
Ok... some constructive (hopefully) criticism:
- look into the new wx namespace
Now about the keyEvents... they are delivered to the focused component.
I have attached a small script demonstrating that;
click the red panel, the button, the textctrl and the gray area and each time you'll see that the focus moves and the component that receives the key events is different (different event handlers are called).
Notice that if you don't call evt.Skip() in the textCtrl's handler the keyEvents don't get to the textCtrl default handler and they don't get printed (chars don't get inserted in the textCtrl).
me@here:~$ python keyEvents.py Traceback (most recent call last):
File "keyEvents.py", line 34, in ?
MyApp(0).MainLoop()
File "/usr/lib/python2.3/site-packages/wxPython/wx.py", line 1951, in __init__
_wxStart(self.OnInit)
File "keyEvents.py", line 15, in OnInit
textCtrl.Bind(wx.EVT_CHAR, self.OnKeyEvent1)
AttributeError: wxTextCtrl instance has no attribute 'Bind'
Bind is new in wxPthon 2.5.x
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!
I guess you might be using an old version of wxpython (maybe 2.4.2.4 )
anyway... I've made some changes... now it should work (I don't have 2.4 anymore, I couldn't test it)
On Mon, 06 Sep 2004 10:13:07 -0400, <jahurt644@netscape.net> wrote:
Thanks, but I can't get it to work....
me@here:~$ python keyEvents.py
Traceback (most recent call last):
File "keyEvents.py", line 34, in ?
MyApp(0).MainLoop()
File "/usr/lib/python2.3/site-packages/wxPython/wx.py", line 1951, in __init__
_wxStart(self.OnInit)
File "keyEvents.py", line 15, in OnInit
textCtrl.Bind(wx.EVT_CHAR, self.OnKeyEvent1)
AttributeError: wxTextCtrl instance has no attribute 'Bind'