[Tutor] click and line
Chris F.A. Johnson
cfaj at freeshell.org
Mon Nov 7 05:43:08 CET 2005
On Sun, 6 Nov 2005, Shi Mu wrote:
> based on the following rewritten code, why the lines still can not be
> drawn? (there is no error report and the canvas appears).
It works for me.
> from Tkinter import *
>
> root = Tk()
>
> c = Canvas(root, bg='#0e2e0e', height=500, width=1000)
>
> lastX=""
> lastY=""
> def click(event):
> global lastX, lastY
> if lastX != "":
> c.create_line(lastX,lastY,event.x,event.y,fill="white")
> lastX = event.x
> lastY = event.y
>
> frame = c
> c.bind('<Button-1>',click)
>
> c.pack()
>
> root.mainloop()
--
Chris F.A. Johnson <http://cfaj.freeshell.org>
==================================================================
Shell Scripting Recipes: A Problem-Solution Approach, 2005, Apress
<http://www.torfree.net/~chris/books/cfaj/ssr.html>
More information about the Tutor
mailing list