Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWalter Bender <walter@walter-laptop.(none)>2010-01-30 15:01:48 (GMT)
committer Walter Bender <walter@walter-laptop.(none)>2010-01-30 15:01:48 (GMT)
commit12fedd22a5e9bc0b9941d0e73f748f75972c7c0c (patch)
tree22fd50ec3f5cebcf6988e20ac26e356e53a92524
parent03636bc856f48252abc50c85458770f3a2d3bef7 (diff)
adding multimedia support
-rw-r--r--block.py151
-rw-r--r--constants.py25
-rw-r--r--images/audiooff.svg71
-rw-r--r--images/audiosmall.svg71
-rw-r--r--images/descriptionoff.svg55
-rw-r--r--images/descriptionon.svg54
-rw-r--r--images/descriptionsmall.svg59
-rw-r--r--images/journaloff.svg63
-rw-r--r--images/journalsmall.svg63
-rw-r--r--images/pythonsmall.svg53
-rw-r--r--sprites.py20
-rw-r--r--talogo.py4
-rw-r--r--taproject.py13
-rw-r--r--tawindow.py99
14 files changed, 682 insertions, 119 deletions
diff --git a/block.py b/block.py
index 776a5e8..f7eb05b 100644
--- a/block.py
+++ b/block.py
@@ -86,6 +86,7 @@ class Block:
self.content = None
self.primitive = None
self.type = type
+ self._dx = 0
self._ex = 0
self._ey = 0
self._font_size = [6.0, 4.5]
@@ -118,8 +119,8 @@ class Block:
lw = self.spr.label_width()
lwh = self.spr.label_area_dimensions()
if lw > lwh[0]:
- e = (lw-lwh[0])
- self._make_block(e, self.svg)
+ self._dx = (lw-lwh[0])
+ self._make_block(self.svg)
self.spr.set_shape(self.shapes[0])
# We may want to rescale blocks as well.
@@ -129,19 +130,19 @@ class Block:
self.scale = scale
for i in range(len(self._font_size)):
self._font_size[i] *= self.scale
- self._make_block(e, self.svg)
+ self._make_block(self.svg)
self.spr.set_shape(self.shapes[0])
# We may want to grow a block vertically.
def expand_in_y(self, dy):
self._ey += dy
- self._make_block(0, self.svg)
+ self._make_block(self.svg)
self.spr.set_shape(self.shapes[0])
# We may want to grow a block vertically.
def expand_in_x(self, dx):
self._ex += dx
- self._make_block(0, self.svg)
+ self._make_block(self.svg)
self.spr.set_shape(self.shapes[0])
def _new_block_from_factory(self, sprite_list, x, y):
@@ -153,7 +154,7 @@ class Block:
self.svg.set_tab(True)
self.svg.set_slot(True)
- self._make_block(0, self.svg)
+ self._make_block(self.svg)
self.spr = sprites.Sprite(sprite_list, x, y, self.shapes[0])
self.spr.set_margins(self._left, self.svg.get_slot_depth(), self._right,
@@ -181,49 +182,53 @@ class Block:
"center", "middle", i)
self.spr.set_label(label, i)
- def _make_block(self, e, svg):
+ def _make_block(self, svg):
self._set_colors(svg)
self.svg.set_stroke_width(STANDARD_STROKE_WIDTH)
self.svg.clear_docks()
self.shapes = []
if self.name in BASIC_STYLE:
- self._make_basic_style(e, svg)
+ self._make_basic_style(svg)
elif self.name in BASIC_STYLE_HEAD:
- self._make_basic_style_head(e, svg)
+ self._make_basic_style_head(svg)
elif self.name in BASIC_STYLE_HEAD_1ARG:
- self._make_basic_style_head_1arg(e, svg)
+ self._make_basic_style_head_1arg(svg)
elif self.name in BASIC_STYLE_TAIL:
- self._make_basic_style_tail(e, svg)
+ self._make_basic_style_tail(svg)
elif self.name in BASIC_STYLE_1ARG:
- self._make_basic_style_1arg(e, svg)
+ self._make_basic_style_1arg(svg)
elif self.name in BASIC_STYLE_2ARG:
- self._make_basic_style_2arg(e, svg)
+ self._make_basic_style_2arg(svg)
elif self.name in BOX_STYLE:
- self._make_box_style(e, svg)
+ self._make_box_style(svg)
+ elif self.name in BOX_STYLE_MEDIA:
+ self._make_media_style(svg)
elif self.name in NUMBER_STYLE:
- self._make_number_style(e, svg)
+ self._make_number_style(svg)
elif self.name in NUMBER_STYLE_BLOCK:
- self._make_number_style_block(e, svg)
+ self._make_number_style_block(svg)
elif self.name in NUMBER_STYLE_1ARG:
- self._make_number_style_1arg(e, svg)
+ self._make_number_style_1arg(svg)
+ elif self.name in NUMBER_STYLE_1STRARG:
+ self._make_number_style_1strarg(svg)
elif self.name in NUMBER_STYLE_PORCH:
- self._make_number_style_porch(e, svg)
+ self._make_number_style_porch(svg)
elif self.name in COMPARE_STYLE:
- self._make_compare_style(e, svg)
+ self._make_compare_style(svg)
elif self.name in BOOLEAN_STYLE:
- self._make_boolean_style(e, svg)
+ self._make_boolean_style(svg)
elif self.name in NOT_STYLE:
- self._make_not_style(e, svg)
+ self._make_not_style(svg)
elif self.name in FLOW_STYLE:
- self._make_flow_style(e, svg)
+ self._make_flow_style(svg)
elif self.name in FLOW_STYLE_1ARG:
- self._make_flow_style_1arg(e, svg)
+ self._make_flow_style_1arg(svg)
elif self.name in FLOW_STYLE_BOOLEAN:
- self._make_flow_style_boolean(e, svg)
+ self._make_flow_style_boolean(svg)
elif self.name in FLOW_STYLE_ELSE:
- self._make_flow_style_else(e, svg)
+ self._make_flow_style_else(svg)
else:
- self._make_basic_style(e, svg)
+ self._make_basic_style(svg)
print ">>>>> I don't know how to create a %s block" % (self.name)
def _set_colors(self, svg):
@@ -235,15 +240,15 @@ class Block:
self.colors = COLORS[p]
self.svg.set_colors(self.colors)
- def _make_basic_style(self, e, svg):
- self.svg.expand(e+self._ex, self._ey)
+ def _make_basic_style(self, svg):
+ self.svg.expand(self._dx+self._ex, self._ey)
self._make_basic_block(svg)
self.docks = (('flow',True,self.svg.docks[0][0],self.svg.docks[0][1]),
('flow',False,self.svg.docks[1][0],self.svg.docks[1][1]))
self._left, self._right = 2, 2
- def _make_basic_style_head(self, e, svg):
- self.svg.expand(10+e+self._ex, self._ey)
+ def _make_basic_style_head(self, svg):
+ self.svg.expand(10+self._dx+self._ex, self._ey)
self.svg.set_slot(False)
self.svg.set_cap(True)
self._make_basic_block(svg)
@@ -252,8 +257,8 @@ class Block:
self.svg.docks[0][1]))
self._left, self._right = 2, 2
- def _make_basic_style_head_1arg(self, e, svg):
- self.svg.expand(10+e+self._ex, self._ey)
+ def _make_basic_style_head_1arg(self, svg):
+ self.svg.expand(10+self._dx+self._ex, self._ey)
self.svg.set_innie([True])
self.svg.set_slot(False)
self.svg.set_cap(True)
@@ -265,16 +270,16 @@ class Block:
self.svg.docks[1][1]))
self._left, self._right = 2, self.svg.get_innie_width()*1.5
- def _make_basic_style_tail(self, e, svg):
- self.svg.expand(10+e+self._ex, self._ey)
+ def _make_basic_style_tail(self, svg):
+ self.svg.expand(10+self._dx+self._ex, self._ey)
self.svg.set_tab(False)
self._make_basic_block(svg)
self.docks = (('flow', True, self.svg.docks[0][0],
self.svg.docks[0][1]),
('unavailable', False, 0, 0))
- def _make_basic_style_1arg(self, e, svg):
- self.svg.expand(10+e+self._ex, self._ey)
+ def _make_basic_style_1arg(self, svg):
+ self.svg.expand(10+self._dx+self._ex, self._ey)
self.svg.set_innie([True])
self._make_basic_block(svg)
self.docks = (('flow', True, self.svg.docks[0][0],
@@ -285,8 +290,8 @@ class Block:
self.svg.docks[2][1]))
self._left, self._right = 2, self.svg.get_innie_width()*1.5
- def _make_basic_style_2arg(self, e, svg):
- self.svg.expand(10+e+self._ex, self._ey)
+ def _make_basic_style_2arg(self, svg):
+ self.svg.expand(10+self._dx+self._ex, self._ey)
self.svg.set_innie([True,True])
self._make_basic_block(svg)
self.docks = (('flow', True, self.svg.docks[0][0],
@@ -299,16 +304,24 @@ class Block:
self.svg.docks[3][1]))
self._left, self._right = 2, self.svg.get_innie_width()*1.5
- def _make_box_style(self, e, svg):
- self.svg.expand(60+e+self._ex, self._ey)
+ def _make_box_style(self, svg):
+ self.svg.expand(60+self._dx+self._ex, self._ey)
self._make_basic_box(svg)
self.docks = (('number', True, self.svg.docks[0][0],
self.svg.docks[0][1]),
('unavailable', False, 0, 0))
self._left, self._right = self.svg.docks[1][0], 1
- def _make_number_style(self, e, svg):
- self.svg.expand(e+self._ex, self._ey)
+ def _make_media_style(self, svg):
+ self.svg.expand(40+self._dx+self._ex, 10+self._ey)
+ self._make_basic_box(svg)
+ self.docks = (('number', True, self.svg.docks[0][0],
+ self.svg.docks[0][1]),
+ ('unavailable', False, 0, 0))
+ self._left, self._right = self.svg.docks[1][0], 1
+
+ def _make_number_style(self, svg):
+ self.svg.expand(self._dx+self._ex, self._ey)
self.svg.set_innie([True,True])
self.svg.set_outie(True)
self.svg.set_tab(False)
@@ -327,8 +340,8 @@ class Block:
self._left = self.svg.docks[2][0]
self._right = self.svg.get_innie_width()*1.5
- def _make_number_style_block(self, e, svg):
- self.svg.expand(e+self._ex, self._ey)
+ def _make_number_style_block(self, svg):
+ self.svg.expand(self._dx+self._ex, self._ey)
self.svg.set_innie([True,True])
self.svg.set_outie(True)
self.svg.set_tab(False)
@@ -344,8 +357,8 @@ class Block:
self._left = self.svg.docks[2][0]
self._right = self.svg.get_innie_width()*1.5
- def _make_number_style_1arg(self, e, svg):
- self.svg.expand(e+self._ex, self._ey)
+ def _make_number_style_1arg(self, svg):
+ self.svg.expand(self._dx+self._ex, self._ey)
self.svg.set_innie([True])
self.svg.set_outie(True)
self.svg.set_tab(False)
@@ -357,8 +370,22 @@ class Block:
self.svg.docks[0][1]))
self._left, self._right = self.svg.docks[1][0], self.svg.docks[1][0]
- def _make_number_style_porch(self, e, svg):
- self.svg.expand(e+self._ex, self._ey)
+ def _make_number_style_1strarg(self, svg):
+ self.svg.expand(self._dx+self._ex, self._ey)
+ self.svg.set_innie([True])
+ self.svg.set_outie(True)
+ self.svg.set_tab(False)
+ self.svg.set_slot(False)
+ self._make_basic_block(svg)
+ self.docks = (('number', True, self.svg.docks[1][0],
+ self.svg.docks[1][1]),
+ ('string', False, self.svg.docks[0][0],
+ self.svg.docks[0][1]),
+ ('unavailable', False, 0, 0))
+ self._left, self._right = self.svg.docks[1][0], self.svg.docks[1][0]
+
+ def _make_number_style_porch(self, svg):
+ self.svg.expand(self._dx+self._ex, self._ey)
self.svg.set_innie([True,True])
self.svg.set_outie(True)
self.svg.set_tab(False)
@@ -374,8 +401,8 @@ class Block:
self._left = self.svg.docks[2][0]
self._right = self.svg.get_width()-self.svg.docks[0][0]
- def _make_compare_style(self, e, svg):
- self.svg.expand(10+e+self._ex, self._ey)
+ def _make_compare_style(self, svg):
+ self.svg.expand(10+self._dx+self._ex, self._ey)
self._make_boolean_compare(svg)
self.docks = (('bool', True, self.svg.docks[0][0],
self.svg.docks[0][1], '('),
@@ -386,8 +413,8 @@ class Block:
('unavailable', False, 0, 0, ')'))
self._left, self._right = self.svg.get_width()-self.svg.docks[2][0], 0
- def _make_boolean_style(self, e, svg):
- self.svg.expand(10+e+self._ex, self._ey)
+ def _make_boolean_style(self, svg):
+ self.svg.expand(10+self._dx+self._ex, self._ey)
self._make_boolean_and_or(svg)
self.docks = (('bool', True, self.svg.docks[0][0],
self.svg.docks[0][1]),
@@ -397,8 +424,8 @@ class Block:
self.svg.docks[2][1]))
self._left, self._right = self.svg.get_width()-self.svg.docks[1][0], 0
- def _make_not_style(self, e, svg):
- self.svg.expand(15+e+self._ex, self._ey)
+ def _make_not_style(self, svg):
+ self.svg.expand(15+self._dx+self._ex, self._ey)
self._make_boolean_not(svg)
self.docks = (('bool', True, self.svg.docks[0][0],
self.svg.docks[0][1]),
@@ -407,8 +434,8 @@ class Block:
self._right = self.svg.get_width()-self.svg.docks[1][0]
self._left = self._right
- def _make_flow_style(self, e, svg):
- self.svg.expand(10+e+self._ex, self._ey)
+ def _make_flow_style(self, svg):
+ self.svg.expand(10+self._dx+self._ex, self._ey)
self.svg.set_slot(True)
self.svg.set_tab(False)
self._make_basic_flow(svg)
@@ -426,8 +453,8 @@ class Block:
self.svg.docks[1][1]))
self._left, self._right = 0, self.svg.get_width()-self.svg.docks[1][0]
- def _make_flow_style_1arg(self, e, svg):
- self.svg.expand(e+self._ex, self._ey)
+ def _make_flow_style_1arg(self, svg):
+ self.svg.expand(self._dx+self._ex, self._ey)
self.svg.set_slot(True)
self.svg.set_tab(True)
self.svg.set_innie([True])
@@ -444,8 +471,8 @@ class Block:
self._right = self.svg.get_width()-self.svg.docks[1][0]+ \
self.svg.get_innie_width()*1.5
- def _make_flow_style_boolean(self, e, svg):
- self.svg.expand(e+self._ex, self._ey)
+ def _make_flow_style_boolean(self, svg):
+ self.svg.expand(self._dx+self._ex, self._ey)
self.svg.set_slot(True)
self.svg.set_tab(True)
self.svg.set_boolean(True)
@@ -460,8 +487,8 @@ class Block:
self.svg.docks[3][1], ']'))
self._left, self._right = 2, self.svg.get_width()-self.svg.docks[1][0]
- def _make_flow_style_else(self, e, svg):
- self.svg.expand(e+self._ex, self._ey)
+ def _make_flow_style_else(self, svg):
+ self.svg.expand(self._dx+self._ex, self._ey)
self.svg.set_slot(True)
self.svg.set_tab(True)
self.svg.set_else(True)
diff --git a/constants.py b/constants.py
index 2f47399..321389a 100644
--- a/constants.py
+++ b/constants.py
@@ -52,7 +52,7 @@ PALETTES = [['forward', 'back', 'clean', 'left', 'right', 'show',
['kbinput', 'push', 'printheap', 'keyboard', 'pop', 'clearheap',
'myfunc', 'nop', 'leftpos', 'toppos', 'width', 'rightpos',
'bottompos', 'height', 'turtle', 'print'],
- ['hideblocks'],
+ ['journal', 'audio', 'description', 'hideblocks'],
['restore']]
#
@@ -92,10 +92,12 @@ BOX_STYLE = ['number', 'xcor', 'ycor', 'heading', 'pensize', 'color', 'shade',
'textcolor', 'textsize', 'box1', 'box2', 'string', 'leftpos', 'scale',
'toppos', 'rightpos', 'bottompos', 'width', 'height', 'pop', 'keyboard',
'red', 'orange', 'yellow', 'green', 'cyan', 'blue', 'purple']
+BOX_STYLE_MEDIA = ['description', 'audio', 'journal']
NUMBER_STYLE = ['plus2', 'product2', 'myfunc']
NUMBER_STYLE_BLOCK = ['random']
NUMBER_STYLE_PORCH = ['minus2', 'division2', 'remainder2']
-NUMBER_STYLE_1ARG = ['sqrt', 'box', 'identity2']
+NUMBER_STYLE_1ARG = ['sqrt', 'identity2']
+NUMBER_STYLE_1STRARG = ['box']
COMPARE_STYLE = ['greater', 'less', 'equal']
BOOLEAN_STYLE = ['and', 'or']
NOT_STYLE = ['not']
@@ -107,7 +109,7 @@ FLOW_STYLE_ELSE = ['ifelse']
#
# blocks that contain media
#
-CONTENT_BLOCKS = ['number', 'string', 'media', 'audio', 'journal']
+CONTENT_BLOCKS = ['number', 'string', 'description', 'audio', 'journal']
#
# block name dictionary
@@ -116,6 +118,7 @@ CONTENT_BLOCKS = ['number', 'string', 'media', 'audio', 'journal']
BLOCK_NAMES = {
'and':[_('and')],
'arc':[_('arc'),_('angle'),_('radius')],
+ 'audio':[' '],
'back':[_('back')],
'blue':[_('blue')],
'bottompos':[_('bottom')],
@@ -142,14 +145,15 @@ BLOCK_NAMES = {
'identity2':['←'],
'if':['',_('if'),_('then')],
'ifelse':['',_('if'),_('then else')],
+ 'journal':[' '],
'kbinput':[_('query keyboard')],
'keyboard':[_('keyboard')],
'left':[_('left')],
'leftpos':[_('left')],
'less':['<'],'greater':[">"],
'minus2':['–'],
- 'myfunc':[_('python'),_('code'),_('value')],
- 'nop':[_('load Python code')],
+ 'myfunc':[_('Python'),_('code'),_('value')],
+ 'nop':[_(' ')],
'not':[_('not')],
'number':['100'],
'orange':[_('orange')],
@@ -207,7 +211,8 @@ BLOCK_NAMES = {
OLD_NAMES = {'product':'product2', 'storeinbox':'storein',
'division':'division2', 'plus':'plus2',
'remainder':'remainder2', 'identity':'identity2',
- 'division':'division2', 'if else':'if'}
+ 'division':'division2', 'if else':'if', 'audiooff':'audio',
+ 'descriptionoff':'description'}
#
# Logo primitives
@@ -340,8 +345,10 @@ DEFAULTS = {
# Status blocks
#
-MEDIA_SHAPES = ['audioon', 'texton', 'journalon', 'descon', 'pythonoff',
- 'pythonon']
+MEDIA_SHAPES = ['audiooff', 'audioon', 'audiosmall',
+ 'journaloff', 'journalon', 'journalsmall',
+ 'descriptionoff', 'descriptionon', 'descriptionsmall',
+ 'pythonoff', 'pythonon', 'pythonsmall']
OVERLAY_SHAPES = ['Cartesian', 'polar']
@@ -370,6 +377,6 @@ NOISE_KEYS = ['Shift_L', 'Shift_R', 'Control_L', 'Caps_Lock', 'Pause',
'Left', 'Right', 'KP_Home', 'KP_End', 'KP_Up', 'Super_L',
'KP_Down', 'KP_Left', 'KP_Right', 'KP_Page_Down', 'Scroll_Lock',
'Page_Down', 'Page_Up']
-WHITE_SPACE = ['space','Tab','Return']
+WHITE_SPACE = ['space','Tab']
CURSOR = '█'
diff --git a/images/audiooff.svg b/images/audiooff.svg
new file mode 100644
index 0000000..79f6b76
--- /dev/null
+++ b/images/audiooff.svg
@@ -0,0 +1,71 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:xlink="http://www.w3.org/1999/xlink"
+ version="1.0"
+ width="36.386002"
+ height="46.326"
+ id="svg2">
+ <defs
+ id="defs5">
+ <linearGradient
+ id="linearGradient3166">
+ <stop
+ id="stop3168"
+ style="stop-color:#ffffff;stop-opacity:1"
+ offset="0" />
+ <stop
+ id="stop3170"
+ style="stop-color:#ffff00;stop-opacity:1"
+ offset="1" />
+ </linearGradient>
+ <linearGradient
+ x1="0.94254935"
+ y1="-31.669659"
+ x2="94.577461"
+ y2="20.434471"
+ id="linearGradient3172"
+ xlink:href="#linearGradient3166"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(0.7750554,0,0,0.9997979,0.8784441,32.623865)" />
+ </defs>
+ <g
+ transform="translate(-9.182,-4.338)"
+ id="clipping-audio"
+ style="display:block">
+ <g
+ id="g2758"
+ style="display:inline">
+ <g
+ id="g2760">
+ <polygon
+ points="10.932,48.914 10.932,6.088 10.932,6.088 31.874,6.088 43.818,18.027 43.818,48.914 "
+ id="polygon2762"
+ style="fill:#ffffff;stroke:#010101;stroke-width:3.5" />
+ <polyline
+ id="polyline2764"
+ points="43.818,18.027 31.874,18.027 31.874,6.088 "
+ style="fill:none;stroke:#010101;stroke-width:3.5" />
+ </g>
+ </g>
+ <path
+ d="m 28.325,39.697 c -0.511,-1.457 -3.21,-1.073 -4.41,-0.07 -2.4,2.009 -0.424,4.396 2.324,3.277 1.564,-0.638 2.596,-1.748 2.086,-3.207 z"
+ id="path2766"
+ style="fill:#010101;stroke:#010101;stroke-width:3.5;display:inline" />
+ <line
+ id="line2768"
+ y2="26.966999"
+ y1="39.806"
+ x2="28.941"
+ x1="28.941"
+ display="inline"
+ style="fill:none;stroke:#010101;stroke-width:2.25;display:inline" />
+ <polygon
+ points="35.047,25.036 35.047,25.036 27.838,28.595 27.838,24.728 35.047,21.166 "
+ id="polygon2770"
+ style="fill:#010101;display:inline" />
+ </g>
+</svg>
diff --git a/images/audiosmall.svg b/images/audiosmall.svg
new file mode 100644
index 0000000..f922aac
--- /dev/null
+++ b/images/audiosmall.svg
@@ -0,0 +1,71 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:xlink="http://www.w3.org/1999/xlink"
+ version="1.0"
+ width="24.37862"
+ height="31.03842"
+ id="svg2">
+ <defs
+ id="defs5">
+ <linearGradient
+ id="linearGradient3166">
+ <stop
+ id="stop3168"
+ style="stop-color:#ffffff;stop-opacity:1"
+ offset="0" />
+ <stop
+ id="stop3170"
+ style="stop-color:#ffff00;stop-opacity:1"
+ offset="1" />
+ </linearGradient>
+ <linearGradient
+ x1="0.94254935"
+ y1="-31.669659"
+ x2="94.577461"
+ y2="20.434471"
+ id="linearGradient3172"
+ xlink:href="#linearGradient3166"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(0.7750554,0,0,0.9997979,0.8784441,32.623865)" />
+ </defs>
+ <g
+ transform="matrix(0.67,0,0,0.67,-6.15194,-2.90646)"
+ id="clipping-audio"
+ style="display:block">
+ <g
+ id="g2758"
+ style="display:inline">
+ <g
+ id="g2760">
+ <polygon
+ points="43.818,48.914 10.932,48.914 10.932,6.088 10.932,6.088 31.874,6.088 43.818,18.027 "
+ id="polygon2762"
+ style="fill:#ffffff;stroke:#010101;stroke-width:3.5" />
+ <polyline
+ id="polyline2764"
+ points="43.818,18.027 31.874,18.027 31.874,6.088 "
+ style="fill:none;stroke:#010101;stroke-width:3.5" />
+ </g>
+ </g>
+ <path
+ d="m 28.325,39.697 c -0.511,-1.457 -3.21,-1.073 -4.41,-0.07 -2.4,2.009 -0.424,4.396 2.324,3.277 1.564,-0.638 2.596,-1.748 2.086,-3.207 z"
+ id="path2766"
+ style="fill:#010101;stroke:#010101;stroke-width:3.5;display:inline" />
+ <line
+ id="line2768"
+ y2="26.966999"
+ y1="39.806"
+ x2="28.941"
+ x1="28.941"
+ display="inline"
+ style="fill:none;stroke:#010101;stroke-width:2.25;display:inline" />
+ <polygon
+ points="35.047,25.036 35.047,25.036 27.838,28.595 27.838,24.728 35.047,21.166 "
+ id="polygon2770"
+ style="fill:#010101;display:inline" />
+ </g>
+</svg>
diff --git a/images/descriptionoff.svg b/images/descriptionoff.svg
new file mode 100644
index 0000000..e7eb034
--- /dev/null
+++ b/images/descriptionoff.svg
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:xlink="http://www.w3.org/1999/xlink"
+ version="1.0"
+ width="34.5"
+ height="45.5"
+ id="svg2">
+ <defs
+ id="defs5">
+ <linearGradient
+ id="linearGradient3166">
+ <stop
+ id="stop3168"
+ style="stop-color:#ffffff;stop-opacity:1"
+ offset="0" />
+ <stop
+ id="stop3170"
+ style="stop-color:#ffff00;stop-opacity:1"
+ offset="1" />
+ </linearGradient>
+ <linearGradient
+ x1="0.94254935"
+ y1="-31.669659"
+ x2="104.37702"
+ y2="20.434471"
+ id="linearGradient3172"
+ xlink:href="#linearGradient3166"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(0.7083638,0,0,1.0012565,0.1338084,32.632067)" />
+ </defs>
+ <path
+ d="m 1.75,43.75 0,-42 21,0 10,11 0,31 -31,0 z"
+ id="path3199"
+ style="fill:#ffffff;fill-opacity:1;fill-rule:evenodd;stroke:#00000f;stroke-width:3.5;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:0.94117647;stroke-dasharray:none" />
+ <path
+ d="m 10,26.75 c 14.5,0 14.5,0 14.5,0"
+ id="path3163"
+ style="fill:none;stroke:#000000;stroke-width:3.49999976;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
+ <path
+ d="m 10,32.75 c 14.5,0 14.5,0 14.5,0"
+ id="path3165"
+ style="fill:none;stroke:#000000;stroke-width:3.49999976;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
+ <path
+ d="m 10,20.75 c 14.5,0 14.5,0 14.5,0"
+ id="path3167"
+ style="fill:none;stroke:#000000;stroke-width:3.49999976;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
+ <path
+ d="m 21.5,2.5000001 0,10.2499999 9.5,0"
+ id="path3201"
+ style="fill:none;stroke:#000000;stroke-width:3.5;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
+</svg>
diff --git a/images/descriptionon.svg b/images/descriptionon.svg
new file mode 100644
index 0000000..8148f3d
--- /dev/null
+++ b/images/descriptionon.svg
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:xlink="http://www.w3.org/1999/xlink"
+ version="1.0"
+ width="34.5"
+ height="45.5"
+ id="svg2">
+ <defs
+ id="defs5">
+ <linearGradient
+ id="linearGradient3166">
+ <stop
+ id="stop3168"
+ style="stop-color:#ffffff;stop-opacity:1"
+ offset="0" />
+ <stop
+ id="stop3170"
+ style="stop-color:#ffff00;stop-opacity:1"
+ offset="1" />
+ </linearGradient>
+ <linearGradient
+ x1="0.94254935"
+ y1="-31.669659"
+ x2="104.37702"
+ y2="20.434471"
+ id="linearGradient3172"
+ xlink:href="#linearGradient3166"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(0.7083638,0,0,1.0012565,0.1338084,32.632067)" />
+ </defs>
+ <rect
+ width="30.999998"
+ height="42"
+ x="1.75"
+ y="1.75"
+ id="rect2391"
+ style="fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:3.5;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
+ <path
+ d="m 10,26.75 c 14.5,0 14.5,0 14.5,0"
+ id="path3163"
+ style="fill:none;stroke:#ff0000;stroke-width:3.49999976;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
+ <path
+ d="m 10,32.75 c 14.5,0 14.5,0 14.5,0"
+ id="path3165"
+ style="fill:none;stroke:#ff0000;stroke-width:3.49999976;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
+ <path
+ d="m 10,20.75 c 14.5,0 14.5,0 14.5,0"
+ id="path3167"
+ style="fill:none;stroke:#ff0000;stroke-width:3.49999976;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
+</svg>
diff --git a/images/descriptionsmall.svg b/images/descriptionsmall.svg
new file mode 100644
index 0000000..e853170
--- /dev/null
+++ b/images/descriptionsmall.svg
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:xlink="http://www.w3.org/1999/xlink"
+ version="1.0"
+ width="23.115"
+ height="30.485001"
+ id="svg2">
+ <defs
+ id="defs5">
+ <linearGradient
+ id="linearGradient3166">
+ <stop
+ id="stop3168"
+ style="stop-color:#ffffff;stop-opacity:1"
+ offset="0" />
+ <stop
+ id="stop3170"
+ style="stop-color:#ffff00;stop-opacity:1"
+ offset="1" />
+ </linearGradient>
+ <linearGradient
+ x1="0.94254935"
+ y1="-31.669659"
+ x2="104.37702"
+ y2="20.434471"
+ id="linearGradient3172"
+ xlink:href="#linearGradient3166"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(0.7083638,0,0,1.0012565,0.1338084,32.632067)" />
+ </defs>
+ <g
+ transform="scale(0.67,0.67)"
+ id="g2823">
+ <path
+ d="m 1.75,43.75 0,-42 21,0 10,11 0,31 -31,0 z"
+ id="path3199"
+ style="fill:#ffffff;fill-opacity:1;fill-rule:evenodd;stroke:#00000f;stroke-width:3.5;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:0.94117647;stroke-dasharray:none" />
+ <path
+ d="m 10,26.75 c 14.5,0 14.5,0 14.5,0"
+ id="path3163"
+ style="fill:none;stroke:#000000;stroke-width:3.49999976;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
+ <path
+ d="m 10,32.75 c 14.5,0 14.5,0 14.5,0"
+ id="path3165"
+ style="fill:none;stroke:#000000;stroke-width:3.49999976;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
+ <path
+ d="m 10,20.75 c 14.5,0 14.5,0 14.5,0"
+ id="path3167"
+ style="fill:none;stroke:#000000;stroke-width:3.49999976;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
+ <path
+ d="m 21.5,2.5000001 0,10.2499999 9.5,0"
+ id="path3201"
+ style="fill:none;stroke:#000000;stroke-width:3.5;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
+ </g>
+</svg>
diff --git a/images/journaloff.svg b/images/journaloff.svg
new file mode 100644
index 0000000..3cfb3fa
--- /dev/null
+++ b/images/journaloff.svg
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:xlink="http://www.w3.org/1999/xlink"
+ version="1.0"
+ width="41.983002"
+ height="46.5"
+ id="svg2">
+ <defs
+ id="defs5">
+ <linearGradient
+ id="linearGradient3166">
+ <stop
+ id="stop3168"
+ style="stop-color:#ffffff;stop-opacity:1"
+ offset="0" />
+ <stop
+ id="stop3170"
+ style="stop-color:#ffff00;stop-opacity:1"
+ offset="1" />
+ </linearGradient>
+ <linearGradient
+ x1="0.94254935"
+ y1="-31.669659"
+ x2="104.37702"
+ y2="20.434471"
+ id="linearGradient3172"
+ xlink:href="#linearGradient3166"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(0.7083638,0,0,1.0012565,0.1338084,32.632067)" />
+ </defs>
+ <g
+ transform="translate(-5.634,-4.25)"
+ id="activity-journal"
+ style="stroke:#000000;stroke-opacity:1;display:block">
+ <path
+ d="M 45.866,44.669 C 45.866,47.18 44.338,49 41.534,49 l -29.457,0 0,-43 29.458,0 c 2.15,0 4.332,2.154 4.332,4.33 l -10e-4,34.339 0,0 z"
+ id="path2458"
+ style="fill:#ffffff;stroke:#000000;stroke-width:3.5;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" />
+ <line
+ id="line2460"
+ y2="48.881001"
+ y1="6.1209998"
+ x2="21.341"
+ x1="21.341"
+ style="fill:none;stroke:#000000;stroke-width:3.5;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" />
+ <path
+ d="m 7.384,14.464 c 0,0 2.084,0.695 4.17,0.695 2.086,0 4.173,-0.695 4.173,-0.695"
+ id="path2462"
+ style="fill:none;stroke:#000000;stroke-width:3.5;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" />
+ <path
+ d="m 7.384,28.021 c 0,0 1.912,0.695 4.345,0.695 2.433,0 3.999,-0.695 3.999,-0.695"
+ id="path2464"
+ style="fill:none;stroke:#000000;stroke-width:3.5;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" />
+ <path
+ d="m 7.384,41.232 c 0,0 1.736,0.695 4.518,0.695 2.781,0 3.825,-0.695 3.825,-0.695"
+ id="path2466"
+ style="fill:none;stroke:#000000;stroke-width:3.5;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" />
+ </g>
+</svg>
diff --git a/images/journalsmall.svg b/images/journalsmall.svg
new file mode 100644
index 0000000..5b93089
--- /dev/null
+++ b/images/journalsmall.svg
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:xlink="http://www.w3.org/1999/xlink"
+ version="1.0"
+ width="28.128611"
+ height="31.155001"
+ id="svg2">
+ <defs
+ id="defs5">
+ <linearGradient
+ id="linearGradient3166">
+ <stop
+ id="stop3168"
+ style="stop-color:#ffffff;stop-opacity:1"
+ offset="0" />
+ <stop
+ id="stop3170"
+ style="stop-color:#ffff00;stop-opacity:1"
+ offset="1" />
+ </linearGradient>
+ <linearGradient
+ x1="0.94254935"
+ y1="-31.669659"
+ x2="104.37702"
+ y2="20.434471"
+ id="linearGradient3172"
+ xlink:href="#linearGradient3166"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(0.7083638,0,0,1.0012565,0.1338084,32.632067)" />
+ </defs>
+ <g
+ transform="matrix(0.67,0,0,0.67,-3.77478,-2.8475)"
+ id="activity-journal"
+ style="stroke:#000000;stroke-opacity:1;display:block">
+ <path
+ d="M 45.866,44.669 C 45.866,47.18 44.338,49 41.534,49 l -29.457,0 0,-43 29.458,0 c 2.15,0 4.332,2.154 4.332,4.33 l -10e-4,34.339 0,0 z"
+ id="path2458"
+ style="fill:#ffffff;stroke:#000000;stroke-width:3.5;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" />
+ <line
+ id="line2460"
+ y2="48.881001"
+ y1="6.1209998"
+ x2="21.341"
+ x1="21.341"
+ style="fill:none;stroke:#000000;stroke-width:3.5;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" />
+ <path
+ d="m 7.384,14.464 c 0,0 2.084,0.695 4.17,0.695 2.086,0 4.173,-0.695 4.173,-0.695"
+ id="path2462"
+ style="fill:none;stroke:#000000;stroke-width:3.5;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" />
+ <path
+ d="m 7.384,28.021 c 0,0 1.912,0.695 4.345,0.695 2.433,0 3.999,-0.695 3.999,-0.695"
+ id="path2464"
+ style="fill:none;stroke:#000000;stroke-width:3.5;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" />
+ <path
+ d="m 7.384,41.232 c 0,0 1.736,0.695 4.518,0.695 2.781,0 3.825,-0.695 3.825,-0.695"
+ id="path2466"
+ style="fill:none;stroke:#000000;stroke-width:3.5;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" />
+ </g>
+</svg>
diff --git a/images/pythonsmall.svg b/images/pythonsmall.svg
new file mode 100644
index 0000000..d84a976
--- /dev/null
+++ b/images/pythonsmall.svg
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:xlink="http://www.w3.org/1999/xlink"
+ version="1.0"
+ width="18.750023"
+ height="18.750151"
+ id="svg2">
+ <defs
+ id="defs4">
+ <linearGradient
+ id="linearGradient3166">
+ <stop
+ id="stop3168"
+ style="stop-color:#ffffff;stop-opacity:1"
+ offset="0" />
+ <stop
+ id="stop3170"
+ style="stop-color:#ff0000;stop-opacity:1"
+ offset="1" />
+ </linearGradient>
+ <linearGradient
+ x1="0"
+ y1="22"
+ x2="74"
+ y2="22"
+ id="linearGradient3172"
+ xlink:href="#linearGradient3166"
+ gradientUnits="userSpaceOnUse" />
+ </defs>
+ <g
+ transform="matrix(0.72492281,0,0,0.74458853,-16.978876,-13.360816)"
+ id="g2503">
+ <path
+ d="m 36.900421,42.139076 c 3.678049,0 9.139842,-1.579778 9.139842,-6.226149 0,-5.168511 -4.756035,-5.646118 -6.728349,-6.169371 -2.179926,-0.444765 -3.631982,-1.065431 -3.719203,-1.923232 -0.14926,-1.470673 0.711286,-2.043468 2.423778,-2.043468 0,0 4.073618,2.039572 7.534227,0.411922 0.975408,-0.458124 2.722297,-2.59845 2.722297,-4.07469 0,-1.476797 -5.639307,-3.183491 -7.35057,-3.183491 -1.712492,0 -3.168848,2.141439 -3.168848,2.141439 -3.423755,0 -6.848125,2.953594 -6.848125,5.907188 0,2.953037 3.275725,5.263141 7.190869,5.907187 1.819984,0.26107 3.342062,1.235767 2.996247,3.027072 -0.280706,1.454531 -1.839639,2.953594 -5.135633,2.953594 -2.611734,0 -8.169348,-0.121906 -9.05692,-2.270582 -0.570626,-1.383836 0.103192,-2.897372 0.959438,-2.897372 l -0.01658,-0.08906 c -0.872216,-0.08795 -3.407785,0.08906 -3.407785,3.042101 -6.14e-4,3.786345 5.61658,5.486916 12.46532,5.486916 z"
+ id="path2474"
+ style="fill:none;stroke:#000000;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
+ <path
+ d="M 45.550102,26.189335 C 43.938959,26.029576 41.489383,25.076031 40.963596,23.39383"
+ id="path2476"
+ style="fill:none;stroke:#000000;stroke-width:2;stroke-linecap:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
+ <circle
+ cx="35.805"
+ cy="10.96"
+ r="1.676"
+ transform="matrix(0.6142367,0,0,0.5566517,19.396517,15.137572)"
+ id="circle2478"
+ style="fill:#000000;fill-opacity:1;stroke-width:3.42034841;stroke-miterlimit:4;stroke-dasharray:none" />
+ </g>
+</svg>
diff --git a/sprites.py b/sprites.py
index 3564bd6..e66a86d 100644
--- a/sprites.py
+++ b/sprites.py
@@ -151,13 +151,19 @@ class Sprite:
self.layer = 100
self.labels = []
self.images = []
+ self._dx = []
+ self._dy = []
self.set_image(image)
self._sprites.append_to_list(self)
- def set_image(self, image, i=0):
+ def set_image(self, image, i=0, dx=0, dy=0):
while len(self.images) < i+1:
self.images.append(None)
+ self._dx.append(0)
+ self._dy.append(0)
self.images[i] = image
+ self._dx[i] = dx
+ self._dy[i] = dy
if isinstance(self.images[i], gtk.gdk.Pixbuf):
_w = self.images[i].get_width()
_h = self.images[i].get_height()
@@ -251,13 +257,15 @@ class Sprite:
gtk.gdk.Rectangle(self._x,self._y,self._width,self._height), False)
def draw(self):
- for i in self.images:
- if isinstance(i, gtk.gdk.Pixbuf):
+ for i,img in enumerate(self.images):
+ if isinstance(img, gtk.gdk.Pixbuf):
self._sprites.area.draw_pixbuf(
- self._sprites.gc, i, 0, 0, self._x, self._y)
- elif i is not None:
+ self._sprites.gc, img, 0, 0, self._x+self._dx[i],
+ self._y+self._dy[i])
+ elif img is not None:
self._sprites.area.draw_drawable(
- self._sprites.gc, i, 0, 0, self._x, self._y, -1, -1)
+ self._sprites.gc, img, 0, 0, self._x+self._dx[i],
+ self._y+self._dy[i], -1, -1)
if len(self.labels) > 0:
self.draw_label()
diff --git a/talogo.py b/talogo.py
index f0e7372..b93e9d8 100644
--- a/talogo.py
+++ b/talogo.py
@@ -126,12 +126,12 @@ def blocks_to_code(lc, blk):
else:
return ['%nothing%']
for i in range(1,len(blk.connections)):
- b = blk.connections[i]
+ b = blk.connections[i]
dock = blk.docks[i]
if len(dock)>4:
for c in dock[4]:
code.append(c)
- if b is not None:
+ if b is not None:
code.extend(blocks_to_code(lc, b))
elif blk.docks[i][0] not in ['flow', 'unavailable']:
print "appending nothing"
diff --git a/taproject.py b/taproject.py
index 298f281..58eee81 100644
--- a/taproject.py
+++ b/taproject.py
@@ -160,11 +160,14 @@ def read_data(tw, data):
for i, c in enumerate(b.connections):
if c is not None:
bdock = b.docks[i]
- for j in range(len(c.docks)):
- if c.connections[j] == b:
- cdock = c.docks[j]
- nx, ny = sx+bdock[2]-cdock[2], sy+bdock[3]-cdock[3]
- c.spr.move((nx, ny))
+ if len(c.docks) != len(c.connections):
+ print "dock-connection mismatch %s %s" % (b.name, c.name)
+ else:
+ for j in range(len(c.docks)):
+ if c.connections[j] == b:
+ cdock = c.docks[j]
+ nx, ny = sx+bdock[2]-cdock[2], sy+bdock[3]-cdock[3]
+ c.spr.move((nx, ny))
def load_block(tw, b):
# TODO: optionally read blocks without x, y
diff --git a/tawindow.py b/tawindow.py
index e74201f..1a0b43d 100644
--- a/tawindow.py
+++ b/tawindow.py
@@ -209,7 +209,7 @@ class TurtleArtWindow():
def set_userdefined(self):
for blk in self._just_blocks():
if blk.name == 'nop':
- blk.spr.set_label('Python code', 0)
+ blk.spr.set_image(self.media_shapes['pythonon'], 1, 15, 8)
self.nop = 'pythonloaded'
"""
@@ -290,10 +290,8 @@ class TurtleArtWindow():
def _setup_misc(self):
# media blocks get positioned into other blocks
for name in MEDIA_SHAPES:
- self.media_shapes[name] = Sprite(self.sprite_list, 0, 0,
- self._load_sprite_from_file("%s/%s.svg" % (self.path, name)))
- self.media_shapes[name].set_layer(HIDE_LAYER)
- self.media_shapes[name].type = 'media'
+ self.media_shapes[name] = \
+ self._load_sprite_from_file("%s/%s.svg" % (self.path, name))
for i, name in enumerate(STATUS_SHAPES):
self.status_shapes[name] = self._load_sprite_from_file(
@@ -385,6 +383,13 @@ class TurtleArtWindow():
0, 0, 'proto', [], 1.5))
self.palettes[n][i].spr.set_layer(TAB_LAYER)
self.palettes[n][i].spr.set_shape(self.palettes[n][i].shapes[0])
+ # Add a skin to some blocks
+ if name in BOX_STYLE_MEDIA:
+ self.palettes[n][i].spr.set_image(self.media_shapes[
+ name+'small'], 1, 28, 7)
+ elif name == 'nop':
+ self.palettes[n][i].spr.set_image(self.media_shapes[
+ 'pythonsmall'], 1, 10, 7)
# simple packing algorithm
_x, _y, _max_width = 5, ICON_SIZE+5, 0
for i in range(len(PALETTES[n])):
@@ -838,6 +843,7 @@ class TurtleArtWindow():
self._select_category(spr)
elif spr.type == 'category':
r,g,b,a = spr.get_pixel((x, y))
+ # print "%s %s %s %s" % (r,g,b,a)
if (r == 255 and g == 0) or g == 255:
self._hide_palette()
return True
@@ -957,13 +963,18 @@ class TurtleArtWindow():
if blk.name=='number' or blk.name=='string':
self.saved_string = blk.spr.labels[0]
blk.spr.labels[0] += CURSOR
- '''
- elif blk.name in self.importblocks:
- self._import_from_journal(self.selected_spr)
- '''
+ elif blk.name in BOX_STYLE_MEDIA:
+ self._import_from_journal(self.selected_blk)
elif blk.name=='vspace':
+ group = self._find_group(blk)
+ for b in group:
+ if b != blk:
+ b.spr.move_relative((0, 20*blk.scale))
blk.expand_in_y(20)
elif blk.name=='hspace':
+ group = self._find_group(blk.connections[1])
+ for b in group:
+ b.spr.move_relative((20*blk.scale, 0))
blk.expand_in_x(20)
elif blk.name=='nop' and self.myblock==None:
self._import_py()
@@ -1007,7 +1018,7 @@ class TurtleArtWindow():
"""
import from Journal
"""
- def _import_from_journal(self, spr):
+ def _import_from_journal(self, blk):
if self.running_sugar():
chooser = ObjectChooser('Choose image', None,\
gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT)
@@ -1015,21 +1026,42 @@ class TurtleArtWindow():
result = chooser.run()
if result == gtk.RESPONSE_ACCEPT:
dsobject = chooser.get_selected_object()
- # change block graphic to indicate that object is "loaded"
- blk = self.block_list.spr_to_block(spr)
if blk.name == 'journal':
- self._load_image(dsobject, spr)
- elif blk.name == 'audiooff':
- spr.set_image(self.media_shapes['audioon'])
+ self._load_image(dsobject, blk)
+ elif blk.name == 'audio':
+ blk.spr.set_image(self.media_shapes['audioon'],
+ 1, 17, 2)
else:
- spr.set_image(self.media_shapes['decson'])
+ blk.spr.set_image(self.media_shapes['decsriptionon'],
+ 1, 17, 2)
blk.values[0] = dsobject.object_id
dsobject.destroy()
finally:
chooser.destroy()
del chooser
else:
- print "Journal Object Chooser unavailable from outside of Sugar"
+ from taproject import _get_load_name
+ fname = _get_load_name(self, '.*')
+ if fname is None:
+ return
+ pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(fname, 80, 60)
+ if pixbuf is not None:
+ blk.spr.set_image(pixbuf, 1, 17, 2)
+ else:
+ blk.spr.set_image(self.media_shapes['journalon'], 1, 17, 2)
+ blk.values[0] = fname
+ blk.spr.set_label(' ')
+
+ """
+ Replace Journal block graphic with preview image
+ """
+ def _load_image(self, picture, blk):
+ from talogo import get_pixbuf_from_journal
+ pixbuf = get_pixbuf_from_journal(picture, 80, 60)
+ if pixbuf is not None:
+ blk.spr.set_image(pixbuf, 1, 17, 2)
+ else:
+ blk.spr.set_image(self.media_shapes['descon'], 1, 17, 2)
"""
Run stack
@@ -1083,8 +1115,15 @@ class TurtleArtWindow():
else:
newblk = Block(self.block_list, self.sprite_list, name,
x-20, y-20, 'block')
- if name == 'nop' and self.nop == 'pythonloaded':
- newblk.spr.set_label('Python code', 0)
+ # Add special skin to some blocks
+ if name == 'nop':
+ if self.nop == 'pythonloaded':
+ newblk.spr.set_image(self.media_shapes['pythonon'], 1, 17, 8)
+ else:
+ newblk.spr.set_image(self.media_shapes['pythonoff'], 1, 17, 8)
+ elif name in BOX_STYLE_MEDIA:
+ newblk.spr.set_image(self.media_shapes[name+'off'], 1, 27, 8)
+ newblk.spr.set_label(' ')
newspr = newblk.spr
newspr.set_layer(TOP_LAYER)
self.drag_pos = 20, 20
@@ -1157,18 +1196,6 @@ class TurtleArtWindow():
self.drag_turtle = ('move', x-tx, y-ty)
"""
- Replace Journal block graphic with preview image
- TODO: move to block
- """
- def _load_image(self, picture, spr):
- from talogo import get_pixbuf_from_journal
- pixbuf = get_pixbuf_from_journal(picture,spr.width,spr.height)
- if pixbuf is not None:
- spr.set_image(pixbuf)
- else:
- spr.set_image(self.media_shapes['texton'])
-
- """
Find the distance between the dock points of two blocks.
"""
def _dock_dx_dy(self, block1, dock1n, block2, dock2n):
@@ -1177,11 +1204,13 @@ class TurtleArtWindow():
d1type, d1dir, d1x, d1y = dock1[0:4]
d2type, d2dir, d2x, d2y = dock2[0:4]
if (d2type is not 'number') or (dock2n is not 0):
- if block1.connections is not None and dock1n < block1.connections\
- and block1.connections[dock1n] is not None:
+ if block1.connections is not None and \
+ dock1n < len(block1.connections) and \
+ block1.connections[dock1n] is not None:
return (100,100)
- if block2.connections is not None and dock2n < block2.connections\
- and block2.connections[dock2n] is not None:
+ if block2.connections is not None and \
+ dock2n < len(block2.connections) and \
+ block2.connections[dock2n] is not None:
return (100,100)
if block1 == block2:
return (100,100)