Set default caret position inside entry widget in Tkinter Python

前端 未结 1 1631
逝去的感伤
逝去的感伤 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)
提交回复
热议问题