From 775e480302d3cd8758aef7c8bc87e5fc6f4176ac Mon Sep 17 00:00:00 2001 From: Walter Bender Date: Wed, 02 Mar 2011 00:11:42 +0000 Subject: reinstated list block; more cleaning up --- diff --git a/TurtleArt/taconstants.py b/TurtleArt/taconstants.py index bbff803..86fd646 100644 --- a/TurtleArt/taconstants.py +++ b/TurtleArt/taconstants.py @@ -93,9 +93,9 @@ BASIC_STYLE = [] BASIC_STYLE_EXTENDED_VERTICAL = [] INVISIBLE = [] BASIC_STYLE_EXTENDED = [] -BASIC_STYLE_1ARG = ['settextsize', 'settextcolor', 'nop'] +BASIC_STYLE_1ARG = ['nop'] BASIC_STYLE_VAR_ARG = [] -BULLET_STYLE = ['templatelist', 'list'] +BULLET_STYLE = [] BASIC_STYLE_2ARG = [] BOX_STYLE = ['textsize'] BOX_STYLE_MEDIA = [] @@ -177,7 +177,7 @@ EXPANDABLE = ['vspace', 'hspace', 'identity2'] EXPANDABLE_BLOCKS = [] -EXPANDABLE_ARGS = ['templatelist', 'list', 'myfunc1arg', 'myfunc2arg', +EXPANDABLE_ARGS = ['list', 'myfunc1arg', 'myfunc2arg', 'myfunc3arg', 'userdefined', 'userdefined2args', 'userdefined3args'] # @@ -216,31 +216,17 @@ CONSTANTS = {'leftpos': None, 'toppos': None, 'rightpos': None, # # Block-name dictionary used for labels # -BLOCK_NAMES = { - 'list': ['list'], - 'myfunc': [_('Python'), 'f(x)', 'x'], - 'nop': [_(' ')], - 'settextsize': [_('set text size')], - 'textsize': [_('text size')]} +BLOCK_NAMES = {} # # Logo primitives # -# TODO: check hats (nop1, 2, 3), setxy -PRIMITIVES = { - 'list': 'bulletlist', - 'myfunc': 'myfunction', - 'nop': 'userdefined', - 'settextsize': 'settextsize', - 'textsize': 'textsize'} +PRIMITIVES = {} # # block default values # - -DEFAULTS = { - 'myfunc': ['x', 100], - 'nop': [100]} +DEFAULTS = {} # # Blocks that can interchange strings and numbers for their arguments @@ -319,8 +305,7 @@ TEMPLATES = {'t1x1': (0.5, 0.5, 0.0625, 0.125, 1.05, 0), # # Names for blocks without names for popup help # -SPECIAL_NAMES = { - 'textsize': _('text size')} +SPECIAL_NAMES = {} # # Help messages @@ -330,20 +315,14 @@ HELP_STRINGS = { 'clean': _("clears the screen and reset the turtle"), 'debugoff': _("Debug"), 'eraseron': _("Clean"), - 'myfunc': _("a programmable block: used to add advanced math equations, e.g., sin(x)"), 'next': _('displays next palette'), - 'nop': _("runs code found in the tamyblock.py module found in the Journal"), 'orientation': _("changes the orientation of the palette of blocks"), 'polar': _("displays polar coordinates"), 'run-fastoff': _("Run"), 'run-slowoff': _("Step"), 'savepix': _("saves a picture to the Sugar Journal"), 'savesvg': _("saves turtle graphics as an SVG file in the Sugar Journal"), - 'stopiton': _("Stop turtle"), - 'textcolor': _( - "holds current text color (can be used in place of a number block)"), - 'textsize': _( - "holds current text size (can be used in place of a number block)")} + 'stopiton': _("Stop turtle")} # # 'dead key' Unicode dictionaries diff --git a/plugins/turtle_blocks_plugin.py b/plugins/turtle_blocks_plugin.py index c7199f2..4570ab7 100644 --- a/plugins/turtle_blocks_plugin.py +++ b/plugins/turtle_blocks_plugin.py @@ -574,6 +574,17 @@ class Turtle_blocks_plugin(Plugin): lambda self: self.tw.set_fullscreen()) b.add_prim() + b = Primitive('list') + b.set_style('bullet-style') + b.set_label(_('list')) + b.set_prim_name('bulletlist') + b.set_help(_('')) + b.set_default(['∙ ', '∙ ']) + PLUGIN_DICTIONARY['bulletlist'] = self._prim_list + self.tw.lc._def_prim('bulletlist', 1, + PLUGIN_DICTIONARY['bulletlist'], True) + b.add_prim() + b = Primitive('picturelist') # macro b.set_palette('portfolio') b.set_style('basic-style-extended') @@ -732,6 +743,12 @@ class Turtle_blocks_plugin(Plugin): self.tw.lc.update_label_value('keyboard', self.tw.lc.keyboard) self.tw.keypress = '' + def _prim_list(self, blklist): + """ Expandable list block """ + self._prim_showlist(blklist) + self.tw.lc._ireturn() + yield True + def _prim_myblock(self, x): """ Run Python code imported from Journal """ if self.tw.lc.bindex is not None and \ @@ -957,6 +974,16 @@ class Turtle_blocks_plugin(Plugin): self.tw.lc.scale / 100.), self.tw.canvas.width - x) + + def _prim_showlist(self, sarray): + """ Display list of media objects """ + x = self.tw.canvas.xcor / self.tw.coord_scale + y = self.tw.canvas.ycor / self.tw.coord_scale + for s in sarray: + self.tw.canvas.setxy(x, y, pendown=False) + self._prim_show(s) + y -= int(self.tw.canvas.textsize * self.tw.lead) + def _prim_time(self): """ Number of seconds since program execution has started or clean (prim_clear) block encountered """ @@ -965,8 +992,26 @@ class Turtle_blocks_plugin(Plugin): return elapsed_time # Depreciated blocks - + # TODO: reinstate these blocks """ + 'myfunc': [_('Python'), 'f(x)', 'x'], + 'nop': [_(' ')], + 'settextsize': [_('set text size')], + 'textsize': [_('text size')]} + 'myfunc': ['x', 100], + 'nop': [100]} + 'nop': _("runs code found in the tamyblock.py module found in the Journal"), + 'myfunc': 'myfunction', + 'nop': 'userdefined', + 'settextsize': 'settextsize', + 'textsize': 'textsize'} + 'myfunc': _("a programmable block: used to add advanced math equations, e.g., sin(x)"), +'settextsize', 'settextcolor', + 'textsize': _('text size')} + 'textcolor': _( + "holds current text color (can be used in place of a number block)"), + 'textsize': _( + "holds current text size (can be used in place of a number block)")} PORTFOLIO_STYLE_2x2 = ['template2x2'] PORTFOLIO_STYLE_1x1 = ['template1x1', 'template1x1a'] PORTFOLIO_STYLE_2x1 = ['template2x1'] -- cgit v0.9.1