[Tkinter-discuss] ttk.Notebook - how to bind to tab events (tab caption has focus or mouseover)

python at bdurham.com python at bdurham.com
Wed Dec 15 20:48:18 CET 2010


Michael,

Thank you so much for your example!!

Re: Detect mouse events on tabs. The trick for me was understanding how
to use the index method. Your technique below is exactly the solution I
was looking for (I wasn't aware of the '@%d,%d' formatting technique).

index = event.widget.index('@%d,%d' % (event.x, event.y))

Re: Detect when a tab caption has keyboard focus (<FocusIn> or similar).

The <<NotebookTabChanged>> does not correspond to the tab caption
gaining keyboard focus.

And the notebook widget generates a single <FocusIn> event when it gets
focus.

Is there a way to drill-down to the Tk label controls in the captions
and bind to their <FocusIn> events? Or is there a way to expose the tabs
as actual widgets whose events can be bound to?

Thanks again for all your help in these forums!

Malcolm


More information about the Tkinter-discuss mailing list