diff options
author | Pootle daemon <pootle@pootle.sugarlabs.org> | 2012-01-30 05:31:06 (GMT) |
---|---|---|
committer | Pootle daemon <pootle@pootle.sugarlabs.org> | 2012-01-30 05:31:06 (GMT) |
commit | 2b889177c21bcf2d9d60016ebdf7b49e8bd4b898 (patch) | |
tree | bef22fbb7f290d67a74add1ad9081f6f97d9ad7a | |
parent | 6032a5453d919e004e654236997319893afa6acc (diff) | |
parent | 3708e736d10ada4fdb122115cd64cfd012ee2b59 (diff) |
Merge branch 'master' of git.sugarlabs.org:turtleart/mainline
-rw-r--r-- | NEWS | 20 | ||||
-rw-r--r-- | TurtleArt/tabasics.py | 44 | ||||
-rw-r--r-- | activity/activity.info | 2 | ||||
-rw-r--r-- | icons/save-load.svg | 190 | ||||
-rw-r--r-- | plugins/turtle_blocks_extras/turtle_blocks_extras.py | 17 |
5 files changed, 271 insertions, 2 deletions
@@ -1,3 +1,23 @@ +133 + +ENHANCEMENTS: +* New translations +* Added strings used by WeDo plugin +* Added True and False blocks to Numbers palette (only for large screens) +* Added is heap empty block? +* Added support for polynomial objects in math libraries + (used by nutrition plugin) + +132 + +BUG FIX: +* Fixed problem with exporting of Logo code introduced in v131 +* Capture "special blocks" in used block list +* Fixed typo in local variables causing voltage sensing to fail with + XO 1.75 (#3297) +* Changed light-sensor power_state (deprecated) to level in python + sample code (OLPC #11485) + 131 ENHANCEMENTS: diff --git a/TurtleArt/tabasics.py b/TurtleArt/tabasics.py index 8b949da..5a158b3 100644 --- a/TurtleArt/tabasics.py +++ b/TurtleArt/tabasics.py @@ -653,7 +653,11 @@ operators')) logo_command='greater?', help_string=_('logical greater-than operator')) self.tw.lc.def_prim( - 'greater?', 2, lambda self, x, y: primitive_dictionary['more'](x, y)) + 'greater?', 2, + lambda self, x, y: primitive_dictionary['more'](x, y)) + + if self.tw.canvas.width > 1024: + self._make_constant(palette, 'true', _('True'), 1) primitive_dictionary['less'] = self._prim_less palette.add_block('less2', @@ -666,6 +670,9 @@ operators')) self.tw.lc.def_prim( 'less?', 2, lambda self, x, y: primitive_dictionary['less'](x, y)) + if self.tw.canvas.width > 1024: + self._make_constant(palette, 'false', _('False'), 0) + primitive_dictionary['equal'] = self._prim_equal palette.add_block('equal2', style='compare-style', @@ -1120,6 +1127,14 @@ variable')) def _prim_careful_divide(self, x, y): """ Raise error on divide by zero """ + if type(x) == list and _num_type(y): + z = [] + for i in range(len(x)): + try: + z.append(x[i] / y) + except ZeroDivisionError: + raise logoerror("#zerodivide") + return z try: return x / y except ZeroDivisionError: @@ -1136,6 +1151,11 @@ variable')) def _prim_equal(self, x, y): """ Numeric and logical equal """ + if type(x) == list and type(y) == list: + for i in range(len(x)): + if x[i] != y[i]: + return False + return True try: return float(x) == float(y) except ValueError: @@ -1176,6 +1196,11 @@ variable')) """ Add numbers, concat strings """ if _num_type(x) and _num_type(y): return(x + y) + elif type(x) == list and type(y) == list: + z = [] + for i in range(len(x)): + z.append(x[i] + y[i]) + return(z) else: if _num_type(x): xx = str(round_int(x)) @@ -1191,6 +1216,11 @@ variable')) """ Numerical subtraction """ if _num_type(x) and _num_type(y): return(x - y) + elif type(x) == list and type(y) == list: + z = [] + for i in range(len(x)): + z.append(x[i] - y[i]) + return(z) try: return self._string_to_num(x) - self._string_to_num(y) except TypeError: @@ -1200,6 +1230,16 @@ variable')) """ Numerical multiplication """ if _num_type(x) and _num_type(y): return(x * y) + elif type(x) == list and _num_type(y): + z = [] + for i in range(len(x)): + z.append(x[i] * y) + return(z) + elif type(y) == list and _num_type(x): + z = [] + for i in range(len(y)): + z.append(y[i] * x) + return(z) try: return self._string_to_num(x) * self._string_to_num(y) except TypeError: @@ -1260,6 +1300,8 @@ variable')) return(x) if type(x) is ord: return(int(x)) + if type(x) is list: + raise logoerror("#syntaxerror") xx = convert(x.replace(self.tw.decimal_point, '.'), float) if type(xx) is float: return xx diff --git a/activity/activity.info b/activity/activity.info index 80565d4..d304057 100644 --- a/activity/activity.info +++ b/activity/activity.info @@ -1,6 +1,6 @@ [Activity] name = Turtle Art -activity_version = 131 +activity_version = 133 license = MIT bundle_id = org.laptop.TurtleArtActivity exec = sugar-activity TurtleArtActivity.TurtleArtActivity diff --git a/icons/save-load.svg b/icons/save-load.svg new file mode 100644 index 0000000..afaec6d --- /dev/null +++ b/icons/save-load.svg @@ -0,0 +1,190 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> + +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + version="1.1" + width="49.517162" + height="50.998993" + id="svg2"> + <defs + id="defs4"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +</defs> + <metadata + id="metadata7"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + <dc:title></dc:title> + </cc:Work> + </rdf:RDF> + </metadata> + <g + transform="translate(-146.6683,-689.71929)" + id="layer1"> + <g + transform="translate(0,-1.4025637)" + id="g3406"> + <g + transform="matrix(0.55205508,0,0,0.55205508,204.78435,703.45425)" + id="g4382"> + <g + transform="translate(-80.093659,12.220029)" + id="g4308" + style="fill:none;stroke:#ffffff;stroke-opacity:1"> + <g + id="g4310" + style="fill:none;stroke:#ffffff;stroke-opacity:1"> + <path + d="m 6.736,49.002 h 24.52 c 2.225,0 3.439,-1.447 3.439,-3.441 v -27.28 c 0,-1.73 -1.732,-3.441 -3.439,-3.441 h -4.389" + id="path4312" + style="fill:none;stroke:#ffffff;stroke-width:3.5;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" /> + + </g> + + </g> + <g + transform="translate(-80.093659,12.220029)" + id="g4314" + style="fill:none;stroke:#ffffff;stroke-opacity:1"> + <g + id="g4316" + style="fill:none;stroke:#ffffff;stroke-opacity:1"> + <path + d="m 26.867,38.592 c 0,1.836 -1.345,3.201 -3.441,4.047 L 6.736,49.002 V 14.84 l 16.69,-8.599 c 2.228,-0.394 3.441,0.84 3.441,2.834 v 29.517 z" + id="path4318" + style="fill:none;stroke:#ffffff;stroke-width:3.5;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" /> + + </g> + + </g> + <path + d="m -70.669659,54.827029 c 0,0 -1.351,-0.543 -2.702,-0.543 -1.351,0 -2.703,0.543 -2.703,0.543" + id="path4320" + style="fill:none;stroke:#ffffff;stroke-width:2.25;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" /> + <path + d="m -70.669659,44.226029 c 0,0 -1.239,-0.543 -2.815,-0.543 -1.577,0 -2.59,0.543 -2.59,0.543" + id="path4322" + style="fill:none;stroke:#ffffff;stroke-width:2.25;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" /> + <path + d="m -70.669659,33.898029 c 0,0 -1.125,-0.544 -2.927,-0.544 -1.802,0 -2.478,0.544 -2.478,0.544" + id="path4324" + style="fill:none;stroke:#ffffff;stroke-width:2.25;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" /> + <line + id="line4326" + y2="23.725029" + y1="58.753029" + x2="-66.884659" + x1="-66.884659" + style="fill:none;stroke:#ffffff;stroke-width:2.25;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" /> + </g> + <g + transform="translate(0.12541438,0)" + id="g3396"> + <g + transform="matrix(1,0,0,-1,90.781727,733.42579)" + id="g4770"> + <g + transform="translate(34.0803,-1006.42)" + id="g4772"> + <polyline + transform="matrix(-0.469241,0.469241,-0.469241,-0.469241,66.2906,1019.03)" + style="fill:none;stroke:#ffffff;stroke-width:3.5;stroke-linecap:round;stroke-linejoin:round" + points="51.562,15.306 41.17,16.188 42.053,5.794" + id="polyline4774" /> + <path + d="m 39.363241,1033.1291 -0.05636,9.9115 -8.750608,0.067" + id="path4776" + style="fill:none;stroke:#ffffff;stroke-width:2.5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + </g> + </g> + <g + transform="matrix(0,-1,-1,0,211.6059,774.10486)" + id="g4770-3"> + <g + transform="translate(34.0803,-1006.42)" + id="g4772-5"> + <polyline + transform="matrix(-0.469241,0.469241,-0.469241,-0.469241,66.2906,1019.03)" + style="fill:none;stroke:#ffffff;stroke-width:3.5;stroke-linecap:round;stroke-linejoin:round" + points="51.562,15.306 41.17,16.188 42.053,5.794" + id="polyline4774-1" /> + <path + d="m 39.363241,1033.1291 -0.05636,9.9115 -8.750608,0.067" + id="path4776-7" + style="fill:none;stroke:#ffffff;stroke-width:2.5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + </g> + </g> + </g> + </g> + </g> +</svg> diff --git a/plugins/turtle_blocks_extras/turtle_blocks_extras.py b/plugins/turtle_blocks_extras/turtle_blocks_extras.py index 9369d80..0ab049a 100644 --- a/plugins/turtle_blocks_extras/turtle_blocks_extras.py +++ b/plugins/turtle_blocks_extras/turtle_blocks_extras.py @@ -435,6 +435,16 @@ last-out heap)')) define_logo_function('tapop', 'to tapop\rif emptyp :taheap [stop]\r\ make "tmp first :taheap\rmake "taheap butfirst :taheap\routput :tmp\rend\r') + primitive_dictionary['isheapempty'] = self._prim_is_heap_empty + palette.add_block('isheapempty', + style='box-style', + label=_('empty heap?'), + prim_name='isheapempty', + value_block=True, + help_string=_('returns True if heap is empty')) + self.tw.lc.def_prim('isheapempty', 0, + lambda self: primitive_dictionary['isheapempty']()) + primitive_dictionary['print'] = self._prim_print palette.add_block('comment', style='basic-style-1arg', @@ -972,6 +982,13 @@ bullets')) self.tw.lc.stop_logo() raise logoerror("#notanumber") + def _prim_is_heap_empty(self): + """ is FILO empty? """ + if len(self.tw.lc.heap) == 0: + return 1 + else: + return 0 + def _prim_pop(self): """ Pop value off of FILO """ if len(self.tw.lc.heap) == 0: |