0

Estuve buscando, pero no encontré forma de hacerlo y no estoy seguro si es posible. Mi objetivo es que mientras se escribe en un Entry (correspondiente a la libreria Tkinter), se pueda agregar un carácter (que no se encuentra en el código ascii) con una combinación de teclas personalizadas, es decir, simulando el funcionamiento del código ascii. No tengo código para mostrar, pero por ejemplo, que mediante una combinación de teclas pueda introducir:

λ,∩,∪

. ¿Es posible?

1 respuesta 1

1

Si es posible hacerlo. Aqui te dejo un código que hace eso mismo:

from tkinter import *

Tk()

e=Entry()
e.pack()

def char(Event):
    # OBTENGO EL ENTRY #
    entry = Event.widget

    # UBICO EL CARACTER EN DONDE ESTÁ EL CURSOR #
    entry.insert(entry.index("insert"), "∩")

    # SI YA EXISTIA LA COMBINACION DE TECLAS, EVITO QUE SE CREE EL CARACTER ORIGINAL #
    return "break"


# HAGO QUE AL PRESIONAR ALT+9+4 SE LLAME A LA FUNCIÓN CHAR #
e.bind("<Alt_L>94", char)

Para bindear combinaciones de 3 o más teclas la respuesta a esta pregunta te puede servir, es lo que yo usé: https://stackoverflow.com/questions/56204344/binding-multiple-keys-to-a-function-in-tkinter-python#:~:text=In%20tkinter%20you%20can%20put,and%20it%20will%20run%20function.&text=By%20just%20adding%20the%20and,the%20tab%20and%20enter%20keys.

Tu Respuesta

By clicking “Publica tu respuesta”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

¿No es la respuesta que buscas? Examina otras preguntas con la etiqueta o formula tu propia pregunta.