Guilherme Polo <ggp...@gmail.com> added the comment:

Hi Brian (hope you are still there), the code in 31_8.tcl is not
complete so I didn't bother looking into it.

The tkdraw.py is not really correct, here is a cleaned up version that
works:

from Tkinter import Tk, Canvas, LAST, ROUND

def StrokeBegin(event):
    print "clicked at", event.x, event.y
    del stroke[:]
    tuple = (event.x, event.y)
    stroke.append(tuple)

def Stroke(event):
    tuple = (event.x, event.y)
    coords = stroke[len(stroke)-1] + tuple

    stroke.append(tuple)
    canvas.create_line(coords, tag='segments')

def StrokeEnd(event):
    canvas.delete('segments')
    if len(stroke) < 2:
        # Just a click happened
        return

    canvas.create_line(stroke, tag='line', arrow=LAST,
            joinstyle=ROUND, smooth=1)

stroke = []

root = Tk()
canvas = Canvas(root, height=400, width=500)
canvas.bind("<Button-1>", StrokeBegin)
canvas.bind("<B1-Motion>", Stroke)
canvas.bind("<ButtonRelease-1>", StrokeEnd)
canvas.pack()
root.mainloop()

----------
nosy: +gpolo
resolution:  -> invalid
status: open -> closed

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue941262>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to