[wxPython-users] Capturing a mouse click on the tab of an
already selected notebook page
Bob Klahn
bobstones at comcast.net
Tue Sep 25 17:24:20 PDT 2007
At 08:03 PM 9/25/2007, you wrote:
>At 07:52 PM 9/25/2007, you wrote:
>>Hi Bob,
>>
>>On 9/26/07, Bob Klahn wrote:
>> > Still no luck, Robin. My main-frame initialization code now
>> looks like this:
>> >
>> > self.nb1.Bind(wx.EVT_LEFT_DOWN, self.OnLeftDown1)
>> > self.nb2.Bind(wx.EVT_LEFT_DOWN, self.OnLeftDown2)
>> >
>> > def OnLeftDown1(self, evt):
>> > wx.CallAfter(self.SetDiagramFocus())
>> > evt.Skip()
>> >
>> > def OnLeftDown2(self, evt):
>> > wx.CallAfter(self.SetDiagramFocus())
>> > evt.Skip()
>>
>>You shouldn't use brackets in the argument method of wx.CallAfter,
>>this is what the traceback is saying. Try to use the following:
>>
>> def OnLeftDown1(self, evt):
>> wx.CallAfter(self.SetDiagramFocus)
>> evt.Skip()
>>
>> def OnLeftDown2(self, evt):
>> wx.CallAfter(self.SetDiagramFocus)
>> evt.Skip()
>>
>>Notice the missing parenthesis () in the wx.CallAfter arguments :-D :-D
>>
>>Andrea.
>
>Aha! Wunderbar! It works! Bless you.
>
>Bob
One more comment. A code snippet:
self.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED, self.OnPageChanged1)
# if self.nb1.GetRowCount() > 0:
# self.nb1.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED, self.OnPageChanged1)
# self.nb2.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED, self.OnPageChanged2)
The above binding to the main frame rather than to either notebook
works. But when I used the notebook-specific bindings instead, the
old problem returns, i.e., focus remains on the notebook tab.
I don't understand that.
Bob
More information about the wxpython-users
mailing list