This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: List with Canvas.create_line Option arrow=LAST Broke
Type: behavior Stage: test needed
Components: Tkinter Versions: Python 2.6
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: loewis Nosy List: ajaksu2, bbrooks, gpolo, loewis
Priority: normal Keywords:

Created on 2004-04-24 11:31 by bbrooks, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
31_8.tcl bbrooks, 2004-04-24 11:31 TCL Canvas Stroke Drawing
tkdraw.py bbrooks, 2004-04-24 11:32 Python Canvas Stroke Drawing
Messages (5)
msg20584 - (view) Author: Brian Brooks (bbrooks) Date: 2004-04-24 11:31
I'm working on a drawing tool.  I've ported some code
over from TCL and there's one line that doesn't seem to
be working correctly.

I've attached the original TCL.  I'm also attaching the
Python that doesn't seem to work exactly right.
msg20585 - (view) Author: Brian Brooks (bbrooks) Date: 2004-04-24 11:35
Logged In: YES 
user_id=505215

The line that doesn't seem to work is in the function
StrokeEnd(event)...
   
canvas.create_line(coords,tag='line',arrow=LAST,joinstyle=ROUND,smooth=TURN_ON)

coords is a list built from x,y tuples e.g.

  [ (0,0), (1,1), (2,2) ]

msg20586 - (view) Author: Brian Brooks (bbrooks) Date: 2004-04-24 11:37
Logged In: YES 
user_id=505215

I'm running Windows 2000 SP4.
msg82048 - (view) Author: Daniel Diniz (ajaksu2) * (Python triager) Date: 2009-02-14 13:54
Not sure what the expected behavior is, or if the bug is in OP's code.
msg84331 - (view) Author: Guilherme Polo (gpolo) * (Python committer) Date: 2009-03-28 20:03
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()
History
Date User Action Args
2022-04-11 14:56:03adminsetgithub: 40185
2009-03-28 20:03:03gpolosetstatus: open -> closed

nosy: + gpolo
messages: + msg84331

resolution: not a bug
2009-02-14 13:54:12ajaksu2setnosy: + ajaksu2
stage: test needed
type: behavior
messages: + msg82048
versions: + Python 2.6, - Python 2.3
2004-04-24 11:31:43bbrookscreate