【发布时间】:2018-05-29 06:46:57
【问题描述】:
我正在尝试在单击条目内部时更改鼠标指针位置。我在输入时使用 icursor 方法,但它不起作用。
当我在条目内单击时,我希望指针移动到位置 0。
from tkinter import *
from tkinter import ttk
def on_click(event):
event.widget.icursor(0) # this will not move cursor to the first place
root = Tk()
e = ttk.Entry(root)
e.pack()
e.insert(0, "Hello World")
e.bind("<1>", on_click)
root.mainloop()
所以当我在条目中单击时,我希望鼠标指针移动到第一个(icursor(0)),但它不起作用。
actullay 如果我得到鼠标指针位置 python 会看到我它在 0 位置但指针本身不在位置 0 上。
print(e.index(INSERT))
有人知道如何解决这个问题吗?
【问题讨论】:
标签: python python-3.x events tkinter tkinter-entry