[issue27058] Tkinter's canvas' dashed lines have incorrect segment lengths

Kevin report at bugs.python.org
Thu May 19 13:23:02 EDT 2016


Kevin added the comment:

This problem appears to go deeper than Python. On the TK bug tracker, under the issue "-dashofset option doesnt work on ms windows build" (https://core.tcl.tk/tk/tktview?name=1055974fff), a commenter mentions:

 > On Windows, only certain dash patterns and no dash offsets are supported.

Which implies that you can't create segments and gaps of arbitrary length ratios- you can only select from a limited collection of premade patterns. This comment from tkWinDraw.c (https://github.com/tcltk/tk/blob/master/win/tkWinDraw.c#L1188) supports this:

 > Below is a simple translation of serveral dash patterns to valid  windows pen types. Far from complete, but I don't know how to do it better.

The code goes on to invoke CreatePen (https://msdn.microsoft.com/en-us/library/windows/desktop/dd183509%28v=vs.85%29.aspx), which only allows for four different variations of dashed line styles.

Conclusions:
1) It isn't Python's fault.
2) The guy who wrote the Tk code was aware of the limitation at the time, so it's arguably not a bug.

So, this issue ought to be closed; not much we can do, except perhaps petition the popular Tkinter reference websites to put up a warning label on their descriptions of the `dash` keyword argument.

----------
resolution:  -> not a bug
status: open -> closed

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue27058>
_______________________________________


More information about the Python-bugs-list mailing list