I am finishing to implement a typical search engine in a text editor.
The call to open the search panel can be made from the available menu option "Search> " or with the key combination "CTRL + F".
Calling the search engine is when you build your entire panel with all the necessary elements (buttons, entry box, etc.).
And, within the same construction of the panel, I consider the fact if there is something selected in the Text
, to load it as the initial content of Entry
of the search engine.
(where self.text_01
is the name of the Text
and '' the one of the entry of the search engine)
# ...
# Si hay un texto seleccionado...
if(self.text_01.tag_ranges('sel')):
TXT_seleccionado = self.text_01.get(tk.SEL_FIRST, tk.SEL_LAST)
self.entr_str.insert(0, TXT_seleccionado)
# ...
The consideration of a combination of keys to open the search panel I put it like this:
# Combinación de teclas para abrir el panel de "Buscar"
self.bind('<Control-f>', self.buscar)
Here you can see the complete code to which I refer (which already exists in response to another of my questions).
And the question would be, why do I get to load, initially, in Entry
, the content selected in Text
if I access the menu option but NO load if I access the key combination "CTRL + F"?
What would it take to do to load it, properly, by both options?
(provided there was something selected in Text
, of course)
Thank you.