Home>

I am writing a GUI using TKinter. And I ran into a problem for which I could not find a solution:

My interface has an input field (Entry). The user enters some information into it. I need to prevent the user from highlighting the text in this field. It is important.

I tried to solve this problem by creating a stream withThreading, and in an endless loop cleared the selection withselection_clear ()... But I doubt this is a good decision. Maybe there is a way to track the text highlight event inEntry?

look here. something similar -coderoad.ru/26208695/...

splash582021-12-29 07:43:35

@ splash58 Thank you. But there all the solutions prevent the user from entering text. And I need the user to be able to enter text, but at the same time he could not select it

Никита2021-12-29 07:52:40

I did not find the selection event. Alternatively, catch the events of the release of the mouse button and keyboard keys, check the selection, if there is one, clear it.

insolor2021-12-29 09:00:08

Thanks for the advice. I'll try.

Никита2021-12-29 09:01:16

In Tcl /Tk, I would do this at the bind level or intercept the "selection" command itself. But there are generally quite a few events where the selection takes place (tk :: EntryMouseSelect, tk :: EntryKeySelect). Here are the default Entry bindings -github.com/tcltk/tk/blob/main/library/entry.tcl

GrAnd2021-12-29 09:34:28