Open
Description
Feature or enhancement
Proposal:
The turtle.pensize doc says:
turtle.pensize(width=None)
Parameters:
width – a positive number
However, if you put a non-positive number, the function will accept it without any error or warning.
Afterwards, a draw action (like forward) will raise an exception. See below.
>>> import turtle
>>> turtle.pensize(-1)
>>> turtle.forward(100)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<string>", line 8, in forward
File "/home/adorilson/anaconda3/lib/python3.12/turtle.py", line 1636, in forward
self._go(distance)
File "/home/adorilson/anaconda3/lib/python3.12/turtle.py", line 1597, in _go
self._goto(ende)
File "/home/adorilson/anaconda3/lib/python3.12/turtle.py", line 3248, in _goto
screen._drawline(self.drawingLineItem,
File "/home/adorilson/anaconda3/lib/python3.12/turtle.py", line 543, in _drawline
self.cv.itemconfigure(lineitem, width=width)
File "<string>", line 1, in itemconfigure
File "/home/adorilson/anaconda3/lib/python3.12/tkinter/__init__.py", line 2988, in itemconfigure
return self._configure(('itemconfigure', tagOrId), cnf, kw)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/adorilson/anaconda3/lib/python3.12/tkinter/__init__.py", line 1712, in _configure
self.tk.call(_flatten((self._w, cmd)) + self._options(cnf))
_tkinter.TclError: bad screen distance "-1"
>>>
My suggestion is pensize
(and probably others) raises a TurtleGraphicsError
if the width
argument is less than 1.
Has this already been discussed elsewhere?
No response given
Links to previous discussion of this feature:
https://discuss.python.org/t/improving-the-turtle-library/61840/18
Metadata
Metadata
Assignees
Projects
Status
No status