LaGuille
LaGuille

Reputation: 1728

Python Tkinter - Prevent Focus State on Lastly Clicked Button

I'm working on a basic PIN interface for a touch screen with Python 2.7 Tkinter and ttk. I'm developing the script on Windows but it will eventually be loaded on a Linux OS.

I am trying to prevent what is shown on the "6" button of the picture bellow, i.e. a dashed border around the button lastly clicked. Since I don't want people to easily steal the PIN from my users, I have to prevent this from happening, otherwise it becomes really easy to find out what their PIN are just by looking at the screen. I have noticed that this behavior becomes even more obvious on LINUX with something like a thick white border around the button.

Tk interface

I am calling my buttons inside a loop like this:

ttk.Style().configure('TButton', padding=11, relief="flat", background="#ccc", foreground="#393939", width=4,font='Arial 9')


btn = ttk.Button(window, text = txt, command = lambda txt=txt:self.addChar(txt))
btn.grid(row=row, column=col, padx=1, pady=1)

Upvotes: 0

Views: 1665

Answers (1)

Bryan Oakley
Bryan Oakley

Reputation: 386342

The solution is pretty simple: modify your addChar function to move the focus back to some other widget after it inserts the character.

Upvotes: 1

Related Questions