[wxPython-users] Capturing a mouse click on the tab of an already selected notebook page

Bob Klahn bobstones at comcast.net
Tue Sep 25 07:34:34 PDT 2007


At 04:01 AM 9/25/2007, Andrea wrote:
>Hi Bob,
>
>On 9/25/07, Bob Klahn wrote:
> > How do I do that?  It's probably very simple, but the solution
> > continues to escape me.  I suspect I'll slap my forehead when you all
> > clue me in ...
> >
> > I have a splitter with two notebooks, one notebook on each side 
> of the sash.
> >
> > For =one= type of right-notebook page (not for other right-notebook
> > page types), the code that responds to a click there should perform
> > its particular task =and= set the focus to a panel on the
> > corresponding left-notebook page.
> >
> > I have no trouble making this happen in response to a click anywhere
> > =within= the right-notebook page.  THE PROBLEM occurs when  the =tab=
> > of the right-notebook page is clicked.
> >
> > MY QUESTION:  How do I capture a click on the =tab= of an already
> > selected notebook page?
> >
> > (wx.EVT_NOTEBOOK_PAGE_CHANGED (or wx.EVT_NOTEBOOK_PAGE_CHANGING)
> > events are of course not triggered.)
>
>I haven't tried it so I am not sure it will work, but what about 
>something like:
>
>yourNotebook.Bind(wx.EVT_LEFT_DOWN, self.OnLeftDown)
>
>def OnLeftDown(self, event):
>
>     # Do something to the other notebook
>     event.Skip()
>
>When the 2 notebook events (wx.EVT_NOTEBOOK_PAGE_CHANGED or
>wx.EVT_NOTEBOOK_PAGE_CHANGING) are not triggered, probably the
>wx.EVT_LEFT_DOWN is sent.
>
>Andrea.

Thanks!  Yes, wx.EVT_LEFT_DOWN is sent.  I had already tried this, 
and =assumed= (we know about that word) it didn't work because of the 
problem I still have.  I must never have put a log statement in the 
left-down event-triggered code.  Shame on me.

Regardless, as I just said, I still have a problem ...

My main-frame code now looks like this:

self.nb2.Bind(wx.EVT_LEFT_DOWN, self.OnLeftDown2)

def OnLeftDown2(self,event):
       code-to-set-focus-to-notebook1-panel
       event.Skip()

If I comment out the event-skip line, focus is set to the notebook-1 
panel.  But when I comment the event.Skip() line back in, that focus is lost.

So something further up the event chain is interfering.  How can I 
find out what that is?

Bob






More information about the wxpython-users mailing list