Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--block.py36
-rw-r--r--constants.py56
-rw-r--r--tawindow.py2
3 files changed, 55 insertions, 39 deletions
diff --git a/block.py b/block.py
index be829e3..4ec0595 100644
--- a/block.py
+++ b/block.py
@@ -103,10 +103,7 @@ class Block:
def _new_block_from_factory(self, sprite_list, name, labels, colors,
scale, x, y):
- if len(labels) == 0:
- print "new block: %s (%d %d)" % (name, x, y)
- else:
- print "new block: %s %s (%d %d)" % (name, labels[0], x, y)
+ print "new block: %s (%d %d)" % (name, x, y)
svg = SVG()
svg.set_scale(scale)
@@ -119,10 +116,27 @@ class Block:
self._make_block(name, 0, svg)
self.spr = sprites.Sprite(sprite_list, x, y, self.shape)
-
self.spr.set_margins(self._left, 0, self._right, 0)
- if BLOCK_NAMES.has_key(name):
- self.spr.set_label(BLOCK_NAMES[name])
+
+ # if labels were passed, use them
+ if len(labels) > 0:
+ print labels
+ for i, l in enumerate(labels):
+ self.spr.set_label(l,i)
+ if i == 1: # top
+ self.spr.set_label_attributes(9, True, "right", "top", i)
+ elif i == 2: # bottom
+ self.spr.set_label_attributes(9, True, "right", "bottom", i)
+ # otherwise use default values
+ elif BLOCK_NAMES.has_key(name):
+ print BLOCK_NAMES[name]
+ for i, l in enumerate(BLOCK_NAMES[name]):
+ self.spr.set_label(l,i)
+ if i == 1: # top
+ self.spr.set_label_attributes(9, True, "right", "top", i)
+ elif i == 2: # bottom
+ self.spr.set_label_attributes(9, True, "right", "bottom", i)
+
# make sure the label fits
lw = self.spr.label_width()
lwh = self.spr.label_area_dimensions()
@@ -132,13 +146,7 @@ class Block:
self.spr.set_shape(self.shape)
"""
- # NEED TO ADD EXTRA LABELS
- if len(labels) > 0:
- if BLOCK_NAMES.has_key(name):
- self.spr.set_label(BLOCK_NAMES[name])
- for i, label in enumerate(labels):
- if i > 0:
- self.spr.set_label(label, labels[i])
+ Do something with default values?
"""
def _make_block(self, name, e, svg):
diff --git a/constants.py b/constants.py
index 2618839..cc3c56a 100644
--- a/constants.py
+++ b/constants.py
@@ -91,30 +91,38 @@ CONTENT_BLOCKS = ['number', 'string', 'media', 'audio', 'journal']
# block name dictionary
#
-BLOCK_NAMES = {'clean':_('clean'), 'forward':_('forward'), 'back':_('back'),
- 'left':_('left'), 'right':_('right'), 'set heading':_('set heading'),
- 'show':_('show'), 'set scale':_('set scale'), 'xcor':_('xcor'),
- 'ycor':_('ycor'), 'heading':_('heading'), 'pen up':_('pen up'),
- 'pen down':_('pen down'), 'set pen size':_('set pen size'), 'arc':_('arc'),
- 'set text size':_('set text size'), 'set color':_('set color'),
- 'set shade':_('set shade'), 'fill screen':_('fill screen'),
- 'shade':_('shade'),
- 'pen size':_('pen size'), 'text size':_('text size'), 'color':_('color'),
- 'plus':'+', 'minus':'–', 'multiply':'×', 'divide':'/', 'mod':_('mod'),
- 'random':_('random'), 'square root':'√', 'less than':'<',
- 'greater than':">", 'equal to':'=', 'and':_('and'), 'or':_('or'),
- 'not':_('not'), 'print':_('print'), 'wait':_('wait'),
- 'forever':_('forever'), 'repeat':_('repeat'), 'if then':_('if then'),
- 'stop action':_('stop action'), 'hspace':_(' '), 'vspace':_(' '),
- 'start':_('start'), 'def action 1':_('action 1'), 'action 1':_('action 1'),
- 'def action 2':_('action 2'), 'action 2':_('action 2'),
- 'def action':_('action'), 'action':_('action'), 'number':'100',
- 'store in box 1':_('store in box 1'), 'box 1':_('box 1'),
- 'store in box 2':_('store in box 2'), 'box 2':_('box 2'),
- 'store in':_('store in'), 'box':_('box'), 'string':_('string'),
- 'left pos':_('left'), 'top pos':_('top'), 'right pos':_('right'),
- 'bottom pos':_('bottom'), 'width':_('width'), 'height':_('height'),
- 'hide blocks':_('hide blocks'), 'set xy':_('set xy'), 'scale':_('scale')}
+BLOCK_NAMES = {'clean':[_('clean')], 'forward':[_('forward')],
+ 'back':[_('back')],
+ 'left':[_('left')], 'right':[_('right')], 'set heading':[_('set heading')],
+ 'show':[_('show')], 'set scale':[_('set scale')], 'xcor':[_('xcor')],
+ 'ycor':[_('ycor')], 'heading':[_('heading')], 'pen up':[_('pen up')],
+ 'pen down':[_('pen down')], 'set pen size':[_('set pen size')],
+ 'arc':[_('arc'),_('angle'),_('radius')],
+ 'set text size':[_('set text size')], 'set color':[_('set color')],
+ 'set shade':[_('set shade')],
+ 'fill screen':[_('fill screen'),_('color'),_('shade')],
+ 'shade':[_('shade')],
+ 'pen size':[_('pen size')], 'text size':[_('text size')],
+ 'color':[_('color')],
+ 'plus':['+'], 'minus':['–'], 'multiply':['×'], 'divide':['/'],
+ 'mod':[_('mod')],
+ 'random':[_('random')], 'square root':['√'], 'less than':['<'],
+ 'greater than':[">"], 'equal to':['='], 'and':[_('and')], 'or':[_('or')],
+ 'not':[_('not')], 'print':[_('print')], 'wait':[_('wait')],
+ 'forever':[_('forever')], 'repeat':[_('repeat')], 'if then':[_('if then')],
+ 'stop action':[_('stop action')], 'hspace':[' '], 'vspace':[' '],
+ 'start':[_('start')], 'def action 1':[_('action 1')],
+ 'action 1':[_('action 1')],
+ 'def action 2':[_('action 2')], 'action 2':[_('action 2')],
+ 'def action':[_('action')], 'action':[_('action')], 'number':['100'],
+ 'store in box 1':[_('store in box 1')], 'box 1':[_('box 1')],
+ 'store in box 2':[_('store in box 2')], 'box 2':[_('box 2')],
+ 'store in':[_('store in')], 'box':[_('box')], 'string':[_('string')],
+ 'left pos':[_('left')], 'top pos':[_('top')], 'right pos':[_('right')],
+ 'bottom pos':[_('bottom')], 'width':[_('width')], 'height':[_('height')],
+ 'hide blocks':[_('hide blocks')],
+ 'set xy':[_('set xy'),_('x'),_('y')],
+ 'scale':[_('scale')]}
#
# Logo primitives
diff --git a/tawindow.py b/tawindow.py
index eadcb58..4b9daa2 100644
--- a/tawindow.py
+++ b/tawindow.py
@@ -907,7 +907,7 @@ class TurtleArtWindow():
# newspr = Sprite(self,x-20,y-20,self.media_shapes['pythonloaded'])
else:
newblk = block.Block(self.block_list, self.sprite_list, proto.name,
- x-20, y-20, [proto.name])
+ x-20, y-20, [])
newspr = newblk.spr
newspr.set_layer(TOP_LAYER)
self.dragpos = 20, 20