switching from one entry to the other when entering a word

0

People, help me with this, I have two entry and I need when I type a word for example (Python) it changes from one entry to the other automatically

from tkinter import * 

janela2.geometry('250x250+100+100')

lb2 = Label(janela2, text='coloque seu nome')

barrinha= Entry(janela2)

barrinha.place(x=80,y=80)

barrinha1= Entry(janela2)

barrinha1.place(x=80,y=120)

janela2.mainloop ()   
    
asked by anonymous 17.06.2018 / 15:56

1 answer

2

You can make your program recognize that you have typed the word with the Enter key. So the code would look like this:

from tkinter import *

def muda_barrinha(tecla):
    barrinha1.focus()

janela2 = Tk()
janela2.geometry('250x250+100+100')

lb2 = Label(janela2, text='coloque seu nome')

barrinha = Entry(janela2)

barrinha.place(x=80, y=80)
barrinha.focus()
barrinha.bind("<Return>", muda_barrinha) 

The method bind takes the event key enter (Return) and calls the function muda_barrinha :

barrinha1 = Entry(janela2)
barrinha1.place(x=80, y=120)

janela2.mainloop()
    
19.06.2018 / 16:01