Set default caret position inside entry widget in Tkinter Python

前端 未结 1 1623
逝去的感伤
逝去的感伤 2020-12-11 14:33

I want to set the default cursor location inside the entry widget when I run the program.

So when I run it I don\'t have to click inside the widget to start typing.<

1条回答
  •  南方客
    南方客 (楼主)
    2020-12-11 14:57

    Simply call the focus method for the widget:

    import tkinter as tk
    
    root = tk.Tk()
    
    e = tk.Entry(root)
    e.pack()
    e.focus()
    
    tk.mainloop()
    

    0 讨论(0)
提交回复
热议问题