[wxPython-users] Adding a toolbar kills events

Mathew Yeates myeates at jpl.nasa.gov
Tue May 8 17:32:41 PDT 2007


Yes, that worked. Thanks Robin.

Robin Dunn wrote:
> Mathew Yeates wrote:
>> Hi
>> I have an ogl canvas that I want to catch key down events.
>> The following code snippet works if I comment out the toolbar creation.
>> -------------------
>>        self.scrolledWindow1 = 
>> wx.lib.ogl._canvas.ShapeCanvas(id=wxID_PROCVISMAINFRAMESHAPECANVAS1,
>>              name='shapeCanvas1', parent=self, pos=wx.Point(0, 0),
>>              size=wx.Size(822, 630), style=wx.HSCROLL | wx.VSCROLL)
>>        self.scrolledWindow1.Bind(wx.EVT_KEY_DOWN,
>>              self.OnScrolledWindow1KeyDown)
>>
>>        #the next line fouls things up
>>        self.toolBar1 = wx.ToolBar(id=wxID_PROCVISMAINFRAMETOOLBAR1,
>>              name='toolBar1', parent=self.scrolledWindow1, 
>> pos=wx.Point(0, 0),
>>              size=wx.Size(822, 28), style=wx.TB_HORIZONTAL | 
>> wx.NO_BORDER)
>>       ----------------------
>>
>> What gives? Adding a toolbar results in self.OnScrolledWindow1KeyDown 
>> never being called.
>
> Have you tried explicitly setting the focus to self.scrolledWindow1? 
> KEY and CHAR events are only delivered to windows with the focus.
>
>






More information about the wxpython-users mailing list