Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/plugins/turtle_blocks_extras/turtle_blocks_extras.py
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/turtle_blocks_extras/turtle_blocks_extras.py')
-rw-r--r--plugins/turtle_blocks_extras/turtle_blocks_extras.py88
1 files changed, 19 insertions, 69 deletions
diff --git a/plugins/turtle_blocks_extras/turtle_blocks_extras.py b/plugins/turtle_blocks_extras/turtle_blocks_extras.py
index d78ba94..8f5a94d 100644
--- a/plugins/turtle_blocks_extras/turtle_blocks_extras.py
+++ b/plugins/turtle_blocks_extras/turtle_blocks_extras.py
@@ -92,7 +92,6 @@ class Turtle_blocks_extras(Plugin):
# internally expanded macro
palette.add_block('while',
- hidden=True,
style='clamp-style-boolean',
label=_('while'),
prim_name='while',
@@ -103,7 +102,6 @@ boolean operators from Numbers palette'))
# internally expanded macro
palette.add_block('until',
- hidden=True,
style='clamp-style-boolean',
label=_('until'),
prim_name='until',
@@ -114,7 +112,6 @@ boolean operators from Numbers palette'))
primitive_dictionary['clamp'] = self._prim_clamp
palette.add_block('sandwichclamp',
- hidden=True,
style='clamp-style-collapsible',
label=' ',
special_name=_('top'),
@@ -123,9 +120,10 @@ boolean operators from Numbers palette'))
self.tw.lc.def_prim('clamp', 1, primitive_dictionary['clamp'], True)
def _media_palette(self):
- palette = make_palette('flow',
- colors=["#FFC000", "#A08000"],
- help_string=_('Palette of flow operators'))
+ palette = make_palette('media',
+ colors=["#A0FF00", "#80A000"],
+ help_string=_('Palette of media objects'),
+ position=7)
palette.add_block('journal',
style='box-style-media',
@@ -140,7 +138,6 @@ boolean operators from Numbers palette'))
MEDIA_SHAPES.append('journalon')
palette.add_block('audio',
- hidden=True,
style='box-style-media',
label=' ',
special_name=_('audio'),
@@ -153,7 +150,6 @@ boolean operators from Numbers palette'))
MEDIA_SHAPES.append('audioon')
palette.add_block('video',
- hidden=True,
style='box-style-media',
label=' ',
special_name=_('video'),
@@ -166,7 +162,6 @@ boolean operators from Numbers palette'))
MEDIA_SHAPES.append('videoon')
palette.add_block('description',
- hidden=True,
style='box-style-media',
label=' ',
special_name=_('description'),
@@ -179,7 +174,6 @@ boolean operators from Numbers palette'))
MEDIA_SHAPES.append('descriptionon')
palette.add_block('string',
- hidden=True,
style='box-style',
label=_('text'),
default=_('text'),
@@ -188,7 +182,6 @@ boolean operators from Numbers palette'))
primitive_dictionary['show'] = self._prim_show
palette.add_block('show',
- hidden=True,
style='basic-style-1arg',
label=_('show'),
default=_('text'),
@@ -216,7 +209,6 @@ Journal'))
primitive_dictionary['setscale'] = self._prim_setscale
palette.add_block('setscale',
- hidden=True,
style='basic-style-1arg',
label=_('set scale'),
prim_name='setscale',
@@ -229,7 +221,6 @@ Journal'))
primitive_dictionary['savepix'] = self._prim_save_picture
palette.add_block('savepix',
- hidden=True,
style='basic-style-1arg',
label=_('save picture'),
prim_name='savepix',
@@ -241,7 +232,6 @@ Journal'))
primitive_dictionary['savesvg'] = self._prim_save_svg
palette.add_block('savesvg',
- hidden=True,
style='basic-style-1arg',
label=_('save SVG'),
prim_name='savesvg',
@@ -252,7 +242,6 @@ in the Sugar Journal'))
lambda self, x: primitive_dictionary['savesvg'](x))
palette.add_block('scale',
- hidden=True,
style='box-style',
label=_('scale'),
prim_name='scale',
@@ -262,7 +251,6 @@ in the Sugar Journal'))
self.tw.lc.def_prim('scale', 0, lambda self: self.tw.lc.scale)
palette.add_block('mediawait',
- hidden=True,
style='basic-style-extended-vertical',
label=_('media wait'),
prim_name='mediawait',
@@ -271,7 +259,6 @@ complete'))
self.tw.lc.def_prim('mediawait', 0, self.tw.lc.media_wait, True)
palette.add_block('mediastop',
- hidden=True,
style='basic-style-extended-vertical',
label=_('media stop'),
prim_name='mediastop',
@@ -279,7 +266,6 @@ complete'))
self.tw.lc.def_prim('mediastop', 0, self.tw.lc.media_stop, True)
palette.add_block('mediapause',
- hidden=True,
style='basic-style-extended-vertical',
label=_('media pause'),
prim_name='mediapause',
@@ -287,7 +273,6 @@ complete'))
self.tw.lc.def_prim('mediapause', 0, self.tw.lc.media_pause, True)
palette.add_block('mediaplay',
- hidden=True,
style='basic-style-extended-vertical',
label=_('media resume'),
prim_name='mediaplay',
@@ -296,7 +281,6 @@ complete'))
primitive_dictionary['speak'] = self._prim_speak
palette.add_block('speak',
- hidden=True,
style='basic-style-1arg',
label=_('speak'),
prim_name='speak',
@@ -307,7 +291,6 @@ complete'))
primitive_dictionary['sinewave'] = self._prim_sinewave
palette.add_block('sinewave',
- hidden=True,
style='basic-style-3arg',
# TRANS: pitch, duration, amplitude
label=[_('sinewave') + '\n\n', _('pitch'),
@@ -321,9 +304,10 @@ amplitude, and duration (in seconds)'))
primitive_dictionary['sinewave'](x, y, z))
def _sensor_palette(self):
- palette = make_palette('flow',
- colors=["#FFC000", "#A08000"],
- help_string=_('Palette of flow operators'))
+ palette = make_palette('sensor',
+ colors=["#FF6060", "#A06060"],
+ help_string=_('Palette of sensor blocks'),
+ position=6)
primitive_dictionary['mousebutton'] = self._prim_mouse_button
palette.add_block('mousebutton',
@@ -339,7 +323,6 @@ pressed'))
primitive_dictionary['mousebutton2'] = self._prim_mouse_button_bool
palette.add_block('mousebutton2',
- hidden=True,
style='boolean-block-style',
label=_('button down'),
prim_name='mousebutton2',
@@ -351,7 +334,6 @@ pressed'))
primitive_dictionary['mousebutton2']())
palette.add_block('mousex',
- hidden=True,
style='box-style',
label=_('mouse x'),
prim_name='mousex',
@@ -362,7 +344,6 @@ pressed'))
self.tw.mouse_x - (self.tw.canvas.width / 2))
palette.add_block('mousey',
- hidden=True,
style='box-style',
label=_('mouse y'),
prim_name='mousey',
@@ -374,7 +355,6 @@ pressed'))
primitive_dictionary['kbinput'] = self._prim_kbinput
palette.add_block('kbinput',
- hidden=True,
style='basic-style-extended-vertical',
label=_('query keyboard'),
prim_name='kbinput',
@@ -384,7 +364,6 @@ stored in keyboard block)'))
lambda self: primitive_dictionary['kbinput']())
palette.add_block('keyboard',
- hidden=True,
style='box-style',
label=_('keyboard'),
prim_name='keyboard',
@@ -421,7 +400,6 @@ block as number'))
primitive_dictionary['readpixel'] = self._prim_readpixel
palette.add_block('readpixel',
- hidden=True,
style='basic-style-extended-vertical',
label=_('read pixel'),
prim_name='readpixel',
@@ -433,7 +411,6 @@ to the stack'))
primitive_dictionary['see'] = self._prim_see
palette.add_block('see',
- hidden=True,
style='box-style',
label=_('turtle sees'),
prim_name='see',
@@ -456,11 +433,11 @@ program started'))
def _extras_palette(self):
palette = make_palette('extras',
colors=["#FF0000", "#A00000"],
- help_string=_('Palette of extra options'))
+ help_string=_('Palette of extra options'),
+ position=8)
primitive_dictionary['push'] = self._prim_push
palette.add_block('push',
- hidden=True,
style='basic-style-1arg',
#TRANS: push adds a new item to the program stack
label=_('push'),
@@ -475,7 +452,6 @@ last-out heap)'))
primitive_dictionary['printheap'] = self._prim_printheap
palette.add_block('printheap',
- hidden=True,
style='basic-style-extended-vertical',
label=_('show heap'),
prim_name='printheap',
@@ -489,7 +465,6 @@ end\n')
primitive_dictionary['clearheap'] = self._prim_emptyheap
palette.add_block('clearheap',
- hidden=True,
style='basic-style-extended-vertical',
label=_('empty heap'),
prim_name='clearheap',
@@ -503,7 +478,6 @@ end\n')
primitive_dictionary['pop'] = self._prim_pop
palette.add_block('pop',
- hidden=True,
style='box-style',
#TRANS: pop removes a new item from the program stack
label=_('pop'),
@@ -530,7 +504,6 @@ make "tmp first :taheap\nmake "taheap butfirst :taheap\noutput :tmp\nend\n')
primitive_dictionary['isheapempty2'] = self._prim_is_heap_empty_bool
palette.add_block('isheapempty2',
- hidden=True,
style='boolean-block-style',
label=_('empty heap?'),
prim_name='isheapempty2',
@@ -542,7 +515,6 @@ make "tmp first :taheap\nmake "taheap butfirst :taheap\noutput :tmp\nend\n')
primitive_dictionary['print'] = self._prim_print
palette.add_block('comment',
- hidden=True,
style='basic-style-1arg',
label=_('comment'),
prim_name='comment',
@@ -567,7 +539,6 @@ bottom of the screen'))
primitive_dictionary['chr'] = self._prim_chr
palette.add_block('chr',
- hidden=True,
style='number-style-1arg',
label='chr',
prim_name='chr',
@@ -577,7 +548,6 @@ bottom of the screen'))
primitive_dictionary['int'] = self._prim_int
palette.add_block('int',
- hidden=True,
style='number-style-1arg',
label='int',
prim_name='int',
@@ -587,7 +557,6 @@ bottom of the screen'))
primitive_dictionary['myfunction'] = self._prim_myfunction
palette.add_block('myfunc1arg',
- hidden=True,
style='number-style-var-arg',
label=[_('Python'), 'f(x)', 'x'],
prim_name='myfunction',
@@ -629,7 +598,6 @@ advanced multi-variable math equations, e.g., sin(x+y+z)'))
primitive_dictionary['userdefined'] = self._prim_myblock
palette.add_block('userdefined',
- hidden=True,
style='basic-style-var-arg',
label=' ',
prim_name='userdefined',
@@ -698,7 +666,6 @@ module found in the Journal'))
lambda self: self.tw.set_polar(True))
palette.add_block('addturtle',
- hidden=True,
style='basic-style-1arg',
label=_('turtle'),
prim_name='turtle',
@@ -711,7 +678,6 @@ module found in the Journal'))
primitive_dictionary['activeturtle'] = self._prim_active_turtle
palette.add_block('activeturtle',
- hidden=True,
style='box-style',
#TRANS: pop removes a new item from the program stack
label=_('active turtle'),
@@ -736,7 +702,6 @@ module found in the Journal'))
# macro
palette.add_block('reskin',
- hidden=True,
style='basic-style-1arg',
label=_('turtle shell'),
help_string=_("put a custom 'shell' on the turtle"))
@@ -751,7 +716,6 @@ module found in the Journal'))
primitive_dictionary['loadblock'] = self._prim_load_block
palette.add_block('loadblock',
- hidden=True,
style='basic-style-var-arg',
label=_('load'),
prim_name='loadblock',
@@ -762,8 +726,8 @@ module found in the Journal'))
primitive_dictionary['loadblock'](x))
palette.add_block('loadblock2arg',
- hidden=True,
style='basic-style-var-arg',
+ hidden=True,
label=_('load'),
prim_name='loadblock2',
string_or_number=True,
@@ -774,8 +738,8 @@ module found in the Journal'))
primitive_dictionary['loadblock']([x, y]))
palette.add_block('loadblock3arg',
- hidden=True,
style='basic-style-var-arg',
+ hidden=True,
label=_('load'),
string_or_number=True,
prim_name='loadblock3',
@@ -787,7 +751,6 @@ module found in the Journal'))
primitive_dictionary['loadpalette'] = self._prim_load_palette
palette.add_block('loadpalette',
- hidden=True,
style='basic-style-1arg',
string_or_number=True,
label=_('palette'),
@@ -799,13 +762,14 @@ module found in the Journal'))
primitive_dictionary['loadpalette'](x))
def _portfolio_palette(self):
- palette = make_palette('extras',
- colors=["#FF0000", "#FF0000"],
- help_string=_('Palette of extra options'))
+ palette = make_palette('portfolio',
+ colors=["#0606FF", "#0606A0"],
+ help_string=_('Palette of presentation \
+templates'),
+ position=9)
primitive_dictionary['hideblocks'] = self._prim_hideblocks
palette.add_block('hideblocks',
- hidden=True,
style='basic-style-extended-vertical',
label=_('hide blocks'),
prim_name='hideblocks',
@@ -815,7 +779,6 @@ module found in the Journal'))
primitive_dictionary['showblocks'] = self._prim_showblocks
palette.add_block('showblocks',
- hidden=True,
style='basic-style-extended-vertical',
label=_('show blocks'),
prim_name='showblocks',
@@ -824,7 +787,6 @@ module found in the Journal'))
lambda self: primitive_dictionary['showblocks']())
palette.add_block('fullscreen',
- hidden=True,
style='basic-style-extended-vertical',
label=_('Fullscreen').lower(),
prim_name='fullscreen',
@@ -847,7 +809,6 @@ module found in the Journal'))
# macros
palette.add_block('picturelist',
- hidden=True,
style='basic-style-extended',
label=' ',
help_string=_('presentation template: list of \
@@ -855,7 +816,6 @@ bullets'))
MEDIA_SHAPES.append('list')
palette.add_block('picture1x1a',
- hidden=True,
style='basic-style-extended',
label=' ',
help_string=_('presentation template: select \
@@ -863,7 +823,6 @@ Journal object (no description)'))
MEDIA_SHAPES.append('1x1a')
palette.add_block('picture1x1',
- hidden=True,
style='basic-style-extended',
label=' ',
help_string=_('presentation template: select \
@@ -871,7 +830,6 @@ Journal object (with description)'))
MEDIA_SHAPES.append('1x1')
palette.add_block('picture2x2',
- hidden=True,
style='basic-style-extended',
label=' ',
help_string=_('presentation template: select four \
@@ -879,7 +837,6 @@ Journal objects'))
MEDIA_SHAPES.append('2x2')
palette.add_block('picture2x1',
- hidden=True,
style='basic-style-extended',
label=' ',
help_string=_('presentation template: select two \
@@ -887,7 +844,6 @@ Journal objects'))
MEDIA_SHAPES.append('2x1')
palette.add_block('picture1x2',
- hidden=True,
style='basic-style-extended',
label=' ',
help_string=_('presentation template: select two \
@@ -896,7 +852,6 @@ Journal objects'))
# Display-dependent constants
palette.add_block('leftpos',
- hidden=True,
style='box-style',
label=_('left'),
prim_name='lpos',
@@ -905,7 +860,6 @@ Journal objects'))
self.tw.lc.def_prim('lpos', 0, lambda self: CONSTANTS['leftpos'])
palette.add_block('bottompos',
- hidden=True,
style='box-style',
label=_('bottom'),
prim_name='bpos',
@@ -914,7 +868,6 @@ Journal objects'))
self.tw.lc.def_prim('bpos', 0, lambda self: CONSTANTS['bottompos'])
palette.add_block('width',
- hidden=True,
style='box-style',
label=_('width'),
prim_name='hres',
@@ -923,7 +876,6 @@ Journal objects'))
self.tw.lc.def_prim('hres', 0, lambda self: CONSTANTS['width'])
palette.add_block('rightpos',
- hidden=True,
style='box-style',
label=_('right'),
prim_name='rpos',
@@ -932,7 +884,6 @@ Journal objects'))
self.tw.lc.def_prim('rpos', 0, lambda self: CONSTANTS['rightpos'])
palette.add_block('toppos',
- hidden=True,
style='box-style',
label=_('top'),
prim_name='tpos',
@@ -941,7 +892,6 @@ Journal objects'))
self.tw.lc.def_prim('tpos', 0, lambda self: CONSTANTS['toppos'])
palette.add_block('height',
- hidden=True,
style='box-style',
label=_('height'),
prim_name='vres',
@@ -1007,7 +957,8 @@ Journal objects'))
''' User-defined macros are saved as a json-encoded file;
these get loaded into a palette on startup '''
- if os.path.exists(self.tw.macros_path):
+ if hasattr(self.tw, 'macros_path') and \
+ os.path.exists(self.tw.macros_path):
files = glob.glob(os.path.join(self.tw.macros_path, '*.tb'))
debug_output('making myblocks palette', self.tw.running_sugar)
if len(files) > 0:
@@ -1253,7 +1204,6 @@ Journal objects'))
def _prim_save_svg(self, name):
""" Save SVG to file """
- self.tw.canvas.svg_close()
self.tw.save_as_image(name, svg=True)
def _prim_speak(self, text):