Get of Entry does not work (python (tkinter))

0

I need to do the following exercise, the problem is that when I want to use the var.get () does not return anything, does not give an error, only returns nothing. I tried to use it inside the main and it works, but inside the function, can someone help me? Thanks.

"""
4. Una secuencia de ADN es una cadena compuesta de As, Ts, Cs y Gs. Escribe una aplicación
GUI en la cual se ingresa una secuencia de ADN, y cuando se hace clic en el botón Contar, se
cuenta y se visualiza el número de As, Ts, Cs y Gs en la ventana (vea la imagen a
continuación).
"""

from tkinter import *
ventana= Tk()

def buscaRufus(var,entradaTexto):
    As= str(var.get()).upper().count("AS")
    Ts= str(var.get()).upper().count("TS")
    Cs= str(var.get()).upper().count("CS")
    Gs= str(var.get()).upper().count("GS")

    textoFinal="Num As: " +str(As)+ " Num Ts: " +str(Ts)+ " Num Cs: " +str(Cs)+ " Num GS: " +str(Gs)   
    a= StringVar()
    a= "a"+var.get()
    entradaTexto.set(a)

if __name__=="__main__":
    #Variables globales
    var= StringVar()
    entradaTexto= StringVar()
    #Vista
    contenedor= Frame(ventana).pack()
    Entry= Entry(contenedor, borderwidth="4", textvariable=var).pack()

    boton= Button(contenedor, text="Busca", command=buscaRufus(var,entradaTexto)).pack()

    label= Label(contenedor, textvariable=entradaTexto).pack()


    ventana.mainloop()
    
asked by elver 13.12.2018 в 19:07
source

0 answers