Tkinter: Remove active button highlight

Question:

How can I remove the dotted black border after a button is clicked in Tkinter (with Ttkthemes)?
enter image description here

I’m on Windows 10, Python 3.7.9.

There seems to be no uniform way to remove it and I searched across Google and SO with no luck. Thanks.
Here’s a minimal example:

import tkinter
import tkinter.ttk
from ttkthemes import ThemedTk

tk = ThemedTk(theme="arc")
tk.configure(background="#f5f6f7")
tk.resizable(0,0)

selectFileInput = tkinter.ttk.Button(
    tk,
    text="Select Input File"
)
selectFileInput.place(x=20,y=60)
tk.mainloop()
Asked By: user11709129

||

Answers:

I found the solution. It was to create a dummy button and focus it to remove focus from the button to the dummy button by using dummy.focus()

Answered By: user11709129

ttk.Button has the keyword argument takefocus this can be set to false and the button does not take focus after it is clicked.

ttk.Button(.., .., takefocus=False)

Therefore you do not need a hack with a dummy button that takes focus as in the answer.

Answered By: Klaus
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.