ColabTurtlePlus 2.0__tar.gz → 2.0.2__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.
@@ -23,6 +23,10 @@ v1.4-v1.5 uploaded to PyPI
23
23
  v2.0.0 Sept. 2021, Switched to using classes to allow for multiple turtles
24
24
  Uploaded to PyPI
25
25
 
26
+ v2.0.1 Oct. 2021
27
+ Lines drawn with drawlines() method now included in saved SVG file.
28
+ Fixes so that graphic window is still displayed when cell executed more than once in Jupyter notebook.
29
+
26
30
  """
27
31
 
28
32
  DEFAULT_WINDOW_SIZE = (800, 600)
@@ -260,12 +264,13 @@ class _Screen:
260
264
  header += ("""<rect width="100%" height="100%" style="fill:{fillcolor};stroke:{kolor};stroke-width:1" />\n""").format(
261
265
  fillcolor=self.background_color,
262
266
  kolor=self.border_color)
267
+ lines = self._svg_drawlines_string.replace("/>","/>\n")
263
268
  image = self._generateSvgLines().replace("/>","/>\n")
264
269
  stampsB = self._generateSvgStampsB().replace("</g>","</g>\n")
265
270
  stampsT = self._generateSvgStampsT().replace("</g>","</g>\n")
266
271
  dots = self._generateSvgDots().replace(">",">\n")
267
272
  turtle_svg = (self._generateTurtlesSvgDrawing() + " \n") if turtle else ""
268
- output = header + stampsB + image + dots + stampsT + turtle_svg + "</svg>"
273
+ output = header + stampsB + lines + image + dots + stampsT + turtle_svg + "</svg>"
269
274
  print(output)
270
275
 
271
276
  # Save the image as an SVG file using given filename. Set turtle=True to include turtle in svg output
@@ -297,12 +302,13 @@ class _Screen:
297
302
  header += ("""<rect width="100%" height="100%" style="fill:{fillcolor};stroke:{kolor};stroke-width:1" />\n""").format(
298
303
  fillcolor=self.background_color,
299
304
  kolor=self.border_color)
305
+ lines = self._svg_drawlines_string.replace("/>","/>\n")
300
306
  image = self._generateSvgLines().replace("/>","/>\n")
301
307
  stampsB = self._generateSvgStampsB().replace("</g>","</g>\n")
302
308
  stampsT = self._generateSvgStampsT().replace("</g>","</g>\n")
303
309
  dots = self._generateSvgDots().replace(">",">\n")
304
310
  turtle_svg = (self._generateTurtlesSvgDrawing() + " \n") if turtle else ""
305
- output = header + stampsB + image + dots + stampsT + turtle_svg + "</svg>"
311
+ output = header + stampsB + lines + image + dots + stampsT + turtle_svg + "</svg>"
306
312
  text_file.write(output)
307
313
  text_file.close()
308
314
 
@@ -587,12 +593,16 @@ class _Screen:
587
593
 
588
594
  # Clear all text and all turtles on the screen
589
595
  def clear(self):
590
- """Clears any text or drawing on the screen. Deletes all turtles.
596
+ """Clears any text or drawing in the graphics window. Deletes all turtles.
591
597
 
592
598
  No argument.
599
+
600
+ Note: clear() can only be used as a method, not a function.
593
601
 
594
- Note: This method is not available as a function. Use clearscreen.
602
+ In order to re-run turtle commands in a cell, put clearscreen() as the first
603
+ command in the cell (after the import command).
595
604
  """
605
+ if self._turtles == []: return
596
606
  for turtle in self._turtles:
597
607
  turtle.svg_lines_string = ""
598
608
  turtle.svg_fill_string = ""
@@ -607,7 +617,7 @@ class _Screen:
607
617
  self._svg_drawlines_string = ""
608
618
  self._turtles = []
609
619
  Turtle._pen = None
610
- self._updateDrawing()
620
+ Turtle._screen = None
611
621
 
612
622
  # Reset all Turtles on the Screen to their initial state.
613
623
  def reset(self):
@@ -731,7 +741,7 @@ class _Screen:
731
741
  return True
732
742
  if re.search("^#(?:[0-9a-fA-F]{3}){1,2}$", color): # 3 or 6 digit hex color code
733
743
  return True
734
- if re.search("rgb\(\s*(?:(?:\d{1,2}|1\d\d|2(?:[0-4]\d|5[0-5]))\s*,?){3}\)$", color): # rgb color code
744
+ if re.search(r"rgb\(\s*(?:(?:\d{1,2}|1\d\d|2(?:[0-4]\d|5[0-5]))\s*,?){3}\)$", color): # rgb color code
735
745
  return True
736
746
  return False
737
747
 
@@ -0,0 +1 @@
1
+ print("Put clearscreen() as the first line in a cell (after the import command) to re-run turtle commands in the cell")
@@ -1,7 +1,7 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: ColabTurtlePlus
3
- Version: 2.0
4
- Summary: An HTML based Turtle implementation for Google Colab and Jupyter Labs
3
+ Version: 2.0.2
4
+ Summary: An HTML based Turtle implementation with classes for Google Colab and Jupyter Labs
5
5
  Home-page: https://github.com/mathriddle/ColabTurtlePlus
6
6
  Author: Larry Riddle
7
7
  Author-email: lriddle@agnesscott.edu
@@ -9,15 +9,23 @@ License: MIT
9
9
  Project-URL: Bug Tracker, https://github.com/mathriddle/ColabTurtlePlus/issues
10
10
  Project-URL: Examples, https://github.com/mathriddle/ColabTurtlePlus/tree/main/examples_version2
11
11
  Project-URL: Documentation, https://larryriddle.agnesscott.org/ColabTurtlePlus/documentation2.html
12
- Platform: UNKNOWN
13
12
  Classifier: License :: OSI Approved :: MIT License
14
13
  Classifier: Programming Language :: Python :: 3
15
14
  Description-Content-Type: text/markdown
16
15
  License-File: LICENSE
16
+ Dynamic: author
17
+ Dynamic: author-email
18
+ Dynamic: classifier
19
+ Dynamic: description
20
+ Dynamic: description-content-type
21
+ Dynamic: home-page
22
+ Dynamic: license
23
+ Dynamic: license-file
24
+ Dynamic: summary
17
25
 
18
26
  # ColabTurtlePlus
19
27
 
20
- An extension of the original ColabTurtle by Tolga Atam (tolgaatam) using classes (so multiple turtle are possible). Also includes some code from jaronma ColabTurtle_2 repo.
28
+ An extension of the original ColabTurtle by Tolga Atam (tolgaatam) using classes (so multiple turtle are possible).
21
29
 
22
30
  This is a module for drawing classic Turtle figures on Google Colab notebooks. It can also be used in Jupyter Lab notebooks. The graphics are drawn using SVG tags. The SVG commands can be printed on screen (after the drawing is completed) or saved to a file for use in a program like inkscape or Adobe Illustrator, or displaying the image in a webpage.
23
31
 
@@ -37,7 +45,7 @@ Run the code cell to install the library.
37
45
 
38
46
  Usage
39
47
  ----
40
- In any code cell, import the module using
48
+ In a code cell, import the module using
41
49
 
42
50
  from ColabTurtlePlus.Turtle import *
43
51
 
@@ -46,7 +54,7 @@ Example 1
46
54
  This example uses the procedure-oriented interface.
47
55
  ```
48
56
  from ColabTurtlePlus.Turtle import *
49
- reset()
57
+ clearscreen()
50
58
  setup(300,300)
51
59
  showborder()
52
60
  color("red", "yellow")
@@ -134,7 +142,7 @@ Main differences with classic turtle.py
134
142
  ----
135
143
 
136
144
  * The circle method draws smooth arcs using SVG. The step argument is available but primarily for backward compatability with classic turtle.py circle. To get a true circular arc, do NOT use steps since the circle will be drawn using SVG commands. If steps > 20, it will be assumed that an arc of a circle was intended. While this function can still be used to draw a regular polygon with 20 or fewer sides, it is better to use the regularPolygon() turtle method to take advantage of svg commands.
137
- * A screen method to draw lines has been included.
145
+ * A screen method to draw lines independent of a turtle has been included.
138
146
  * Added getcolor function to return a color string from the list of 140 valid HTML colors that are allowed as valid colors.
139
147
  * Setting speed = 0 draws only the final image with no intermediate animations. This is usually very quick. To turn off the animation but still show the turtle motion (equivalent to speed=0 in classic turtle.py), call animationOff(). This will use the current speed, but forward/back/circle makes the turtle jump and likewise left/right makes the turtle turn instantly. Keeping consistent with the original ColabTurtle, the non-zero speed values can be from 1 to 13 (slowest to fastest).
140
148
  * There is a fillrule turtle method to set nonzero or evenodd as the options used by SVG to fill an object. The global default fill-rule is evenodd to match the behavior of classic turtle.py. The begin_fill() function can take an argument of 'nonzero' or 'evenodd' to set the fill-rule just for that fill. See details in the documentation.
@@ -143,5 +151,7 @@ Main differences with classic turtle.py
143
151
  * Not all the methods from classic turtle.py are included. Most of the missing ones are for user events, special turtle methods, and screen methods.
144
152
 
145
153
  Documentation for the methods and functions in ColabTurtlePlus can be found at <a href="https://larryriddle.agnesscott.org/ColabTurtlePlus/documentation2.html">https://larryriddle.agnesscott.org/ColabTurtlePlus/documentation2.html.
146
-
147
-
154
+
155
+ Acknowledgements
156
+ ----
157
+ Inspiration for this work came from Tolga Atam's original ColabTurtle as well as the repositories at jaronma/ColabTurtle_2, diego2500garza/ColabTurtle, and Abstrqt/ColabTurtleClass.
@@ -1,7 +1,7 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: ColabTurtlePlus
3
- Version: 2.0
4
- Summary: An HTML based Turtle implementation for Google Colab and Jupyter Labs
3
+ Version: 2.0.2
4
+ Summary: An HTML based Turtle implementation with classes for Google Colab and Jupyter Labs
5
5
  Home-page: https://github.com/mathriddle/ColabTurtlePlus
6
6
  Author: Larry Riddle
7
7
  Author-email: lriddle@agnesscott.edu
@@ -9,15 +9,23 @@ License: MIT
9
9
  Project-URL: Bug Tracker, https://github.com/mathriddle/ColabTurtlePlus/issues
10
10
  Project-URL: Examples, https://github.com/mathriddle/ColabTurtlePlus/tree/main/examples_version2
11
11
  Project-URL: Documentation, https://larryriddle.agnesscott.org/ColabTurtlePlus/documentation2.html
12
- Platform: UNKNOWN
13
12
  Classifier: License :: OSI Approved :: MIT License
14
13
  Classifier: Programming Language :: Python :: 3
15
14
  Description-Content-Type: text/markdown
16
15
  License-File: LICENSE
16
+ Dynamic: author
17
+ Dynamic: author-email
18
+ Dynamic: classifier
19
+ Dynamic: description
20
+ Dynamic: description-content-type
21
+ Dynamic: home-page
22
+ Dynamic: license
23
+ Dynamic: license-file
24
+ Dynamic: summary
17
25
 
18
26
  # ColabTurtlePlus
19
27
 
20
- An extension of the original ColabTurtle by Tolga Atam (tolgaatam) using classes (so multiple turtle are possible). Also includes some code from jaronma ColabTurtle_2 repo.
28
+ An extension of the original ColabTurtle by Tolga Atam (tolgaatam) using classes (so multiple turtle are possible).
21
29
 
22
30
  This is a module for drawing classic Turtle figures on Google Colab notebooks. It can also be used in Jupyter Lab notebooks. The graphics are drawn using SVG tags. The SVG commands can be printed on screen (after the drawing is completed) or saved to a file for use in a program like inkscape or Adobe Illustrator, or displaying the image in a webpage.
23
31
 
@@ -37,7 +45,7 @@ Run the code cell to install the library.
37
45
 
38
46
  Usage
39
47
  ----
40
- In any code cell, import the module using
48
+ In a code cell, import the module using
41
49
 
42
50
  from ColabTurtlePlus.Turtle import *
43
51
 
@@ -46,7 +54,7 @@ Example 1
46
54
  This example uses the procedure-oriented interface.
47
55
  ```
48
56
  from ColabTurtlePlus.Turtle import *
49
- reset()
57
+ clearscreen()
50
58
  setup(300,300)
51
59
  showborder()
52
60
  color("red", "yellow")
@@ -134,7 +142,7 @@ Main differences with classic turtle.py
134
142
  ----
135
143
 
136
144
  * The circle method draws smooth arcs using SVG. The step argument is available but primarily for backward compatability with classic turtle.py circle. To get a true circular arc, do NOT use steps since the circle will be drawn using SVG commands. If steps > 20, it will be assumed that an arc of a circle was intended. While this function can still be used to draw a regular polygon with 20 or fewer sides, it is better to use the regularPolygon() turtle method to take advantage of svg commands.
137
- * A screen method to draw lines has been included.
145
+ * A screen method to draw lines independent of a turtle has been included.
138
146
  * Added getcolor function to return a color string from the list of 140 valid HTML colors that are allowed as valid colors.
139
147
  * Setting speed = 0 draws only the final image with no intermediate animations. This is usually very quick. To turn off the animation but still show the turtle motion (equivalent to speed=0 in classic turtle.py), call animationOff(). This will use the current speed, but forward/back/circle makes the turtle jump and likewise left/right makes the turtle turn instantly. Keeping consistent with the original ColabTurtle, the non-zero speed values can be from 1 to 13 (slowest to fastest).
140
148
  * There is a fillrule turtle method to set nonzero or evenodd as the options used by SVG to fill an object. The global default fill-rule is evenodd to match the behavior of classic turtle.py. The begin_fill() function can take an argument of 'nonzero' or 'evenodd' to set the fill-rule just for that fill. See details in the documentation.
@@ -143,5 +151,7 @@ Main differences with classic turtle.py
143
151
  * Not all the methods from classic turtle.py are included. Most of the missing ones are for user events, special turtle methods, and screen methods.
144
152
 
145
153
  Documentation for the methods and functions in ColabTurtlePlus can be found at <a href="https://larryriddle.agnesscott.org/ColabTurtlePlus/documentation2.html">https://larryriddle.agnesscott.org/ColabTurtlePlus/documentation2.html.
146
-
147
-
154
+
155
+ Acknowledgements
156
+ ----
157
+ Inspiration for this work came from Tolga Atam's original ColabTurtle as well as the repositories at jaronma/ColabTurtle_2, diego2500garza/ColabTurtle, and Abstrqt/ColabTurtleClass.
@@ -1,6 +1,6 @@
1
1
  # ColabTurtlePlus
2
2
 
3
- An extension of the original ColabTurtle by Tolga Atam (tolgaatam) using classes (so multiple turtle are possible). Also includes some code from jaronma ColabTurtle_2 repo.
3
+ An extension of the original ColabTurtle by Tolga Atam (tolgaatam) using classes (so multiple turtle are possible).
4
4
 
5
5
  This is a module for drawing classic Turtle figures on Google Colab notebooks. It can also be used in Jupyter Lab notebooks. The graphics are drawn using SVG tags. The SVG commands can be printed on screen (after the drawing is completed) or saved to a file for use in a program like inkscape or Adobe Illustrator, or displaying the image in a webpage.
6
6
 
@@ -20,7 +20,7 @@ Run the code cell to install the library.
20
20
 
21
21
  Usage
22
22
  ----
23
- In any code cell, import the module using
23
+ In a code cell, import the module using
24
24
 
25
25
  from ColabTurtlePlus.Turtle import *
26
26
 
@@ -29,7 +29,7 @@ Example 1
29
29
  This example uses the procedure-oriented interface.
30
30
  ```
31
31
  from ColabTurtlePlus.Turtle import *
32
- reset()
32
+ clearscreen()
33
33
  setup(300,300)
34
34
  showborder()
35
35
  color("red", "yellow")
@@ -117,7 +117,7 @@ Main differences with classic turtle.py
117
117
  ----
118
118
 
119
119
  * The circle method draws smooth arcs using SVG. The step argument is available but primarily for backward compatability with classic turtle.py circle. To get a true circular arc, do NOT use steps since the circle will be drawn using SVG commands. If steps > 20, it will be assumed that an arc of a circle was intended. While this function can still be used to draw a regular polygon with 20 or fewer sides, it is better to use the regularPolygon() turtle method to take advantage of svg commands.
120
- * A screen method to draw lines has been included.
120
+ * A screen method to draw lines independent of a turtle has been included.
121
121
  * Added getcolor function to return a color string from the list of 140 valid HTML colors that are allowed as valid colors.
122
122
  * Setting speed = 0 draws only the final image with no intermediate animations. This is usually very quick. To turn off the animation but still show the turtle motion (equivalent to speed=0 in classic turtle.py), call animationOff(). This will use the current speed, but forward/back/circle makes the turtle jump and likewise left/right makes the turtle turn instantly. Keeping consistent with the original ColabTurtle, the non-zero speed values can be from 1 to 13 (slowest to fastest).
123
123
  * There is a fillrule turtle method to set nonzero or evenodd as the options used by SVG to fill an object. The global default fill-rule is evenodd to match the behavior of classic turtle.py. The begin_fill() function can take an argument of 'nonzero' or 'evenodd' to set the fill-rule just for that fill. See details in the documentation.
@@ -126,3 +126,7 @@ Main differences with classic turtle.py
126
126
  * Not all the methods from classic turtle.py are included. Most of the missing ones are for user events, special turtle methods, and screen methods.
127
127
 
128
128
  Documentation for the methods and functions in ColabTurtlePlus can be found at <a href="https://larryriddle.agnesscott.org/ColabTurtlePlus/documentation2.html">https://larryriddle.agnesscott.org/ColabTurtlePlus/documentation2.html.
129
+
130
+ Acknowledgements
131
+ ----
132
+ Inspiration for this work came from Tolga Atam's original ColabTurtle as well as the repositories at jaronma/ColabTurtle_2, diego2500garza/ColabTurtle, and Abstrqt/ColabTurtleClass.
@@ -1,9 +1,9 @@
1
1
  [metadata]
2
2
  name = ColabTurtlePlus
3
- version = 2.0
3
+ version = 2.0.2
4
4
  author = Larry Riddle
5
5
  author_email = lriddle@agnesscott.edu
6
- description = 'An HTML based Turtle implementation for Google Colab and Jupyter Labs'
6
+ description = 'An HTML based Turtle implementation with classes for Google Colab and Jupyter Labs'
7
7
  long_description = file: README.md
8
8
  long_description_content_type = text/markdown
9
9
  url = https://github.com/mathriddle/ColabTurtlePlus
@@ -9,13 +9,13 @@ README = (HERE / "README.md").read_text()
9
9
 
10
10
  setup(
11
11
  name='ColabTurtlePlus',
12
- version='2.0',
12
+ version='2.0.2',
13
13
  packages=['ColabTurtlePlus'],
14
14
  url='https://github.com/mathriddle/ColabTurtlePlus',
15
15
  license='MIT',
16
16
  author='Larry Riddle',
17
17
  author_email='lriddle@agnesscott.edu',
18
- description='An HTML based Turtle implementation for Google Colab and Jupyter Labs',
18
+ description='An HTML based Turtle implementation with classes for Google Colab and Jupyter Labs',
19
19
  long_description=README,
20
20
  long_description_content_type="text/markdown",
21
21
  classifiers=[
File without changes