turtleshell 1.0.0__tar.gz → 1.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: turtleshell
3
- Version: 1.0.0
3
+ Version: 1.2.0
4
4
  Summary: Convenience wrapper around turtle.Turtle and turtle.Screen
5
5
  Author-email: Sam Mangan <sam.mangan2@gmail.com>
6
6
  License-Expression: MIT
@@ -16,3 +16,42 @@ Requires-Dist: pytest; extra == "dev"
16
16
  # TurtleShell
17
17
 
18
18
  Convenience wrapper around Python turtle standard library.
19
+
20
+ ## Development
21
+ Do all this in a virtual environment, e.g.
22
+ ```
23
+ python3 -m venv venv
24
+ ./venv/bin/activate
25
+ ```
26
+
27
+ Test changes:
28
+ ```
29
+ pip install pytest
30
+ pytest
31
+ ```
32
+
33
+ Push changes.
34
+
35
+ Update package version:
36
+ ```
37
+ pip install bumpver
38
+ bumpver update --minor
39
+ ```
40
+
41
+ Build and check package with twine:
42
+ ```
43
+ pip install build twine
44
+ python -m build
45
+ twine check dist/*
46
+ ```
47
+
48
+ Upload to Test PyPI, install, and test:
49
+ ```
50
+ twine upload -r testpypi dist/*
51
+ pip install -i https://test.pypi.org/simple turtleshell
52
+ ```
53
+
54
+ Upload to PyPI:
55
+ ```
56
+ twine upload dist/*
57
+ ```
@@ -0,0 +1,42 @@
1
+ # TurtleShell
2
+
3
+ Convenience wrapper around Python turtle standard library.
4
+
5
+ ## Development
6
+ Do all this in a virtual environment, e.g.
7
+ ```
8
+ python3 -m venv venv
9
+ ./venv/bin/activate
10
+ ```
11
+
12
+ Test changes:
13
+ ```
14
+ pip install pytest
15
+ pytest
16
+ ```
17
+
18
+ Push changes.
19
+
20
+ Update package version:
21
+ ```
22
+ pip install bumpver
23
+ bumpver update --minor
24
+ ```
25
+
26
+ Build and check package with twine:
27
+ ```
28
+ pip install build twine
29
+ python -m build
30
+ twine check dist/*
31
+ ```
32
+
33
+ Upload to Test PyPI, install, and test:
34
+ ```
35
+ twine upload -r testpypi dist/*
36
+ pip install -i https://test.pypi.org/simple turtleshell
37
+ ```
38
+
39
+ Upload to PyPI:
40
+ ```
41
+ twine upload dist/*
42
+ ```
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "turtleshell"
3
- version = "1.0.0"
3
+ version = "1.2.0"
4
4
  authors = [
5
5
  { name="Sam Mangan", email="sam.mangan2@gmail.com" },
6
6
  ]
@@ -27,7 +27,7 @@ addopts = [
27
27
  ]
28
28
 
29
29
  [tool.bumpver]
30
- current_version = "1.0.0"
30
+ current_version = "1.2.0"
31
31
  version_pattern = "MAJOR.MINOR.PATCH"
32
32
  commit_message = "Bump version {old_version} -> {new_version}"
33
33
  commit = true
@@ -1,3 +1,3 @@
1
1
  from .core import Screen, Turtle
2
2
 
3
- __version__ = "1.0.0"
3
+ __version__ = "1.2.0"
@@ -44,6 +44,7 @@ class Turtle(turtle.RawTurtle):
44
44
 
45
45
  _pen = None
46
46
  _screen = None
47
+ MULT = 20
47
48
 
48
49
  def __init__(self,
49
50
  shape=turtle._CFG["shape"],
@@ -55,7 +56,7 @@ class Turtle(turtle.RawTurtle):
55
56
  shape=shape,
56
57
  undobuffersize=undobuffersize,
57
58
  visible=visible)
58
- self.shapesize(20)
59
+ self.shapesize(Turtle.MULT)
59
60
  self._pen_hsv = HSV(0, 1, 1)
60
61
  self._fill_hsv = HSV(0, 1, 1)
61
62
 
@@ -75,16 +76,32 @@ class Turtle(turtle.RawTurtle):
75
76
  def y(self, value):
76
77
  self.sety(value)
77
78
 
78
- @property
79
- def shapewidth(self):
80
- xcoords = [vertex[0] for vertex in self.get_shapepoly()]
81
- return max(xcoords) - min(xcoords)
79
+ def shapesize(self, stretch_wid=None, stretch_len=None, outline=None):
82
80
 
83
- @property
84
- def shapeheight(self):
85
- ycoords = [vertex[1] for vertex in self.get_shapepoly()]
86
- return max(ycoords) - min(ycoords)
81
+ if stretch_wid is None and stretch_len is None and outline is None:
82
+ stretch_wid, stretch_len, outline = super().shapesize()
83
+ return stretch_wid*Turtle.MULT, stretch_len*Turtle.MULT, outline
84
+
85
+ stretch_wid = stretch_wid/Turtle.MULT if stretch_wid else None
86
+ stretch_len = stretch_len/Turtle.MULT if stretch_len else None
87
+ ret = super().shapesize(stretch_wid, stretch_len, outline)
88
+ return ret
89
+
90
+ def teleport(self, x, y):
91
+ pendown = self.isdown()
92
+ if pendown:
93
+ self.pen(pendown=False)
94
+ self.penup()
95
+ self._position = turtle.Vec2D(x, y)
96
+ self.pen(pendown=pendown)
97
+
98
+ def write(self, arg, move=False, align="center", font=("Arial", 18, "bold")):
99
+ super().write(arg, move, align, font)
100
+
101
+ def to_front(self):
102
+ self.goto(self.position())
87
103
 
104
+ ## HSV colour methods
88
105
  def hue(self, degrees):
89
106
  self.penhue(degrees)
90
107
  self.fillhue(degrees)
@@ -121,21 +138,6 @@ class Turtle(turtle.RawTurtle):
121
138
  self._fill_hsv.val = value/100
122
139
  self.fillcolor(_hsv_to_rgb(self._fill_hsv))
123
140
 
124
- def shapesize(self, stretch_wid=None, stretch_len=None, outline=None):
125
- stretch_wid = stretch_wid/20 if stretch_wid else None
126
- stretch_len = stretch_len/20 if stretch_len else None
127
- super().shapesize(stretch_wid, stretch_len, outline)
128
-
129
- def teleport(self, x, y):
130
- pendown = self.isdown()
131
- if pendown:
132
- self.pen(pendown=False)
133
- self.penup()
134
- self._position = turtle.Vec2D(x, y)
135
- self.pen(pendown=pendown)
136
-
137
- def write(self, arg, move=False, align="center", font=("Arial", 18, "bold")):
138
- super().write(arg, move, align, font)
139
141
 
140
142
  Pen = Turtle
141
143
 
@@ -146,9 +148,7 @@ if __name__ == "__main__":
146
148
  print(f"\n\n***\nTURTLE TYPE: {type(pen)}\nSCREEN TYPE: {type(canvas)}\n***\n")
147
149
 
148
150
  pen.shape("square")
149
- print(f"{pen.shapewidth}, {pen.shapeheight}")
150
151
  pen.shapesize(30, 25)
151
- print(f"{pen.shapewidth}, {pen.shapeheight}")
152
152
 
153
153
  pen.hue(0)
154
154
  pen.stamp()
@@ -165,4 +165,4 @@ if __name__ == "__main__":
165
165
  pen.hue(240)
166
166
  pen.stamp()
167
167
 
168
- canvas.exitonclick()
168
+ canvas.exitonclick()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: turtleshell
3
- Version: 1.0.0
3
+ Version: 1.2.0
4
4
  Summary: Convenience wrapper around turtle.Turtle and turtle.Screen
5
5
  Author-email: Sam Mangan <sam.mangan2@gmail.com>
6
6
  License-Expression: MIT
@@ -16,3 +16,42 @@ Requires-Dist: pytest; extra == "dev"
16
16
  # TurtleShell
17
17
 
18
18
  Convenience wrapper around Python turtle standard library.
19
+
20
+ ## Development
21
+ Do all this in a virtual environment, e.g.
22
+ ```
23
+ python3 -m venv venv
24
+ ./venv/bin/activate
25
+ ```
26
+
27
+ Test changes:
28
+ ```
29
+ pip install pytest
30
+ pytest
31
+ ```
32
+
33
+ Push changes.
34
+
35
+ Update package version:
36
+ ```
37
+ pip install bumpver
38
+ bumpver update --minor
39
+ ```
40
+
41
+ Build and check package with twine:
42
+ ```
43
+ pip install build twine
44
+ python -m build
45
+ twine check dist/*
46
+ ```
47
+
48
+ Upload to Test PyPI, install, and test:
49
+ ```
50
+ twine upload -r testpypi dist/*
51
+ pip install -i https://test.pypi.org/simple turtleshell
52
+ ```
53
+
54
+ Upload to PyPI:
55
+ ```
56
+ twine upload dist/*
57
+ ```
@@ -25,11 +25,21 @@ def test_y(pen):
25
25
  pen.sety(200)
26
26
  assert pen.y == 200
27
27
 
28
- def test_shapesize(pen):
28
+ def test_shapesize_set(pen):
29
29
  pen.shape("square")
30
30
  pen.shapesize(30,40)
31
- assert pen.shapewidth == 30
32
- assert pen.shapeheight == 40
31
+ width, height, outline = pen.shapesize()
32
+ assert width == 30
33
+ assert height == 40
34
+ assert outline == 1
35
+
36
+ def test_shapesize_get(pen):
37
+ pen.shape("square")
38
+ pen.shapesize(30, 40, 2)
39
+ width, height, outline = pen.shapesize()
40
+ assert width == 30
41
+ assert height == 40
42
+ assert outline == 2
33
43
 
34
44
  def test_teleport(pen):
35
45
  assert pen.position() == (0, 0)
@@ -1,3 +0,0 @@
1
- # TurtleShell
2
-
3
- Convenience wrapper around Python turtle standard library.
File without changes