试图让鼠标指针的坐标显示在鼠标所在的画布上。这是代码。我可以让文本显示只是找不到显示鼠标本身坐标的技巧。任何帮助,将不胜感激。
from tkinter import *
width = 250
height = 250
class MainGUI:
def __init__(self):
window = Tk()
window.title("Display Cursor Position")
self.canvas = Canvas(window, bg = "white", width = width, height = height)
self.canvas.pack()
self.canvas.bind("<Button-1>", self.processMouseEvent)
self.canvas.focus_set()
window.mainloop()
def processMouseEvent(self, event):
self.canvas.create_text(event.x, event.y, text = "event.x, event.y")
#self.canvas.insert(cursorPoint)
MainGUI()