python - takefocus = NO fails to prevent tkinter.ttk.Notebook tabs from taking focus -
in following example, have set notebook not take focus, tabs skipped on while navigating widget widget using shortcuts supported enable_traversal()
. works, not entirely. if tab being displayed (but doesn't have focus), pressing <alt-key>
underline-style shortcut gives focus. how can prevent this?
from tkinter import * tkinter import ttk root = tk() nb = ttk.notebook(root, takefocus = no) nb.enable_traversal() f1 = frame(nb) b1a = button(f1, text = 'charlie') b1b = button(f1, text = 'delta') f2 = frame(nb) b2a = button(f2, text = 'echo') b2b = button(f2, text = 'foxtrot') b1a.pack() b1b.pack() b2a.pack() b2b.pack() f1.pack() f2.pack() nb.pack() nb.add(f1, text = 'alpha', underline = 0) nb.add(f2, text = 'bravo', underline = 0)
why add underline=0
? remove piece of code in both lines. also, add argument takefocus=false
while adding tabs. , remove takefocus
when creating notebook.
Comments
Post a Comment