diff options
author | Marion <marion.zepf@gmail.com> | 2013-09-08 14:12:50 (GMT) |
---|---|---|
committer | Marion <marion.zepf@gmail.com> | 2013-09-08 14:12:50 (GMT) |
commit | dfebf0be36908618c3b23839557dea93810b1198 (patch) | |
tree | 1e9e57273127cbc23e3847e6d3df2427201fdfc1 /plugins | |
parent | 7fe3c377a730a75e15b5d7c23c7ba2f746e0396c (diff) |
Primitives for all constant blocks (add screen dimensions, update colors)
- Use the get() method of the CONSTANTS dict to retrieve the values of
constants, but export it as CONSTANTS['key'].
- Introduce the new class TypedSubscript for Subscript ASTs with a type.
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/turtle_blocks_extras/turtle_blocks_extras.py | 48 |
1 files changed, 36 insertions, 12 deletions
diff --git a/plugins/turtle_blocks_extras/turtle_blocks_extras.py b/plugins/turtle_blocks_extras/turtle_blocks_extras.py index 041dc24..8538d89 100644 --- a/plugins/turtle_blocks_extras/turtle_blocks_extras.py +++ b/plugins/turtle_blocks_extras/turtle_blocks_extras.py @@ -880,7 +880,9 @@ Journal objects')) prim_name='lpos', logo_command='lpos', help_string=_('xcor of left of screen')) - self.tw.lc.def_prim('lpos', 0, lambda self: CONSTANTS['leftpos']) + self.tw.lc.def_prim('lpos', 0, + Primitive(CONSTANTS.get, return_type=TYPE_INT, + arg_descs=[ConstantArg('leftpos')])) palette.add_block('bottompos', style='box-style', @@ -888,7 +890,9 @@ Journal objects')) prim_name='bpos', logo_command='bpos', help_string=_('ycor of bottom of screen')) - self.tw.lc.def_prim('bpos', 0, lambda self: CONSTANTS['bottompos']) + self.tw.lc.def_prim('bpos', 0, + Primitive(CONSTANTS.get, return_type=TYPE_INT, + arg_descs=[ConstantArg('bottompos')])) palette.add_block('width', style='box-style', @@ -896,7 +900,9 @@ Journal objects')) prim_name='hres', logo_command='width', help_string=_('the canvas width')) - self.tw.lc.def_prim('hres', 0, lambda self: CONSTANTS['width']) + self.tw.lc.def_prim('hres', 0, + Primitive(CONSTANTS.get, return_type=TYPE_INT, + arg_descs=[ConstantArg('width')])) palette.add_block('rightpos', style='box-style', @@ -904,7 +910,9 @@ Journal objects')) prim_name='rpos', logo_command='rpos', help_string=_('xcor of right of screen')) - self.tw.lc.def_prim('rpos', 0, lambda self: CONSTANTS['rightpos']) + self.tw.lc.def_prim('rpos', 0, + Primitive(CONSTANTS.get, return_type=TYPE_INT, + arg_descs=[ConstantArg('rightpos')])) palette.add_block('toppos', style='box-style', @@ -912,7 +920,9 @@ Journal objects')) prim_name='tpos', logo_command='tpos', help_string=_('ycor of top of screen')) - self.tw.lc.def_prim('tpos', 0, lambda self: CONSTANTS['toppos']) + self.tw.lc.def_prim('tpos', 0, + Primitive(CONSTANTS.get, return_type=TYPE_INT, + arg_descs=[ConstantArg('toppos')])) palette.add_block('height', style='box-style', @@ -920,7 +930,9 @@ Journal objects')) prim_name='vres', logo_command='height', help_string=_('the canvas height')) - self.tw.lc.def_prim('vres', 0, lambda self: CONSTANTS['height']) + self.tw.lc.def_prim('vres', 0, + Primitive(CONSTANTS.get, return_type=TYPE_INT, + arg_descs=[ConstantArg('height')])) palette.add_block('titlex', hidden=True, @@ -929,7 +941,9 @@ Journal objects')) label=_('title x'), logo_command='titlex', prim_name='titlex') - self.tw.lc.def_prim('titlex', 0, lambda self: CONSTANTS['titlex']) + self.tw.lc.def_prim('titlex', 0, + Primitive(CONSTANTS.get, return_type=TYPE_INT, + arg_descs=[ConstantArg('titlex')])) palette.add_block('titley', hidden=True, @@ -938,7 +952,9 @@ Journal objects')) label=_('title y'), logo_command='titley', prim_name='titley') - self.tw.lc.def_prim('titley', 0, lambda self: CONSTANTS['titley']) + self.tw.lc.def_prim('titley', 0, + Primitive(CONSTANTS.get, return_type=TYPE_INT, + arg_descs=[ConstantArg('titley')])) palette.add_block('leftx', hidden=True, @@ -947,7 +963,9 @@ Journal objects')) label=_('left x'), prim_name='leftx', logo_command='leftx') - self.tw.lc.def_prim('leftx', 0, lambda self: CONSTANTS['leftx']) + self.tw.lc.def_prim('leftx', 0, + Primitive(CONSTANTS.get, return_type=TYPE_INT, + arg_descs=[ConstantArg('leftx')])) palette.add_block('topy', hidden=True, @@ -956,7 +974,9 @@ Journal objects')) label=_('top y'), prim_name='topy', logo_command='topy') - self.tw.lc.def_prim('topy', 0, lambda self: CONSTANTS['topy']) + self.tw.lc.def_prim('topy', 0, + Primitive(CONSTANTS.get, return_type=TYPE_INT, + arg_descs=[ConstantArg('topy')])) palette.add_block('rightx', hidden=True, @@ -965,7 +985,9 @@ Journal objects')) label=_('right x'), prim_name='rightx', logo_command='rightx') - self.tw.lc.def_prim('rightx', 0, lambda self: CONSTANTS['rightx']) + self.tw.lc.def_prim('rightx', 0, + Primitive(CONSTANTS.get, return_type=TYPE_INT, + arg_descs=[ConstantArg('rightx')])) palette.add_block('bottomy', hidden=True, @@ -974,7 +996,9 @@ Journal objects')) label=_('bottom y'), prim_name='bottomy', logo_command='bottomy') - self.tw.lc.def_prim('bottomy', 0, lambda self: CONSTANTS['bottomy']) + self.tw.lc.def_prim('bottomy', 0, + Primitive(CONSTANTS.get, return_type=TYPE_INT, + arg_descs=[ConstantArg('bottomy')])) def _myblocks_palette(self): ''' User-defined macros are saved as a json-encoded file; |