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

2

I would like to know how to flash the cursor on a tkinter.Text object when I walk the application, because normally no widget is selected. I would like to have the same effect as a terminal when it is turned on, where the cursor is flashing.

This is the code I'm using, but it does not 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()
    
asked by anonymous 11.12.2014 / 02:23

1 answer

1

Use Entry.focus()

from tkinter import *

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

root.mainloop()
    
11.12.2014 / 03:06