How to make the cursor be in Text at the beginning of the program?

Asked

Viewed 113 times

2

I would like to know how to blink the cursor on an object tkinter.Text when I walk the application, because usually no widget is selected. I would like to have the same effect as a terminal when it is turned on, where you see the blink cursor.

This is the code I’m using, but it doesn’t work:

self.prompt = tkinter.Text(self.root, bg=self.bg, fg=self.fg, insertbackground=self.fg)

self.prompt.insert(tkinter.END, self.PROMPT_M)
self.prompt.bind('<Return>', self.add_prompt)

self.prompt.pack()
self.prompt.focus()

1 answer

1

Utilize Entry.focus()

from tkinter import *

root = Tk()
text = Text(root)
entry = Entry(root)
entry.pack()
entry.focus()

root.mainloop()

Browser other questions tagged

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