sample.py
import tkinter as tk
#Draw a black dot (the larger the number, the bigger the dot)
def myMotion(mouse):
cv.create_oval(mouse.x - 1, mouse.y - 1, mouse.x + 1, mouse.y + 1, fill = "black")
win = tk.Tk()
cv = tk.Canvas(win, width = 600, height = 400)
cv.create_rectangle(0, 0, 600, 400, fill = "white")
cv.pack()
win.bind("<B1-Motion>", myMotion)
win.mainloop()
A point (small circle) is drawn at the mouse position only while the click is pressed.
Recommended Posts