我怎么用这个诅咒.KEY选项正确吗?

2024-05-18 22:28:45 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在写作业,我必须用python3制作一个使用诅咒的文本编辑器。我对关键的比较有些问题,因为我不知道为什么它不起作用。 这是我第一次和诅咒打交道,所以请记住这一点。你知道吗

我试过了窗口.getch()函数和窗口.getkey()但都不起作用。 我尝试了一些简单的东西,如果你按向上键,它会删除窗口,并添加更多的东西到同一个窗口,只是为了尝试,但它不起作用。你知道吗

def main():
    """
    Función principal
    """
    #Start the window
    ventana = empezar_interfaz() #Start the window

#This is the information that appears the first time
texto = estructura_datos()

#Put that information into the window
imprimir = colocar_texto(0,0,texto[0]+texto[1]+texto[2],ventana)

#Get a key, "tecla" is key
tecla = capturar_tecla(ventana)

#This is what it's supposed to happen when you hit that key
if tecla == "KEY_UP":

    #Just add some more text to the window
    ventana.erase()

    texto_nuevo = "Presionó la tecla de abajo!"

    colocar_texto(1,1,texto_nuevo,ventana)

    ventana.refresh()

    tecla = capturar_tecla(ventana)

    terminar = end_interfaz(ventana)

#Ends the app    
terminar = end_interfaz(ventana)

我写了一些描述让你理解,因为正如你所见,我讲西班牙语。你知道吗

“capturar\u tecla(ventana)”函数只是使用getkey()或getch()获取一个键

正如我告诉你的,我期待的是删除窗口,并添加一些文字后,键被击中。你知道吗


Tags: thekey函数thatiswindowthisstart

热门问题