diff options
author | Walter Bender <walter.bender@gmail.com> | 2012-07-18 19:49:34 (GMT) |
---|---|---|
committer | Walter Bender <walter.bender@gmail.com> | 2012-07-18 19:49:34 (GMT) |
commit | d2871214f611d95529c5d15828584bdddf83e3f0 (patch) | |
tree | 62906194a8c716df190d67e93cd998264a354783 /pysamples | |
parent | 21111b93b925d56d1a78a08d464699517ab1476b (diff) |
use dock positions; mark for deletion
Diffstat (limited to 'pysamples')
-rw-r--r-- | pysamples/load_block.py | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/pysamples/load_block.py b/pysamples/load_block.py index e7a7af6..6719bea 100644 --- a/pysamples/load_block.py +++ b/pysamples/load_block.py @@ -1,4 +1,4 @@ -#Copyright (c) 2011, Walter Bender +#Copyright (c) 2011,2012 Walter Bender # This procedure is invoked when the user-definable block on the # "extras" palette is selected. @@ -12,6 +12,8 @@ # turtle is moved to the bottom of the block after it is loaded in # order position another block to the bottom of the stack. +# The status of these blocks is set to 'load block' + # For example, try the following to place forward 100, right 90 on the canvas: # start # Python(forward, 100) <-- Python load_block.py expanded to two arguments @@ -37,11 +39,13 @@ def myblock(tw, blkname): blk = tw.block_list.spr_to_block(spr) if blk is not None: tw.drag_group = find_group(blk) + for b in tw.drag_group: + b.status = 'load block' tw._snap_to_dock() # Disassociate new block from mouse. tw.drag_group = None - return blk.height + return blk.docks[-1][3] * tw.scale def find_block(tw, blkname, x, y, defaults=None): """ Create a new block. It is a bit more work than just calling @@ -73,7 +77,14 @@ def myblock(tw, blkname): dy = int(find_block(tw, name, x, y, value)) else: name = blkname - dy = int(find_block(tw, name, x, y)) + if name == 'delete': + for blk in tw.just_blocks(): + if blk.status == 'load block': + blk.type = 'trash' + blk.spr.hide() + dy = 0 + else: + dy = int(find_block(tw, name, x, y)) # Account for block overlaps by adding back 4 pixels - tw.active_turtle.move((x, y - dy + 4)) + tw.active_turtle.move((x, y + dy)) |