[Python] Python: How do i store a text input from the user on Tkinter?

Discussão em 'Python' iniciado por Stack, Dezembro 1, 2024.

  1. Stack

    Stack Membro Participativo

    This is what i tried so far to get the user's input:

    master = Tk()
    master.title('Title')

    v = StringVar()

    L1 = Label(master, text = 'Name')
    L1.pack(side = LEFT)

    E1 = Entry(master, textvariable = v, bd = 5)
    E1.pack(side = RIGHT)

    def userinput():
    a = raw_input(v.get())
    print a


    b = Button(master, text = 'Submit', command = userinput)
    b.pack(side = BOTTOM)


    master.mainloop()


    The real question is, how can i store the v.get() raw_input into a variable outside the function? Thx!

    Continue reading...

Compartilhe esta Página