Issue941262
Created on 2004-04-24 11:31 by bbrooks, last changed 2009-03-28 20:03 by gpolo.
| File name |
Uploaded |
Description |
Edit |
Remove |
|
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 |
|
|
|
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) |
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) |
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()
|
|
| Date |
User |
Action |
Args |
| 2009-03-28 20:03:03 | gpolo | set | status: open -> closed
nosy:
+ gpolo messages:
+ msg84331
resolution: invalid |
| 2009-02-14 13:54:12 | ajaksu2 | set | nosy:
+ ajaksu2 stage: test needed type: behavior messages:
+ msg82048 versions:
+ Python 2.6, - Python 2.3 |
| 2004-04-24 11:31:43 | bbrooks | create | |
|