switching from one entry to the other when typing a word

Asked

Viewed 72 times

0

Guys, help me with this, I have two entry and I need that 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 ()   

1 answer

2

You can make your program recognize that you have finished typing the word with a tap on the key Enter. Then 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 hold the enter (Return) key event and call the function muda_barrinha:

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

janela2.mainloop()

Browser other questions tagged

You are not signed in. Login or sign up in order to post.