The attached file is the wxPython 2.8.4 sash window demo, modified to demonstrate an event-binding problem:
Despite binding both wx.EVT_LEFT_DOWN and wx.EVT_KEY_DOWN to self.OnUserAction, self.OnUserAction is not called when the left mouse button is pressed or when a key is pressed.
Since wx.MouseEvent and wx.KeyEvent are not command events, they are only sent to the widget that event actually happened to, and will not travel up to the parent widgets. Since you are binding these events to the panel, then the KEY_DOWN will only be sent when the panel has the keyboard focus (which will never happen if it has children) and the LEFT_DOWN will only be sent when the panel itself is clicked on (which will never happen because it is fully covered by the sash window.)
···
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!
I'm still confused. I had tried binding wx.EVT_LEFT_DOWN and wx.EVT_KEY_DOWN to the left and right windows, without success. So, after reading your words to me, I'm trying again, still without success; please see the attached SashWinBinds.py.
The attached file is the wxPython 2.8.4 sash window demo, modified to demonstrate an event-binding problem:
Despite binding both wx.EVT_LEFT_DOWN and wx.EVT_KEY_DOWN to self.OnUserAction, self.OnUserAction is not called when the left mouse button is pressed or when a key is pressed.
What am I missing here?
class TestSashWindow(wx.Panel):
def __init__(self, parent, log):
wx.Panel.__init__(self, parent, -1)
Since wx.MouseEvent and wx.KeyEvent are not command events, they are only sent to the widget that event actually happened to, and will not travel up to the parent widgets. Since you are binding these events to the panel, then the KEY_DOWN will only be sent when the panel has the keyboard focus (which will never happen if it has children) and the LEFT_DOWN will only be sent when the panel itself is clicked on (which will never happen because it is fully covered by the sash window.)
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!
I'm still confused. I had tried binding wx.EVT_LEFT_DOWN and wx.EVT_KEY_DOWN to the left and right windows, without success. So, after reading your words to me, I'm trying again, still without success; please see the attached SashWinBinds.py.
Once I corrected the apparent typo in your test code it worked fine here.
What platform and version are you using?
···
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!
Ah, leftwin1 instead of leftwin. I looked straight at that and
didn’t see it. Yikes! Time for me to retire! Oh, that’s
right, I already have.
Since I hadn’t created the leftwin sash layout window, I’m
surprised that the statements after the leftwin1 =
wx.SashLayoutWindow …
statement didn’t produce errors.
I’m on Win XP SP2 with python 2.5.1 and wxPython 2.8.4.
Bob
···
At 04:51 PM 10/3/2007, Robin Dunn wrote:
Bob Klahn wrote:
Hi Robin,
I’m still confused. I had tried binding wx.EVT_LEFT_DOWN and
wx.EVT_KEY_DOWN to the left and right windows, without success. So,
after reading your words to me, I’m trying again, still without success;
please see the attached SashWinBinds.py.
Once I corrected the apparent typo in your test code it worked fine
here.