From 11f1d6744b229f9e8b5983880be288e14347c31c Mon Sep 17 00:00:00 2001 From: Walter Bender Date: Thu, 03 Mar 2011 03:26:32 +0000 Subject: pylint cleanup --- diff --git a/TurtleArt/tabasics.py b/TurtleArt/tabasics.py index 14ea499..984a839 100644 --- a/TurtleArt/tabasics.py +++ b/TurtleArt/tabasics.py @@ -40,7 +40,7 @@ make the following changes: # def_prim takes 3 arguments: the primitive name, the number of # of arguments, 0 in this case, and the function to call, in this # case, the canvas function to set the heading. - self.tw.lc._def_prim('uturn', 0, + self.tw.lc.def_prim('uturn', 0, lambda self, x: self.tw.canvas.seth(self.tw.canvas.heading + 180)) That's it. When you next run Turtle Art, you will have a 'uturn' block @@ -66,9 +66,9 @@ from random import uniform from gettext import gettext as _ -from taprimitive import Palette, Primitive, make_prim -from talogo import PLUGIN_DICTIONARY, VALUE_BLOCKS, logoerror -from taconstants import DEFAULT_SCALE, CONSTANTS, BLACK, WHITE +from taprimitive import Palette, make_prim +from talogo import PLUGIN_DICTIONARY, logoerror +from taconstants import CONSTANTS, BLACK, WHITE from tautils import convert, chr_to_ord, round_int, strtype @@ -141,7 +141,7 @@ class Palettes(): default=100, prim_name='forward', help_string=_('moves turtle forward')) - self.tw.lc._def_prim('forward', 1, + self.tw.lc.def_prim('forward', 1, lambda self, x: PLUGIN_DICTIONARY['move']( self.tw.canvas.forward, x)) @@ -152,7 +152,7 @@ class Palettes(): prim_name='back', default=100, help_string=_('moves turtle backward')) - self.tw.lc._def_prim('back', 1, + self.tw.lc.def_prim('back', 1, lambda self, x: PLUGIN_DICTIONARY['move']( self.tw.canvas.forward, -x)) @@ -163,7 +163,7 @@ class Palettes(): label=_('clean'), prim_name='clean', help_string=_('clears the screen and reset the turtle')) - self.tw.lc._def_prim('clean', 0, + self.tw.lc.def_prim('clean', 0, lambda self: PLUGIN_DICTIONARY['clean']()) PLUGIN_DICTIONARY['right'] = self._prim_right @@ -175,7 +175,7 @@ class Palettes(): default=90, help_string=_('turns turtle counterclockwise (angle in \ degrees)')) - self.tw.lc._def_prim('right', 1, + self.tw.lc.def_prim('right', 1, lambda self, x: PLUGIN_DICTIONARY['right'](-x)) make_prim('right', @@ -185,7 +185,7 @@ degrees)')) prim_name='right', default=90, help_string=_('turns turtle clockwise (angle in degrees)')) - self.tw.lc._def_prim('right', 1, + self.tw.lc.def_prim('right', 1, lambda self, x: PLUGIN_DICTIONARY['right'](x)) PLUGIN_DICTIONARY['arc'] = self._prim_arc @@ -196,7 +196,7 @@ degrees)')) prim_name='arc', default=[90, 100], help_string=_('moves turtle along an arc')) - self.tw.lc._def_prim('arc', 2, + self.tw.lc.def_prim('arc', 2, lambda self, x, y: PLUGIN_DICTIONARY['arc']( self.tw.canvas.arc, x, y)) @@ -208,7 +208,7 @@ degrees)')) default=[0, 0], help_string=_('moves turtle to position xcor, ycor; (0, 0) \ is in the center of the screen.')) - self.tw.lc._def_prim('setxy2', 2, + self.tw.lc.def_prim('setxy2', 2, lambda self, x, y: PLUGIN_DICTIONARY['move']( self.tw.canvas.setxy, x, y)) @@ -221,7 +221,7 @@ is in the center of the screen.')) default=0, help_string=_('sets the heading of the turtle (0 is towards \ the top of the screen.)')) - self.tw.lc._def_prim('seth', 1, + self.tw.lc.def_prim('seth', 1, lambda self, x: PLUGIN_DICTIONARY['set']( 'heading', self.tw.canvas.seth, x)) @@ -233,7 +233,7 @@ the top of the screen.)')) turtle (can be used in place of a number block)'), value_block=True, prim_name='xcor') - self.tw.lc._def_prim( + self.tw.lc.def_prim( 'xcor', 0, lambda self: self.tw.canvas.xcor / self.tw.coord_scale) make_prim('ycor', @@ -244,7 +244,7 @@ turtle (can be used in place of a number block)'), turtle (can be used in place of a number block)'), value_block=True, prim_name='ycor') - self.tw.lc._def_prim( + self.tw.lc.def_prim( 'ycor', 0, lambda self: self.tw.canvas.ycor / self.tw.coord_scale) make_prim('heading', @@ -255,7 +255,7 @@ turtle (can be used in place of a number block)'), (can be used in place of a number block)'), value_block=True, prim_name='heading') - self.tw.lc._def_prim( + self.tw.lc.def_prim( 'heading', 0, lambda self: self.tw.canvas.heading) # Depreciated @@ -266,7 +266,7 @@ turtle (can be used in place of a number block)'), default=[0, 0], help_string=_('moves turtle to position xcor, ycor; (0, 0) \ is in the center of the screen.')) - self.tw.lc._def_prim('setxy', 2, + self.tw.lc.def_prim('setxy', 2, lambda self, x, y: PLUGIN_DICTIONARY['move']( self.tw.canvas.setxy, x, y, pendown=False)) @@ -279,7 +279,7 @@ is in the center of the screen.')) label=_('pen up'), prim_name='penup', help_string=_('Turtle will not draw when moved.')) - self.tw.lc._def_prim('penup', 0, + self.tw.lc.def_prim('penup', 0, lambda self: self.tw.canvas.setpen(False)) make_prim('pendown', @@ -288,7 +288,7 @@ is in the center of the screen.')) label=_('pen down'), prim_name='pendown', help_string=_('Turtle will draw when moved.')) - self.tw.lc._def_prim('pendown', 0, + self.tw.lc.def_prim('pendown', 0, lambda self: self.tw.canvas.setpen(True)) make_prim('setpensize', @@ -298,7 +298,7 @@ is in the center of the screen.')) prim_name='setpensize', default=5, help_string=_('sets size of the line drawn by the turtle')) - self.tw.lc._def_prim('setpensize', 1, + self.tw.lc.def_prim('setpensize', 1, lambda self, x: PLUGIN_DICTIONARY['set']( 'pensize', self.tw.canvas.setpensize, x)) @@ -309,7 +309,7 @@ is in the center of the screen.')) prim_name='fillscreen', default=[60, 80], help_string=_('fills the background with (color, shade)')) - self.tw.lc._def_prim('fillscreen', 2, + self.tw.lc.def_prim('fillscreen', 2, lambda self, x, y: self.tw.canvas.fillscreen(x, y)) make_prim('pensize', @@ -320,7 +320,7 @@ is in the center of the screen.')) of a number block)'), value_block=True, prim_name='pensize') - self.tw.lc._def_prim('pensize', 0, lambda self: self.tw.canvas.pensize) + self.tw.lc.def_prim('pensize', 0, lambda self: self.tw.canvas.pensize) make_prim('startfill', palette='pen', @@ -329,7 +329,7 @@ of a number block)'), prim_name='startfill', help_string=_('starts filled polygon (used with end fill \ block)')) - self.tw.lc._def_prim('startfill', 0, + self.tw.lc.def_prim('startfill', 0, lambda self: self.tw.canvas.start_fill()) make_prim('stopfill', @@ -339,7 +339,7 @@ block)')) prim_name='stopfill', help_string=_('completes filled polygon (used with start \ fill block)')) - self.tw.lc._def_prim('stopfill', 0, + self.tw.lc.def_prim('stopfill', 0, lambda self: self.tw.canvas.stop_fill()) def _color_palette(self): @@ -352,7 +352,7 @@ fill block)')) prim_name='setcolor', default=0, help_string=_('sets color of the line drawn by the turtle')) - self.tw.lc._def_prim('setcolor', 1, + self.tw.lc.def_prim('setcolor', 1, lambda self, x: PLUGIN_DICTIONARY['set']( 'color', self.tw.canvas.setcolor, x)) @@ -363,7 +363,7 @@ fill block)')) prim_name='setshade', default=50, help_string=_('sets shade of the line drawn by the turtle')) - self.tw.lc._def_prim('setshade', 1, + self.tw.lc.def_prim('setshade', 1, lambda self, x: PLUGIN_DICTIONARY['set']( 'shade', self.tw.canvas.setshade, x)) @@ -375,7 +375,7 @@ fill block)')) default=100, help_string=_('sets gray level of the line drawn by the \ turtle')) - self.tw.lc._def_prim('setgray', 1, + self.tw.lc.def_prim('setgray', 1, lambda self, x: PLUGIN_DICTIONARY['set']( 'gray', self.tw.canvas.setgray, x)) @@ -387,7 +387,7 @@ turtle')) place of a number block)'), value_block=True, prim_name='color') - self.tw.lc._def_prim('color', 0, lambda self: self.tw.canvas.color) + self.tw.lc.def_prim('color', 0, lambda self: self.tw.canvas.color) make_prim('shade', palette='colors', @@ -396,7 +396,7 @@ place of a number block)'), help_string=_('holds current pen shade'), value_block=True, prim_name='shade') - self.tw.lc._def_prim('shade', 0, lambda self: self.tw.canvas.shade) + self.tw.lc.def_prim('shade', 0, lambda self: self.tw.canvas.shade) make_prim('gray', palette='colors', @@ -406,7 +406,7 @@ place of a number block)'), place of a number block)'), value_block=True, prim_name='gray') - self.tw.lc._def_prim('gray', 0, lambda self: self.tw.canvas.gray) + self.tw.lc.def_prim('gray', 0, lambda self: self.tw.canvas.gray) self._make_constant('red', 'colors', CONSTANTS['red']) self._make_constant('orange', 'colors', CONSTANTS['orange']) @@ -425,7 +425,7 @@ place of a number block)'), prim_name='settextcolor', default=0, help_string=_('sets color of text drawn by the turtle')) - self.tw.lc._def_prim('settextcolor', 1, + self.tw.lc.def_prim('settextcolor', 1, lambda self, x: self.tw.canvas.settextcolor(x)) make_prim('settextsize', @@ -434,7 +434,7 @@ place of a number block)'), prim_name='settextsize', default=0, help_string=_('sets size of text drawn by the turtle')) - self.tw.lc._def_prim('settextsize', 1, + self.tw.lc.def_prim('settextsize', 1, lambda self, x: self.tw.canvas.settextsize(x)) def _numbers_palette(self): @@ -448,7 +448,7 @@ place of a number block)'), special_name=_('plus'), prim_name='plus', help_string=_('adds two alphanumeric inputs')) - self.tw.lc._def_prim( + self.tw.lc.def_prim( 'plus', 2, lambda self, x, y: PLUGIN_DICTIONARY['plus'](x, y)) PLUGIN_DICTIONARY['minus'] = self._prim_minus @@ -460,7 +460,7 @@ place of a number block)'), prim_name='minus', help_string=_('subtracts bottom numeric input from top \ numeric input')) - self.tw.lc._def_prim( + self.tw.lc.def_prim( 'minus', 2, lambda self, x, y: PLUGIN_DICTIONARY['minus'](x, y)) PLUGIN_DICTIONARY['product'] = self._prim_product @@ -471,7 +471,7 @@ numeric input')) special_name=_('multiply'), prim_name='product', help_string=_('multiplies two numeric inputs')) - self.tw.lc._def_prim( + self.tw.lc.def_prim( 'product', 2, lambda self, x, y: PLUGIN_DICTIONARY['product'](x, y)) @@ -484,7 +484,7 @@ numeric input')) prim_name='division', help_string=_('divides top numeric input (numerator) by \ bottom numeric input (denominator)')) - self.tw.lc._def_prim( + self.tw.lc.def_prim( 'division', 2, lambda self, x, y: PLUGIN_DICTIONARY['division'](x, y)) @@ -496,7 +496,7 @@ bottom numeric input (denominator)')) special_name=_('identity'), prim_name='id', help_string=_('identity operator used for extending blocks')) - self.tw.lc._def_prim('id', 1, + self.tw.lc.def_prim('id', 1, lambda self, x: PLUGIN_DICTIONARY['id'](x)) PLUGIN_DICTIONARY['remainder'] = self._prim_mod @@ -507,7 +507,7 @@ bottom numeric input (denominator)')) special_name=_('mod'), prim_name='remainder', help_string=_('modular (remainder) operator')) - self.tw.lc._def_prim('remainder', 2, + self.tw.lc.def_prim('remainder', 2, lambda self, x, y: PLUGIN_DICTIONARY['remainder'](x, y)) PLUGIN_DICTIONARY['sqrt'] = self._prim_sqrt @@ -518,7 +518,7 @@ bottom numeric input (denominator)')) special_name=_('square root'), prim_name='sqrt', help_string=_('calculates square root')) - self.tw.lc._def_prim('sqrt', 1, + self.tw.lc.def_prim('sqrt', 1, lambda self, x: PLUGIN_DICTIONARY['sqrt'](x)) PLUGIN_DICTIONARY['random'] = self._prim_random @@ -530,7 +530,7 @@ bottom numeric input (denominator)')) prim_name='random', help_string=_('returns random number between minimum (top) \ and maximum (bottom) values')) - self.tw.lc._def_prim( + self.tw.lc.def_prim( 'random', 2, lambda self, x, y: PLUGIN_DICTIONARY['random'](x, y)) make_prim('number', @@ -550,7 +550,7 @@ operators')) special_name=_('greater than'), prim_name='greater?', help_string=_('logical greater-than operator')) - self.tw.lc._def_prim( + self.tw.lc.def_prim( 'greater?', 2, lambda self, x, y: PLUGIN_DICTIONARY['more'](x, y)) PLUGIN_DICTIONARY['less'] = self._prim_less @@ -561,7 +561,7 @@ operators')) special_name=_('less than'), prim_name='less?', help_string=_('logical less-than operator')) - self.tw.lc._def_prim( + self.tw.lc.def_prim( 'less?', 2, lambda self, x, y: PLUGIN_DICTIONARY['less'](x, y)) PLUGIN_DICTIONARY['equal'] = self._prim_equal @@ -572,7 +572,7 @@ operators')) special_name=_('equal'), prim_name='equal?', help_string=_('logical equal-to operator')) - self.tw.lc._def_prim( + self.tw.lc.def_prim( 'equal?', 2, lambda self, x, y: PLUGIN_DICTIONARY['equal'](x, y)) make_prim('not', @@ -581,7 +581,7 @@ operators')) label=_('not'), prim_name='not', help_string=_('logical NOT operator')) - self.tw.lc._def_prim('not', 1, lambda self, x: not x) + self.tw.lc.def_prim('not', 1, lambda self, x: not x) make_prim('and2', palette='numbers', @@ -590,7 +590,7 @@ operators')) prim_name='and', special_name=_('and'), help_string=_('logical AND operator')) - self.tw.lc._def_prim('not', 2, lambda self, x, y: x & y) + self.tw.lc.def_prim('not', 2, lambda self, x, y: x & y) make_prim('or2', palette='numbers', @@ -599,7 +599,7 @@ operators')) prim_name='or', special_name=_('or'), help_string=_('logical OR operator')) - self.tw.lc._def_prim('not', 2, lambda self, x, y: x | y) + self.tw.lc.def_prim('not', 2, lambda self, x, y: x | y) def _flow_palette(self): """ The basic Turtle Art flow palette """ @@ -613,7 +613,7 @@ operators')) default=1, help_string=_( 'pauses program execution a specified number of seconds')) - self.tw.lc._def_prim('wait', 1, PLUGIN_DICTIONARY['wait'], True) + self.tw.lc.def_prim('wait', 1, PLUGIN_DICTIONARY['wait'], True) PLUGIN_DICTIONARY['forever'] = self._prim_forever make_prim('forever', @@ -623,7 +623,7 @@ operators')) prim_name='forever', default=[None, 'vspace'], help_string=_('loops forever')) - self.tw.lc._def_prim('forever', 1, PLUGIN_DICTIONARY['forever'], True) + self.tw.lc.def_prim('forever', 1, PLUGIN_DICTIONARY['forever'], True) PLUGIN_DICTIONARY['repeat'] = self._prim_repeat make_prim('repeat', @@ -634,7 +634,7 @@ operators')) default=[4, None, 'vspace'], special_name=_('repeat'), help_string=_('loops specified number of times')) - self.tw.lc._def_prim('repeat', 2, PLUGIN_DICTIONARY['repeat'], True) + self.tw.lc.def_prim('repeat', 2, PLUGIN_DICTIONARY['repeat'], True) PLUGIN_DICTIONARY['if'] = self._prim_if make_prim('if', @@ -646,7 +646,7 @@ operators')) special_name=_('if then'), help_string=_('if-then operator that uses boolean \ operators from Numbers palette')) - self.tw.lc._def_prim('if', 2, PLUGIN_DICTIONARY['if'], True) + self.tw.lc.def_prim('if', 2, PLUGIN_DICTIONARY['if'], True) PLUGIN_DICTIONARY['ifelse'] = self._prim_ifelse make_prim('ifelse', @@ -658,7 +658,7 @@ operators from Numbers palette')) special_name=_('if then else'), help_string=_('if-then-else operator that uses boolean \ operators from Numbers palette')) - self.tw.lc._def_prim('ifelse', 3, PLUGIN_DICTIONARY['ifelse'], True) + self.tw.lc.def_prim('ifelse', 3, PLUGIN_DICTIONARY['ifelse'], True) make_prim('hspace', palette='flow', @@ -667,7 +667,7 @@ operators from Numbers palette')) prim_name='nop', special_name=_('horizontal space'), help_string=_('jogs stack right')) - self.tw.lc._def_prim('nop', 0, lambda self: None) + self.tw.lc.def_prim('nop', 0, lambda self: None) make_prim('vspace', palette='flow', @@ -676,7 +676,7 @@ operators from Numbers palette')) prim_name='nop', special_name=_('vertical space'), help_string=_('jogs stack down')) - self.tw.lc._def_prim('nop', 0, lambda self: None) + self.tw.lc.def_prim('nop', 0, lambda self: None) PLUGIN_DICTIONARY['stopstack'] = self._prim_stopstack make_prim('stopstack', @@ -685,7 +685,7 @@ operators from Numbers palette')) label=_('stop action'), prim_name='stopstack', help_string=_('stops current action')) - self.tw.lc._def_prim('stopstack', 0, + self.tw.lc.def_prim('stopstack', 0, lambda self: PLUGIN_DICTIONARY['stopstack']()) def _blocks_palette(self): @@ -698,7 +698,7 @@ operators from Numbers palette')) label=_('start'), prim_name='start', help_string=_('connects action to toolbar run buttons')) - self.tw.lc._def_prim('start', 0, + self.tw.lc.def_prim('start', 0, lambda self: PLUGIN_DICTIONARY['start']()) PLUGIN_DICTIONARY['setbox'] = self._prim_setbox @@ -709,7 +709,7 @@ operators from Numbers palette')) prim_name='storeinbox1', default=100, help_string=_('stores numeric value in Variable 1')) - self.tw.lc._def_prim('storeinbox1', 1, + self.tw.lc.def_prim('storeinbox1', 1, lambda self, x: PLUGIN_DICTIONARY['setbox']( 'box1', None, x)) @@ -720,7 +720,7 @@ operators from Numbers palette')) prim_name='storeinbox2', default=100, help_string=_('stores numeric value in Variable 2')) - self.tw.lc._def_prim('storeinbox2', 1, + self.tw.lc.def_prim('storeinbox2', 1, lambda self, x: PLUGIN_DICTIONARY['setbox']( 'box2', None, x)) @@ -739,7 +739,7 @@ operators from Numbers palette')) prim_name='box1', help_string=_('Variable 1 (numeric value)'), value_block=True) - self.tw.lc._def_prim('box1', 0, lambda self: self.tw.lc.boxes['box1']) + self.tw.lc.def_prim('box1', 0, lambda self: self.tw.lc.boxes['box1']) make_prim('box2', palette='blocks', @@ -748,7 +748,7 @@ operators from Numbers palette')) prim_name='box2', help_string=_('Variable 2 (numeric value)'), value_block=True) - self.tw.lc._def_prim('box2', 0, lambda self: self.tw.lc.boxes['box2']) + self.tw.lc.def_prim('box2', 0, lambda self: self.tw.lc.boxes['box2']) PLUGIN_DICTIONARY['box'] = self._prim_box make_prim('box', @@ -758,7 +758,7 @@ operators from Numbers palette')) prim_name='box', default=_('my box'), help_string=_('named variable (numeric value)')) - self.tw.lc._def_prim('box', 1, + self.tw.lc.def_prim('box', 1, lambda self, x: PLUGIN_DICTIONARY['box'](x)) make_prim('storein', @@ -768,7 +768,7 @@ operators from Numbers palette')) prim_name='storeinbox', default=[_('my box'), 100], help_string=_('stores numeric value in named variable')) - self.tw.lc._def_prim('storeinbox', 2, + self.tw.lc.def_prim('storeinbox', 2, lambda self, x, y: PLUGIN_DICTIONARY['setbox']( 'box3', x, y)) @@ -779,7 +779,7 @@ operators from Numbers palette')) prim_name='nop3', default=_('action'), help_string=_('top of nameable action stack')) - self.tw.lc._def_prim('nop3', 1, lambda self, x: None) + self.tw.lc.def_prim('nop3', 1, lambda self, x: None) make_prim('hat1', palette='blocks', @@ -787,7 +787,7 @@ operators from Numbers palette')) label=_('action 1'), prim_name='nop1', help_string=_('top of Action 1 stack')) - self.tw.lc._def_prim('nop1', 0, lambda self: None) + self.tw.lc.def_prim('nop1', 0, lambda self: None) make_prim('hat2', palette='blocks', @@ -795,7 +795,7 @@ operators from Numbers palette')) label=_('action 2'), prim_name='nop2', help_string=_('top of Action 2 stack')) - self.tw.lc._def_prim('nop2', 0, lambda self: None) + self.tw.lc.def_prim('nop2', 0, lambda self: None) PLUGIN_DICTIONARY['stack'] = self._prim_stack make_prim('stack', @@ -805,7 +805,7 @@ operators from Numbers palette')) prim_name='stack', default=_('action'), help_string=_('invokes named action stack')) - self.tw.lc._def_prim('stack', 1, PLUGIN_DICTIONARY['stack'], True) + self.tw.lc.def_prim('stack', 1, PLUGIN_DICTIONARY['stack'], True) PLUGIN_DICTIONARY['stack1'] = self._prim_stack1 make_prim('stack1', @@ -815,7 +815,7 @@ operators from Numbers palette')) prim_name='stack1', default=_('action 1'), help_string=_('invokes Action 1 stack')) - self.tw.lc._def_prim('stack1', 0, PLUGIN_DICTIONARY['stack1'], True) + self.tw.lc.def_prim('stack1', 0, PLUGIN_DICTIONARY['stack1'], True) PLUGIN_DICTIONARY['stack2'] = self._prim_stack2 make_prim('stack2', @@ -825,7 +825,7 @@ operators from Numbers palette')) prim_name='stack2', default=_('action 2'), help_string=_('invokes Action 2 stack')) - self.tw.lc._def_prim('stack2', 0, PLUGIN_DICTIONARY['stack2'], True) + self.tw.lc.def_prim('stack2', 0, PLUGIN_DICTIONARY['stack2'], True) def _trash_palette(self): """ The basic Turtle Art turtle palette """ @@ -866,28 +866,28 @@ operators from Numbers palette')) def _prim_forever(self, blklist): """ Do list forever """ while True: - self.tw.lc._icall(self.tw.lc._evline, blklist[:]) + self.tw.lc.icall(self.tw.lc.evline, blklist[:]) yield True if self.tw.lc.procstop: break - self.tw.lc._ireturn() + self.tw.lc.ireturn() yield True def _prim_if(self, boolean, blklist): """ If bool, do list """ if boolean: - self.tw.lc._icall(self.tw.lc._evline, blklist[:]) + self.tw.lc.icall(self.tw.lc.evline, blklist[:]) yield True - self.tw.lc._ireturn() + self.tw.lc.ireturn() yield True def _prim_ifelse(self, boolean, list1, list2): """ If bool, do list1, else do list2 """ if boolean: - self.tw.lc._ijmp(self.tw.lc._evline, list1[:]) + self.tw.lc.ijmp(self.tw.lc.evline, list1[:]) yield True else: - self.tw.lc._ijmp(self.tw.lc._evline, list2[:]) + self.tw.lc.ijmp(self.tw.lc.evline, list2[:]) yield True def _prim_move(self, cmd, value1, value2=None, pendown=True): @@ -903,13 +903,13 @@ operators from Numbers palette')) def _prim_repeat(self, num, blklist): """ Repeat list num times. """ - num = self.tw.lc._int(num) + num = self.tw.lc.int(num) for i in range(num): - self.tw.lc._icall(self.tw.lc._evline, blklist[:]) + self.tw.lc.icall(self.tw.lc.evline, blklist[:]) yield True if self.tw.lc.procstop: break - self.tw.lc._ireturn() + self.tw.lc.ireturn() yield True def _prim_right(self, value): @@ -943,32 +943,32 @@ operators from Numbers palette')) if 'stack3' + str(x) not in self.tw.lc.stacks or \ self.tw.lc.stacks['stack3' + str(x)] is None: raise logoerror("#nostack") - self.tw.lc._icall(self.tw.lc._evline, + self.tw.lc.icall(self.tw.lc.evline, self.tw.lc.stacks['stack3' + str(x)][:]) yield True self.tw.lc.procstop = False - self.tw.lc._ireturn() + self.tw.lc.ireturn() yield True def _prim_stack1(self): """ Process Stack 1 """ if self.tw.lc.stacks['stack1'] is None: raise logoerror("#nostack") - self.tw.lc._icall(self.tw.lc._evline, + self.tw.lc.icall(self.tw.lc.evline, self.tw.lc.stacks['stack1'][:]) yield True self.tw.lc.procstop = False - self.tw.lc._ireturn() + self.tw.lc.ireturn() yield True def _prim_stack2(self): """ Process Stack 2 """ if self.tw.lc.stacks['stack2'] is None: raise logoerror("#nostack") - self.tw.lc._icall(self.tw.lc._evline, self.tw.lc.stacks['stack2'][:]) + self.tw.lc.icall(self.tw.lc.evline, self.tw.lc.stacks['stack2'][:]) yield True self.tw.lc.procstop = False - self.tw.lc._ireturn() + self.tw.lc.ireturn() yield True def _prim_start(self): @@ -980,14 +980,14 @@ operators from Numbers palette')) """ Stop execution of a stack """ self.tw.lc.procstop = True - def _prim_wait(self, time): + def _prim_wait(self, wait_time): """ Show the turtle while we wait """ self.tw.active_turtle.show() - endtime = _millisecond() + time * 1000. + endtime = _millisecond() + wait_time * 1000. while _millisecond() < endtime: yield True self.tw.active_turtle.hide() - self.tw.lc._ireturn() + self.tw.lc.ireturn() yield True # Math primitivies @@ -1148,4 +1148,4 @@ operators from Numbers palette')) """ Factory for constant blocks """ make_prim(block_name, palette=palette_name, style='box-style', label=_(block_name), prim_name=block_name) - self.tw.lc._def_prim(block_name, 0, lambda self: constant) + self.tw.lc.def_prim(block_name, 0, lambda self: constant) diff --git a/TurtleArt/talogo.py b/TurtleArt/talogo.py index 6e714f5..373b825 100644 --- a/TurtleArt/talogo.py +++ b/TurtleArt/talogo.py @@ -30,13 +30,13 @@ from UserDict import UserDict from taconstants import TAB_LAYER, DEFAULT_SCALE, BLOCK_NAMES, \ PREFIX_DICTIONARY from tautils import get_pixbuf_from_journal, convert, data_from_file, \ - text_media_type, round_int, get_path, debug_output + text_media_type, round_int, debug_output from util.RtfParser import RtfTextOnly from gettext import gettext as _ -VALUE_BLOCKS = [] +VALUE_BLOCKS = [] # blocks whose labels are updated get added here MEDIA_BLOCKS_DICTIONARY = {} # new media blocks get added here PLUGIN_DICTIONARY = {} # new block primitives get added here @@ -94,9 +94,9 @@ class LogoCode: for p in iter(DEFPRIM): if len(DEFPRIM[p]) == 2: - self._def_prim(p, DEFPRIM[p][0], DEFPRIM[p][1]) + self.def_prim(p, DEFPRIM[p][0], DEFPRIM[p][1]) else: - self._def_prim(p, DEFPRIM[p][0], DEFPRIM[p][1], DEFPRIM[p][2]) + self.def_prim(p, DEFPRIM[p][0], DEFPRIM[p][1], DEFPRIM[p][2]) self.symtype = type(self._intern('print')) self.listtype = type([]) @@ -124,7 +124,7 @@ class LogoCode: self.gplay = None self.filepath = None self.dsobject = None - self._start_time = None + self.start_time = None # Scale factors for depreciated portfolio blocks self.title_height = int((self.tw.canvas.height / 20) * self.tw.scale) @@ -144,7 +144,7 @@ class LogoCode: stop_media(self) self.tw.active_turtle.show() - def _def_prim(self, name, args, fcn, rprim=False): + def def_prim(self, name, args, fcn, rprim=False): """ Define the primitives associated with the blocks """ sym = self._intern(name) sym.nargs, sym.fcn = args, fcn @@ -193,7 +193,7 @@ class LogoCode: code = self._blocks_to_code(blk) if run_flag: debug_output("running code: %s" % (code), self.tw.running_sugar) - self._start_time = time() + self.start_time = time() self._setup_cmd(code) if not self.tw.hide: self.tw.display_coordinates() @@ -298,7 +298,7 @@ class LogoCode: elif self.tw.interactive_mode: self.tw.toolbar_shapes['stopiton'].set_layer(TAB_LAYER) self.running = True - self._icall(self._evline, blklist) + self.icall(self.evline, blklist) yield True if self.tw.running_sugar: self.tw.activity.stop_turtle_button.set_icon("stopitoff") @@ -307,12 +307,12 @@ class LogoCode: yield False self.running = False - def _icall(self, fcn, *args): + def icall(self, fcn, *args): """ Add a function and its arguments to the program stack. """ self.istack.append(self.step) self.step = fcn(*(args)) - def _evline(self, blklist): + def evline(self, blklist): """ Evaluate a line of code from the list. """ oldiline = self.iline self.iline = blklist[:] @@ -342,7 +342,7 @@ class LogoCode: (token, self.bindex) = self.iline[1] # Process the token and any arguments. - self._icall(self._eval) + self.icall(self._eval) yield True # Time to unhighlight the current block. @@ -358,7 +358,7 @@ class LogoCode: self.tw.block_list.list[self.bindex].highlight() raise logoerror(str(self.iresult)) self.iline = oldiline - self._ireturn() + self.ireturn() if not self.tw.hide and self.tw.step_time > 0: self.tw.display_coordinates() yield True @@ -375,7 +375,7 @@ class LogoCode: # We highlight blocks here in case an error occurs... if not self.tw.hide and bindex is not None: self.tw.block_list.list[bindex].highlight() - self._icall(self._evalsym, token) + self.icall(self._evalsym, token) yield True # and unhighlight if everything was OK. if not self.tw.hide and bindex is not None: @@ -384,7 +384,7 @@ class LogoCode: else: res = token - self._ireturn(res) + self.ireturn(res) yield True def _evalsym(self, token): @@ -397,18 +397,18 @@ class LogoCode: raise logoerror("#noinput") for i in range(token.nargs): self._no_args_check() - self._icall(self._eval) + self.icall(self._eval) yield True self.arglist.append(self.iresult) if self.cfun.rprim: if type(self.cfun.fcn) == self.listtype: debug_output('evalsym rprim list: %s' % (str(token)), self.tw.running_sugar) - self._icall(self._ufuncall, self.cfun.fcn) + self.icall(self._ufuncall, self.cfun.fcn) yield True else: # print "evalsym rprim: ", token - self._icall(self.cfun.fcn, *self.arglist) + self.icall(self.cfun.fcn, *self.arglist) yield True result = None else: @@ -418,12 +418,12 @@ class LogoCode: if self.arglist is not None and result == None: raise logoerror("%s %s %s" % \ (oldcfun.name, _("did not output to"), self.cfun.name)) - self._ireturn(result) + self.ireturn(result) yield True def _ufuncall(self, body): """ ufuncall """ - self._ijmp(self._evline, body) + self.ijmp(self.evline, body) yield True def doevalstep(self): @@ -450,12 +450,12 @@ class LogoCode: return False return True - def _ireturn(self, res=None): + def ireturn(self, res=None): """ return value """ self.step = self.istack.pop() self.iresult = res - def _ijmp(self, fcn, *args): + def ijmp(self, fcn, *args): """ ijmp """ self.step = fcn(*(args)) @@ -490,7 +490,19 @@ class LogoCode: name.nargs, name.fcn = 0, body name.rprim = True - def _int(self, n): + def prim_clear(self): + """ Clear screen """ + if self.tw.gst_available: + from tagplay import stop_media + # stop_media(self) # TODO: gplay variable + self.tw.canvas.clearscreen() + self.tw.lc.scale = DEFAULT_SCALE + self.tw.lc.hidden_turtle = None + self.tw.lc.start_time = time() + for name in VALUE_BLOCKS: + self.tw.lc.update_label_value(name) + + def int(self, n): """ Raise an error if n doesn't convert to int. """ if type(n) == int: return n @@ -502,7 +514,6 @@ class LogoCode: raise logoerror("%s %s %s %s" \ % (self.cfun.name, _("doesn't like"), str(n), _("as input"))) - def find_value_blocks(self): """ Find any value blocks that may need label updates """ self.value_blocks = {} @@ -537,28 +548,28 @@ class LogoCode: self.heap.append(val) self.update_label_value('pop', self.heap[-1]) - def _x(self): + def x2tx(self): """ Convert screen coordinates to turtle coordinates """ return int(self.tw.canvas.width / 2) + int(self.tw.canvas.xcor) - def _y(self): + def y2ty(self): """ Convert screen coordinates to turtle coordinates """ return int(self.tw.canvas.height / 2) - int(self.tw.canvas.ycor) - def _w(self): - """ Convert screen coordinates to turtle coordinates """ + def wpercent(self): + """ width as a percentage of screen coordinates """ return int((self.tw.canvas.width * self.scale) / 100.) - def _h(self): - """ Convert screen coordinates to turtle coordinates """ + def hpercent(self): + """ height as a percentage of screen coordinates """ return int((self.tw.canvas.height * self.scale) / 100.) - def _insert_image(self, center=False, filepath=None): + def insert_image(self, center=False, filepath=None): """ Image only (at current x, y) """ if filepath is not None: self.filepath = filepath pixbuf = None - w, h = self._w(), self._h() + w, h = self.wpercent(), self.hpercent() if w < 1 or h < 1: return if self.dsobject is not None: @@ -580,16 +591,16 @@ class LogoCode: if pixbuf is not None: if center: self.tw.canvas.draw_pixbuf(pixbuf, 0, 0, - self._x() - int(w / 2), - self._y() - int(h / 2), w, h, + self.x2tx() - int(w / 2), + self.y2ty() - int(h / 2), w, h, self.filepath) else: - self.tw.canvas.draw_pixbuf(pixbuf, 0, 0, self._x(), self._y(), - w, h, self.filepath) + self.tw.canvas.draw_pixbuf(pixbuf, 0, 0, self.x2tx(), + self.y2ty(), w, h, self.filepath) - def _insert_desc(self, mimetype=None, description=None): + def insert_desc(self, mimetype=None, description=None): """ Description text only (at current x, y) """ - w = self._w() + w = self.wpercent() if w < 1: return text = None @@ -615,30 +626,30 @@ class LogoCode: else: text = self.filepath if text is not None: - self.tw.canvas.draw_text(text, self._x(), self._y(), + self.tw.canvas.draw_text(text, self.x2tx(), self.y2ty(), self.body_height, w) - def _media_wait(self): + def media_wait(self): """ Wait for media to stop playing """ if self.tw.gst_available: from tagplay import media_playing while(media_playing(self)): yield True - self._ireturn() + self.ireturn() yield True - def _play_sound(self): + def play_sound(self): """ Sound file from Journal """ if self.tw.gst_available: from tagplay import play_audio_from_file play_audio_from_file(self, self.filepath) - def _play_video(self): + def play_video(self): """ Movie file from Journal """ - w, h = self._w(), self._h() + w, h = self.wpercent(), self.hpercent() if w < 1 or h < 1: return if self.tw.gst_available: from tagplay import play_movie_from_file - play_movie_from_file(self, self.filepath, self._x(), self._y(), + play_movie_from_file(self, self.filepath, self.x2tx(), self.y2ty(), w, h) diff --git a/plugins/audio_sensors_plugin.py b/plugins/audio_sensors_plugin.py index a0d5c83..1e8dcb1 100644 --- a/plugins/audio_sensors_plugin.py +++ b/plugins/audio_sensors_plugin.py @@ -19,14 +19,12 @@ #OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN #THE SOFTWARE. -import gst try: from numpy import append from numpy.fft import rfft PITCH_AVAILABLE = True except: PITCH_AVAILABLE = False -import gtk from gettext import gettext as _ @@ -37,10 +35,9 @@ from audio.audiograb import AudioGrab_Unknown, AudioGrab_XO1, AudioGrab_XO15, \ from audio.ringbuffer import RingBuffer1d -from TurtleArt.taprimitive import Primitive, Palette, make_prim +from TurtleArt.taprimitive import Palette, make_prim from TurtleArt.taconstants import XO1, XO15 from TurtleArt.talogo import PLUGIN_DICTIONARY -from TurtleArt.tautils import get_path import logging _logger = logging.getLogger('turtleart-activity audio sensors plugin') @@ -96,7 +93,7 @@ class Audio_sensors_plugin(Plugin): help_string=_('raw microphone input signal'), value_block=True, prim_name='sound') - self._parent.lc._def_prim('sound', 0, + self._parent.lc.def_prim('sound', 0, lambda self: PLUGIN_DICTIONARY['sound']()) PLUGIN_DICTIONARY['volume'] = self.prim_volume @@ -107,7 +104,7 @@ class Audio_sensors_plugin(Plugin): help_string=_('microphone input volume'), value_block=True, prim_name='volume') - self._parent.lc._def_prim('volume', 0, + self._parent.lc.def_prim('volume', 0, lambda self: PLUGIN_DICTIONARY['volume']()) PLUGIN_DICTIONARY['pitch'] = self.prim_pitch @@ -126,7 +123,7 @@ class Audio_sensors_plugin(Plugin): help_string=_('microphone input pitch'), value_block=True, prim_name='pitch') - self._parent.lc._def_prim('pitch', 0, + self._parent.lc.def_prim('pitch', 0, lambda self: PLUGIN_DICTIONARY['pitch']()) if self.hw in [XO1, XO15]: @@ -138,7 +135,7 @@ class Audio_sensors_plugin(Plugin): help_string=_('microphone input resistance'), value_block=True, prim_name='resistance') - self._parent.lc._def_prim('resistance', 0, + self._parent.lc.def_prim('resistance', 0, lambda self: PLUGIN_DICTIONARY['resistance']()) PLUGIN_DICTIONARY['voltage'] = self.prim_voltage @@ -149,7 +146,7 @@ class Audio_sensors_plugin(Plugin): help_string=_('microphone input voltage'), value_block=True, prim_name='voltage') - self._parent.lc._def_prim('voltage', 0, + self._parent.lc.def_prim('voltage', 0, lambda self: PLUGIN_DICTIONARY['voltage']()) self.audio_started = False diff --git a/plugins/camera_plugin.py b/plugins/camera_plugin.py index 3fb0f21..26150f4 100644 --- a/plugins/camera_plugin.py +++ b/plugins/camera_plugin.py @@ -31,7 +31,7 @@ from camera.v4l2 import v4l2_control, V4L2_CID_AUTOGAIN, VIDIOC_G_CTRL, \ from plugin import Plugin -from TurtleArt.taprimitive import Primitive, Palette, make_prim +from TurtleArt.taprimitive import Palette, make_prim from TurtleArt.talogo import MEDIA_BLOCKS_DICTIONARY, PLUGIN_DICTIONARY from TurtleArt.tautils import get_path @@ -72,7 +72,7 @@ class Camera_plugin(Plugin): help_string=_('light level detected by camera'), value_block=True, prim_name='luminance') - self._parent.lc._def_prim('luminance', 0, + self._parent.lc.def_prim('luminance', 0, lambda self: PLUGIN_DICTIONARY['luminance'](True)) # Depreciated block @@ -85,7 +85,7 @@ class Camera_plugin(Plugin): to the stack'), value_block=True, prim_name='luminance') - self._parent.lc._def_prim('read_camera', 0, + self._parent.lc.def_prim('read_camera', 0, lambda self: PLUGIN_DICTIONARY['read_camera'](True)) MEDIA_BLOCKS_DICTIONARY['camera'] = self.prim_take_picture diff --git a/plugins/turtle_blocks_plugin.py b/plugins/turtle_blocks_plugin.py index 5bc9389..969fde8 100644 --- a/plugins/turtle_blocks_plugin.py +++ b/plugins/turtle_blocks_plugin.py @@ -30,11 +30,10 @@ except ImportError: pass from plugin import Plugin -from TurtleArt.taprimitive import Palette, Primitive, make_prim +from TurtleArt.taprimitive import Palette, make_prim from TurtleArt.talogo import PLUGIN_DICTIONARY, logoerror, \ MEDIA_BLOCKS_DICTIONARY -from TurtleArt.taconstants import DEFAULT_SCALE, CONSTANTS, BLACK, WHITE, \ - ICON_SIZE +from TurtleArt.taconstants import DEFAULT_SCALE, CONSTANTS, ICON_SIZE from TurtleArt.tautils import convert, round_int, debug_output from TurtleArt.tajail import myfunc, myfunc_import @@ -185,7 +184,7 @@ operators from Numbers palette')) default=_('text'), prim_name='show', help_string=_('draws text or show media from the Journal')) - self.tw.lc._def_prim('show', 1, + self.tw.lc.def_prim('show', 1, lambda self, x: PLUGIN_DICTIONARY['show'](x, True)) make_prim('showaligned', @@ -194,7 +193,7 @@ operators from Numbers palette')) default=_('text'), prim_name='showaligned', help_string=_('draws text or show media from the Journal')) - self.tw.lc._def_prim('showaligned', 1, + self.tw.lc.def_prim('showaligned', 1, lambda self, x: PLUGIN_DICTIONARY['show'](x, False)) # depreciated @@ -205,7 +204,7 @@ operators from Numbers palette')) default=[_('text'), 32], prim_name='write', help_string=_('draws text or show media from the Journal')) - self.tw.lc._def_prim('write', 2, + self.tw.lc.def_prim('write', 2, lambda self, x, y: PLUGIN_DICTIONARY['write'](x, y)) PLUGIN_DICTIONARY['setscale'] = self._prim_setscale @@ -216,7 +215,7 @@ operators from Numbers palette')) prim_name='setscale', default=33, help_string=_('sets the scale of media')) - self.tw.lc._def_prim('setscale', 1, + self.tw.lc.def_prim('setscale', 1, lambda self, x: PLUGIN_DICTIONARY['setscale'](x)) PLUGIN_DICTIONARY['savepix'] = self._prim_save_picture @@ -227,7 +226,7 @@ operators from Numbers palette')) prim_name='savepix', default=_('picture name'), help_string=_('saves a picture to the Sugar Journal')) - self.tw.lc._def_prim('savepix', 1, + self.tw.lc.def_prim('savepix', 1, lambda self, x: PLUGIN_DICTIONARY['savepix'](x)) PLUGIN_DICTIONARY['savesvg'] = self._prim_save_svg @@ -239,7 +238,7 @@ operators from Numbers palette')) default=_('picture name'), help_string=_('saves turtle graphics as an SVG file in the \ Sugar Journal')) - self.tw.lc._def_prim('savesvg', 1, + self.tw.lc.def_prim('savesvg', 1, lambda self, x: PLUGIN_DICTIONARY['savesvg'](x)) make_prim('scale', @@ -249,7 +248,7 @@ Sugar Journal')) prim_name='scale', value_block=True, help_string=_('holds current scale value')) - self.tw.lc._def_prim('scale', 0, lambda self: self.tw.lc.scale) + self.tw.lc.def_prim('scale', 0, lambda self: self.tw.lc.scale) make_prim('mediawait', palette='media', @@ -257,7 +256,7 @@ Sugar Journal')) label=_('media wait'), prim_name='mediawait', help_string=_('wait for current video or audio to complete')) - self.tw.lc._def_prim('mediawait', 0, self.tw.lc._media_wait, True) + self.tw.lc.def_prim('mediawait', 0, self.tw.lc.media_wait, True) def _sensor_palette(self): @@ -269,7 +268,7 @@ Sugar Journal')) prim_name='kbinput', help_string=_('query for keyboard input (results stored in \ keyboard block)')) - self.tw.lc._def_prim('kbinput', 0, + self.tw.lc.def_prim('kbinput', 0, lambda self: PLUGIN_DICTIONARY['kbinput']()) @@ -280,7 +279,7 @@ keyboard block)')) prim_name='keyboard', value_block=True, help_string=_('holds results of query-keyboard block')) - self.tw.lc._def_prim('keyboard', 0, lambda self: self.tw.lc.keyboard) + self.tw.lc.def_prim('keyboard', 0, lambda self: self.tw.lc.keyboard) PLUGIN_DICTIONARY['readpixel'] = self._prim_readpixel make_prim('readpixel', @@ -290,7 +289,7 @@ keyboard block)')) prim_name='readpixel', help_string=_('RGB color under the turtle is pushed to the \ stack')) - self.tw.lc._def_prim('readpixel', 0, + self.tw.lc.def_prim('readpixel', 0, lambda self: PLUGIN_DICTIONARY['readpixel']()) PLUGIN_DICTIONARY['see'] = self._prim_see @@ -300,7 +299,7 @@ stack')) label=_('turtle sees'), prim_name='see', help_string=_('returns the color that the turtle "sees"')) - self.tw.lc._def_prim('see', 0, + self.tw.lc.def_prim('see', 0, lambda self: PLUGIN_DICTIONARY['see']()) PLUGIN_DICTIONARY['time'] = self._prim_time @@ -312,7 +311,7 @@ stack')) value_block=True, help_string=_('elapsed time (in seconds) since program \ started')) - self.tw.lc._def_prim('time', 0, + self.tw.lc.def_prim('time', 0, lambda self: PLUGIN_DICTIONARY['time']()) def _extras_palette(self): @@ -325,7 +324,7 @@ started')) prim_name='push', help_string=_('pushes value onto FILO (first-in last-out \ heap)')) - self.tw.lc._def_prim('push', 1, + self.tw.lc.def_prim('push', 1, lambda self, x: PLUGIN_DICTIONARY['push'](x)) PLUGIN_DICTIONARY['printheap'] = self._prim_printheap @@ -336,7 +335,7 @@ heap)')) prim_name='printheap', help_string=_('shows values in FILO (first-in last-out \ heap)')) - self.tw.lc._def_prim('printheap', 0, + self.tw.lc.def_prim('printheap', 0, lambda self: PLUGIN_DICTIONARY['printheap']()) PLUGIN_DICTIONARY['clearheap'] = self._prim_emptyheap @@ -346,7 +345,7 @@ heap)')) label=_('empty heap'), prim_name='clearheap', help_string=_('emptys FILO (first-in-last-out heap)')) - self.tw.lc._def_prim('clearheap', 0, + self.tw.lc.def_prim('clearheap', 0, lambda self: PLUGIN_DICTIONARY['clearheap']()) PLUGIN_DICTIONARY['pop'] = self._prim_pop @@ -357,7 +356,7 @@ heap)')) prim_name='pop', value_block=True, help_string=_('pops value off FILO (first-in last-out heap)')) - self.tw.lc._def_prim('pop', 0, + self.tw.lc.def_prim('pop', 0, lambda self: PLUGIN_DICTIONARY['pop']()) PLUGIN_DICTIONARY['print'] = self._prim_print @@ -368,7 +367,7 @@ heap)')) prim_name='comment', default=_('comment'), help_string=_('places a comment in your code')) - self.tw.lc._def_prim('comment', 1, + self.tw.lc.def_prim('comment', 1, lambda self, x: PLUGIN_DICTIONARY['print'](x, True)) make_prim('print', @@ -378,7 +377,7 @@ heap)')) prim_name='print', help_string=_('prints value in status block at bottom of \ the screen')) - self.tw.lc._def_prim('print', 1, + self.tw.lc.def_prim('print', 1, lambda self, x: PLUGIN_DICTIONARY['print'](x, False)) PLUGIN_DICTIONARY['myfunction'] = self._prim_myfunction @@ -390,7 +389,7 @@ the screen')) default=['x', 100], help_string=_('a programmable block: used to add advanced \ single-variable math equations, e.g., sin(x)')) - self.tw.lc._def_prim('myfunction', 2, + self.tw.lc.def_prim('myfunction', 2, lambda self, f, x: PLUGIN_DICTIONARY['myfunction'](f, [x])) make_prim('myfunc2arg', @@ -400,7 +399,7 @@ single-variable math equations, e.g., sin(x)')) default=['x+y', 100, 100], help_string=_('a programmable block: used to add advanced \ multi-variable math equations, e.g., sqrt(x*x+y*y)')) - self.tw.lc._def_prim('myfunction2', 3, + self.tw.lc.def_prim('myfunction2', 3, lambda self, f, x: PLUGIN_DICTIONARY['myfunction'](f, [x, y])) make_prim('myfunc3arg', @@ -410,7 +409,7 @@ multi-variable math equations, e.g., sqrt(x*x+y*y)')) default=['x+y+z', 100, 100, 100], help_string=_('a programmable block: used to add advanced \ multi-variable math equations, e.g., sin(x+y+z)')) - self.tw.lc._def_prim('myfunction3', 4, + self.tw.lc.def_prim('myfunction3', 4, lambda self, f, x, y, z: PLUGIN_DICTIONARY['myfunction']( f, [x, y, z])) @@ -424,7 +423,7 @@ multi-variable math equations, e.g., sin(x+y+z)')) default=100, help_string=_('runs code found in the tamyblock.py module \ found in the Journal')) - self.tw.lc._def_prim('userdefined', 1, + self.tw.lc.def_prim('userdefined', 1, lambda self, x: PLUGIN_DICTIONARY['userdefined']([x])) make_prim('userdefined2args', @@ -435,7 +434,7 @@ found in the Journal')) default=[100, 100], help_string=_('runs code found in the tamyblock.py module \ found in the Journal')) - self.tw.lc._def_prim('userdefined2', 2, + self.tw.lc.def_prim('userdefined2', 2, lambda self, x, y: PLUGIN_DICTIONARY['userdefined']([x, y])) make_prim('userdefined3args', @@ -446,7 +445,7 @@ found in the Journal')) default=[100, 100, 100], help_string=_('runs code found in the tamyblock.py module \ found in the Journal')) - self.tw.lc._def_prim('userdefined3', 3, + self.tw.lc.def_prim('userdefined3', 3, lambda self, x, y, z: PLUGIN_DICTIONARY['userdefined']([x, y, z])) make_prim('cartesian', @@ -455,7 +454,7 @@ found in the Journal')) label=_('Cartesian'), prim_name='cartesian', help_string=_('displays Cartesian coordinates')) - self.tw.lc._def_prim('cartesian', 0, + self.tw.lc.def_prim('cartesian', 0, lambda self: self.tw.set_cartesian(True)) make_prim('polar', @@ -464,7 +463,7 @@ found in the Journal')) label=_('polar'), prim_name='polar', help_string=_('displays polar coordinates')) - self.tw.lc._def_prim('polar', 0, + self.tw.lc.def_prim('polar', 0, lambda self: self.tw.set_polar(True)) make_prim('addturtle', @@ -474,7 +473,7 @@ found in the Journal')) prim_name='turtle', default=1, help_string=_('chooses which turtle to command')) - self.tw.lc._def_prim('turtle', 1, + self.tw.lc.def_prim('turtle', 1, lambda self, x: self.tw.canvas.set_turtle(x)) PLUGIN_DICTIONARY['skin'] = self._prim_reskin @@ -483,7 +482,7 @@ found in the Journal')) label=_('turtle shell'), prim_name='skin', help_string=_("put a custom 'shell' on the turtle")) - self.tw.lc._def_prim('skin', 1, + self.tw.lc.def_prim('skin', 1, lambda self, x: PLUGIN_DICTIONARY['skin'](x)) # macro @@ -545,7 +544,7 @@ open')) label=_('hide blocks'), prim_name='hideblocks', help_string=_('declutters canvas by hiding blocks')) - self.tw.lc._def_prim('hideblocks', 0, lambda self: self.tw.hideblocks()) + self.tw.lc.def_prim('hideblocks', 0, lambda self: self.tw.hideblocks()) make_prim('showblocks', palette='portfolio', @@ -553,7 +552,7 @@ open')) label=_('show blocks'), prim_name='showblocks', help_string=_('restores hidden blocks')) - self.tw.lc._def_prim('showblocks', 0, lambda self: self.tw.showblocks()) + self.tw.lc.def_prim('showblocks', 0, lambda self: self.tw.showblocks()) make_prim('fullscreen', palette='portfolio', @@ -561,7 +560,7 @@ open')) label=_('full screen'), prim_name='fullscreen', help_string=_('hides the Sugar toolbars')) - self.tw.lc._def_prim('fullscreen', 0, + self.tw.lc.def_prim('fullscreen', 0, lambda self: self.tw.set_fullscreen()) PLUGIN_DICTIONARY['bulletlist'] = self._prim_list @@ -571,7 +570,7 @@ open')) prim_name='bulletlist', default=['∙ ', '∙ '], help_string=_('presentation bulleted list')) - self.tw.lc._def_prim('bulletlist', 1, + self.tw.lc.def_prim('bulletlist', 1, PLUGIN_DICTIONARY['bulletlist'], True) # macros @@ -623,7 +622,7 @@ objects')) label=_('left'), prim_name='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, lambda self: CONSTANTS['leftpos']) make_prim('bottompos', palette='portfolio', @@ -631,7 +630,7 @@ objects')) label=_('bottom'), prim_name='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, lambda self: CONSTANTS['bottompos']) make_prim('width', palette='portfolio', @@ -639,7 +638,7 @@ objects')) label=_('width'), prim_name='hres', help_string=_('the canvas width')) - self.tw.lc._def_prim('hres', 0, lambda self: CONSTANTS['width']) + self.tw.lc.def_prim('hres', 0, lambda self: CONSTANTS['width']) make_prim('rightpos', palette='portfolio', @@ -647,7 +646,7 @@ objects')) label=_('right'), prim_name='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, lambda self: CONSTANTS['rightpos']) make_prim('toppos', palette='portfolio', @@ -655,7 +654,7 @@ objects')) label=_('top'), prim_name='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, lambda self: CONSTANTS['toppos']) make_prim('height', palette='portfolio', @@ -663,43 +662,43 @@ objects')) label=_('height'), prim_name='vres', help_string=_('the canvas height')) - self.tw.lc._def_prim('vres', 0, lambda self: CONSTANTS['height']) + self.tw.lc.def_prim('vres', 0, lambda self: CONSTANTS['height']) make_prim('titlex', style='box-style', label=_('title x'), prim_name='titlex') - self.tw.lc._def_prim('titlex', 0, lambda self: CONSTANTS['titlex']) + self.tw.lc.def_prim('titlex', 0, lambda self: CONSTANTS['titlex']) make_prim('titley', style='box-style', label=_('title y'), prim_name='titley') - self.tw.lc._def_prim('titley', 0, lambda self: CONSTANTS['titley']) + self.tw.lc.def_prim('titley', 0, lambda self: CONSTANTS['titley']) make_prim('leftx', style='box-style', label=_('left x'), prim_name='leftx') - self.tw.lc._def_prim('leftx', 0, lambda self: CONSTANTS['leftx']) + self.tw.lc.def_prim('leftx', 0, lambda self: CONSTANTS['leftx']) make_prim('topy', style='box-style', label=_('top y'), prim_name='topy') - self.tw.lc._def_prim('topy', 0, lambda self: CONSTANTS['topy']) + self.tw.lc.def_prim('topy', 0, lambda self: CONSTANTS['topy']) make_prim('rightx', style='box-style', label=_('right x'), prim_name='rightx') - self.tw.lc._def_prim('rightx', 0, lambda self: CONSTANTS['rightx']) + self.tw.lc.def_prim('rightx', 0, lambda self: CONSTANTS['rightx']) make_prim('bottomy', style='box-style', label=_('bottom y'), prim_name='bottomy') - self.tw.lc._def_prim('bottomy', 0, lambda self: CONSTANTS['bottomy']) + self.tw.lc.def_prim('bottomy', 0, lambda self: CONSTANTS['bottomy']) # Block primitives @@ -724,7 +723,7 @@ objects')) def _prim_list(self, blklist): """ Expandable list block """ self._prim_showlist(blklist) - self.tw.lc._ireturn() + self.tw.lc.ireturn() yield True def _prim_myblock(self, x): @@ -917,7 +916,7 @@ objects')) debug_output("Couldn't open %s" % (string[6:]), self.tw.running_sugar) elif string[0:6] == 'media_': - self.tw.lc._insert_image(center) + self.tw.lc.insert_image(center) elif string[0:6] == 'descr_': mimetype = None if self.tw.lc.dsobject is not None and \ @@ -927,15 +926,15 @@ objects')) if self.tw.lc.dsobject is not None and \ 'description' in self.tw.lc.dsobject.metadata: description = self.tw.lc.dsobject.metadata['description'] - self.tw.lc._insert_desc(mimetype, description) + self.tw.lc.insert_desc(mimetype, description) elif string[0:6] == 'audio_': - self.tw.lc._play_sound() + self.tw.lc.play_sound() elif string[0:6] == 'video_': - self.tw.lc._play_video() + self.tw.lc.play_video() if self.tw.lc.dsobject is not None: self.tw.lc.dsobject.destroy() else: # assume it is text to display - x, y = self.tw.lc._x(), self.tw.lc._y() + x, y = self.tw.lc.x2tx(), self.tw.lc.y2ty() if center: y -= self.tw.canvas.textsize self.tw.canvas.draw_text(string, x, y, @@ -944,7 +943,7 @@ objects')) self.tw.canvas.width - x) elif type(string) == float or type(string) == int: string = round_int(string) - x, y = self.tw.lc._x(), self.tw.lc._y() + x, y = self.tw.lc.x2tx(), self.tw.lc.y2ty() if center: y -= self.tw.canvas.textsize self.tw.canvas.draw_text(string, x, y, @@ -965,7 +964,7 @@ objects')) def _prim_time(self): """ Number of seconds since program execution has started or clean (prim_clear) block encountered """ - elapsed_time = int(time() - self.tw.lc._start_time) + elapsed_time = int(time() - self.tw.lc.start_time) self.tw.lc.update_label_value('time', elapsed_time) return elapsed_time -- cgit v0.9.1