Set default cursor position inside entry widget in Tkinter Python

吃可爱长大的小学妹 提交于 2020-01-20 07:47:10

问题


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.

Can anyone help me with this? Actually I'm new at programming

import tkinter as tk

root = tk.Tk()

e = tk.Entry(root)
e.pack()

tk.mainloop()

回答1:


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()


来源:https://stackoverflow.com/questions/59499960/set-default-cursor-position-inside-entry-widget-in-tkinter-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!