#mousing_around.py # Demo mouse use in ezgraphics. # Click points, draw line successively between them from ezgraphics import GraphicsWindow width = int(input("Enter width of graphics window: ")) height = int(input("Enter height of graphics window: ")) print("In the graphics window click points with the mouse button") win = GraphicsWindow(width,height) win.setTitle("Mousing demo") win.showStatus() win.setStatus("Click points with the mouse button") canvas = win.canvas() canvas.drawText(10, 10, "Click points with the mouse button") xp,yp = win.getMouse() #get the first point as a 2-tuple (a pair of numbers) win.setStatus("("+str(xp)+","+str(yp)+") Click points with the mouse button") canvas.setColor("red") canvas.drawOval(xp-1,yp-1, 3,3) #draw a red circle at the first point while True: x,y = win.getMouse() #gets a point as a 2-tuple (a pair of numbers) win.setStatus("("+str(x)+","+str(y)+") Click points with the mouse button") canvas.setColor("red") canvas.drawOval(x-1,y-1, 3,3) canvas.setColor("black") canvas.drawLine(xp,yp, x,y) #draw a line from previous point to this point xp,yp = x,y #update previous point to this point