<br><br> Dear tkinter peoples,<br><br> I'm having difficulties with dash, and dashoffset;<br> Can anyone identify what I'm doing wrong?<br><br><br>- Code: ----------------------------------------------------<br>
<br>import tkinter<br><br>def move_dashes(canvas, rect, offset):<br> print("move_dashes(%s, %s, %s)" % (canvas, rect, offset))<br> canvas.itemconfigure(rect, dashoffset=offset)<br> canvas.after(1000, move_dashes, canvas, rect, offset+1)<br>
<br>def dashoffset_test():<br> # Create a canvas<br> canvas = tkinter.Canvas()<br> canvas.pack()<br> # Put a comparison rectangle on the canvas.<br> canvas.create_rectangle(7, 2, 27,28, outline="blue", dash=(5,1))<br>
# Put a rectangle on the canvas with a moving dash pattern.<br> rect = canvas.create_rectangle(10,5, 30,30, dash=(4,1))<br> canvas.after(1000, move_dashes, canvas, rect, 1)<br> canvas.mainloop()<br><br>dashoffset_test()<br>
<br>============================================================<br><br><br> Two questions:<br><br><br> 1. Why are the dash patterns so wildly different?<br> <br> canvas.create_rectangle(7, 2, 27,28, outline="blue", dash=(5,1))<br>
canvas.create_rectangle(10,5, 30,30, dash=(4,1))<br><br> The first looks like:<br><br>xxxxxxxxxxxxxxx xxxxxxxxxxxxxxx xxxxxxxxxxxxxxx<br><br> The second looks like:<br><br>xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx<br>
<br> ...and yet, it's just (5,1) vs. (4,1)<br><br> This is not what I expect from:<br> <a href="http://infohost.nmt.edu/tcc/help/pubs/tkinter/dash-patterns.html">http://infohost.nmt.edu/tcc/help/pubs/tkinter/dash-patterns.html</a><br>
<br><br> 2. Why doesn't the dash pattern move?<br><br> The call to canvas.itemconfigure(rect, dashoffset=offset)<br> looks correct; Am I doing it wrong?<br><br><br> I am using Python 3.1<br><br> Thank you,<br> Lion Kimbro<br>
<br><br>