From bbbb8ae79008517116c4dcde85037200996c83f7 Mon Sep 17 00:00:00 2001 From: Walter Bender Date: Tue, 02 Feb 2010 21:38:00 +0000 Subject: refactored hover help --- diff --git a/NEWS b/NEWS index 404e335..d07b9bc 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,24 @@ +83 + +* MAJOR REFACTORING +** multiple turtles +** expandable blocks +** trash palette +** 90% smaller download bundle-size +** faster first-time launch +** easier i18n maintenance +** variable-length string blocks +** editable strings +** easier to add new blocks and palettes + +82 + +* minor updates to Spanish translations + +81 + +* fixed keyboard input bug introduced in v79 + 80 * new Finnish translations diff --git a/activity/activity.info b/activity/activity.info index b4b191b..326d470 100644 --- a/activity/activity.info +++ b/activity/activity.info @@ -1,6 +1,6 @@ [Activity] name = Turtle Art -activity_version = 80 +activity_version = 83 license = MIT bundle_id = org.laptop.TurtleArtActivity exec = sugar-activity TurtleArtActivity.TurtleArtActivity diff --git a/constants.py b/constants.py index f275395..351feb9 100644 --- a/constants.py +++ b/constants.py @@ -31,7 +31,7 @@ TOP_LAYER = 1000 # block palette categories # -PALETTE_NAMES = ['turtle', 'pen', 'colors', 'number', 'flow', 'blocks', +PALETTE_NAMES = ['turtle', 'pen', 'colors', 'numbers', 'flow', 'blocks', 'extras', 'portfolio', 'trash'] PALETTES = [['forward', 'back', 'clean', 'left', 'right', 'show', @@ -140,12 +140,12 @@ OLD_DOCK = ['and', 'or'] CONTENT_BLOCKS = ['number', 'string', 'description', 'audio', 'journal'] # -# block name dictionary +# block name dictionary used for labels # BLOCK_NAMES = { 'and2':[_('and')], 'arc':[_('arc'),_('angle'),_('radius')], - 'audio':[' '], + 'audio':[''], 'back':[_('back')], 'blue':[_('blue')], 'bottompos':[_('bottom')], @@ -169,11 +169,11 @@ BLOCK_NAMES = { 'heading':[_('heading')], 'height':[_('height')], 'hideblocks':[_('hide blocks')], - 'hspace':[' '], + 'hspace':[''], 'identity2':['←'], 'if':['',_('if'),_('then')], 'ifelse':['',_('if'),_('then else')], - 'journal':[' '], + 'journal':[''], 'kbinput':[_('query keyboard')], 'keyboard':[_('keyboard')], 'left':[_('left')], @@ -182,7 +182,7 @@ BLOCK_NAMES = { 'list':[_('list')], 'minus2':['–'], 'myfunc':[_('Python'),_('code'),_('value')], - 'nop':[_(' ')], + 'nop':[_('')], 'not':[_('not')], 'number':['100'], 'orange':[_('orange')], @@ -231,7 +231,7 @@ BLOCK_NAMES = { 'textsize':[_('text size')], 'toppos':[_('top')], 'turtle':[_('turtle')], - 'vspace':[' '], + 'vspace':[''], 'wait':[_('wait')], 'width':[_('width')], 'xcor':[_('xcor')], @@ -415,7 +415,7 @@ OLD_NAMES = {'product':'product2', 'storeinbox':'storein', 'descriptionoff':'description','template3':'list', 'template1':'template1x1', 'template2':'template2x1', 'template6':'template1x2', 'template7':'template2x2', - 'template4':'template1x1', 'hres':'width', 'vres':'height' } + 'template4':'template1x1a', 'hres':'width', 'vres':'height' } # # Define the relative size and postion of media objects @@ -430,6 +430,140 @@ TEMPLATES = {'t1x1': (0.5, 0.5, 0.0625, 0.125, 1.05, 0), 'insertimage': (0.333, 0.333)} # +# Names for blocks without names for popup help +# +SPECIAL_NAMES = { + 'audio':_('audio'), + 'division2':_('divide'), + 'equal2':_('equal'), + 'greater2':_('greater than'), + 'hspace':_('horizontal space'), + 'identity2':_('identity'), + 'if':_('if then'), + 'ifelse':_('if then else'), + 'journal':_('journal'), + 'less2':_('less than'), + 'minus2':_('minus'), + 'myfunc':_('Python code'), + 'nop':_('Python code'), + 'number':_('number'), + 'plus2':_('plus'), + 'product2':_('multiply'), + 'sqrt':_('square root'), + 'template1x1':_('presentation 1x1'), + 'template1x2':_('presentation 1x2'), + 'template2x1':_('presentation 2x1'), + 'template2x2':_('presentation 2x2'), + 'textsize':_('text size'), + 'vspace':_('vertical space')} + +# +# Help messages +# +HELP_STRINGS = { + 'and2':_("logical AND operator"), + 'arc':_("move turtle along an arc"), + 'audio':_("Sugar Journal audio object"), + 'back':_("move turtle backward"), + 'blocks':_("palette of variable blocks"), + 'bottompos':_("ycor of bottom of screen"), + 'box1':_("variable 1 (numeric value)"), + 'box2':_("variable 2 (numeric value)"), + 'box':_("named variable (numeric value)"), + 'clean':_("clear the screen and reset the turtle"), + 'clearheap':_("empty FILO"), + 'color':_("holds current pen color (can be used in place of a number block)"), + 'colors':_("a palette of pen colors"), + 'description':_("Sugar Journal description field"), + 'division2':_("divides top numeric input (numerator) by bottom numeric input (denominator)"), + 'equal2':_("logical equal-to operator"), + 'extras':_("palette of extra options"), + 'fillscreen':_("fills the background with (color, shade)"), + 'flow':_("palette of flow operators"), + 'forever':_("loop forever"), + 'forward':_("move turtle forward"), + 'greater2':_("logical greater-than operator"), + 'hat1':_("top of action 1 stack"), + 'hat2':_("top of action 2 stack"), + 'hat':_("top of nameable action stack"), + 'heading':_("holds current heading value of the turtle (can be used in place of a number block)"), + 'hideblocks':_("declutter canvas by hiding blocks"), + 'width':_("the canvas width"), + 'hspace':_("jog stack right"), + 'identity2':_("identity operator used for extending blocks"), + 'ifelse':_("if-then-else operator that uses boolean operators from Numbers palette"), + 'if':_("if-then operator that uses boolean operators from Numbers palette"), + 'journal':_("Sugar Journal media object"), + 'kbinput':_("query for keyboard input (results stored in keyboard block)"), + 'keyboard':_("holds results of query-keyboard block"), + 'leftpos':_("xcor of left of screen"), + 'left':_("turn turtle counterclockwise (angle in degrees)"), + 'less2':_("logical less-than operator"), + 'minus2':_("subtracts bottom numeric input from top numeric input"), + 'myfunc':_("a programmable block: add your own math equation in the block, e.g., sin(x)"), + 'nop':_("runs code found in the tamyblock.py module found in the Journal"), + 'not':_("logical NOT operator"), + 'numbers':_("palette of numeric operators"), + 'number':_("used as numeric input in mathematic operators"), + 'or':_("logical OR operator"), + 'orientation':_("changes the orientation of the palette of blocks"), + 'pendown':_("turtle will draw when moved"), + 'pen':_("palette of pen commands"), + 'pensize':_("holds current pen size (can be used in place of a number block)"), + 'penup':_("turtle will not draw when moved"), + 'plus2':_("adds two numeric inputs"), + 'pop':_("pop value off FILO"), + 'portfolio':_("palette of presentation templates"), + 'print':_("prints value in status block at bottom of the screen"), + 'printheap':_("show FILO in status block"), + 'product2':_("multiplies two numeric inputs"), + 'push':_("push value onto FILO (first-in last-out) heap"), + 'random':_("returns random number between minimum (left) and maximum (right) values"), + 'remainder2':_("modular (remainder) operator"), + 'repeat':_("loop specified number of times"), + 'restore':_("restore blocks from trash"), + 'rightpos':_("xcor of right of screen"), + 'right':_("turn turtle clockwise (angle in degrees)"), + 'scale':_("holds current scale value (can be used in place of a number block)"), + 'setcolor':_("set color of the line drawn by the turtle"), + 'seth':_("set the heading of the turtle (0 is towards the top of the screen.)"), + 'setpensize':_("set size of the line drawn by the turtle"), + 'setscale':_("set the scale of media"), + 'setshade':_("set shade of the line drawn by the turtle"), + 'settextcolor':_("set color of text drawn by the turtle"), + 'settextsize':_("set size of text drawn by turtle"), + 'setxy':_("move turtle to position xcor, ycor; (0, 0) is in the center of the screen."), + 'shade':_("holds current pen shade (can be used in place of a number block)"), + 'show':_("draw text or show media from the Journal"), + 'sqrt':_("calculate square root"), + 'stack1':_("invoke action 1 stack"), + 'stack2':_("invoke action 2 stack"), + 'stack':_("invoke named action stack"), + 'start':_("connects action to toolbar run buttons"), + 'stopstack':_("do not continue current action"), + 'storeinbox1':_("store numeric value in variable 1"), + 'storeinbox2':_("store numeric value in variable 2"), + 'storein':_("store numeric value in named variable"), + 'string':_("string value"), + 'template1x1':_("presentation template: select Journal object (with description)"), + 'template2x1':_("presentation template: select two Journal objects"), + 'list':_("presentation template: list of bullets"), + 'template1x1a':_("presentation template: select Journal object (no description)"), + 'template1x2':_("presentation template: select two Journal objects"), + 'template2x2':_("presentation template: select four Journal objects"), + '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)"), + 'toppos':_("ycor of top of screen"), + 'trash':_("a place to throw away blocks"), + 'turtle':_("palette of turtle commands"), + 'height':_("the canvas height"), + 'vspace':_("jog stack down"), + 'wait':_("wait specified number of seconds"), + 'xcor':_("holds current x-coordinate value of the turtle (can be used in place of a number block)"), + 'ycor':_("holds current y-coordinate value of the turtle (can be used in place of a number block)")} + + +# # 'dead key' Unicode dictionaries # diff --git a/images/descon.svg b/images/descon.svg deleted file mode 100644 index 8148f3d..0000000 --- a/images/descon.svg +++ /dev/null @@ -1,54 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/images/numberoff.svg b/images/numbersoff.svg index cffabf7..cffabf7 100644 --- a/images/numberoff.svg +++ b/images/numbersoff.svg diff --git a/images/numberon.svg b/images/numberson.svg index 124994e..124994e 100644 --- a/images/numberon.svg +++ b/images/numberson.svg diff --git a/images/palettehorizontal.svg b/images/palettehorizontal.svg index ea61324..2fb09ea 100644 --- a/images/palettehorizontal.svg +++ b/images/palettehorizontal.svg @@ -14,18 +14,13 @@ transform="translate(3.5,2)" id="g3589" style="stroke:#ffffff;stroke-opacity:1"> - - - - + + diff --git a/images/palettevertical.svg b/images/palettevertical.svg index 2fb09ea..ea61324 100644 --- a/images/palettevertical.svg +++ b/images/palettevertical.svg @@ -14,13 +14,18 @@ transform="translate(3.5,2)" id="g3589" style="stroke:#ffffff;stroke-opacity:1"> - - + + + + diff --git a/images/texton.svg b/images/texton.svg deleted file mode 100644 index 0cbf077..0000000 --- a/images/texton.svg +++ /dev/null @@ -1,69 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - diff --git a/po/TurtleArt.pot b/po/TurtleArt.pot index af7848d..38e0f79 100644 --- a/po/TurtleArt.pot +++ b/po/TurtleArt.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2010-01-26 18:39+0000\n" +"POT-Creation-Date: 2010-02-01 22:04+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -20,327 +20,389 @@ msgstr "" #: /home/walter/Desktop/ta-refactoring/tawindow.py:590 #: /home/walter/Desktop/ta-refactoring/tahoverhelp.py:125 #: /home/walter/Desktop/ta-refactoring/turtleart.py:74 -#: /home/walter/Desktop/ta-refactoring/taexporthtml.py:285 +#: /home/walter/Desktop/ta-refactoring/taexporthtml.py:284 msgid "Turtle Art" msgstr "" -#: /home/walter/Desktop/ta-refactoring/constants.py:114 -msgid "clean" +#: /home/walter/Desktop/ta-refactoring/constants.py:131 +msgid "and" msgstr "" -#: /home/walter/Desktop/ta-refactoring/constants.py:114 -msgid "forward" +#: /home/walter/Desktop/ta-refactoring/constants.py:132 +msgid "arc" msgstr "" -#: /home/walter/Desktop/ta-refactoring/constants.py:115 +#: /home/walter/Desktop/ta-refactoring/constants.py:132 +msgid "angle" +msgstr "" + +#: /home/walter/Desktop/ta-refactoring/constants.py:132 +msgid "radius" +msgstr "" + +#: /home/walter/Desktop/ta-refactoring/constants.py:134 msgid "back" msgstr "" -#: /home/walter/Desktop/ta-refactoring/constants.py:116 -#: /home/walter/Desktop/ta-refactoring/constants.py:141 -msgid "left" +#: /home/walter/Desktop/ta-refactoring/constants.py:135 +msgid "blue" msgstr "" -#: /home/walter/Desktop/ta-refactoring/constants.py:116 -#: /home/walter/Desktop/ta-refactoring/constants.py:141 -msgid "right" +#: /home/walter/Desktop/ta-refactoring/constants.py:136 +#: /home/walter/Desktop/ta-refactoring/tahoverhelp.py:169 +msgid "bottom" msgstr "" -#: /home/walter/Desktop/ta-refactoring/constants.py:116 -msgid "set heading" +#: /home/walter/Desktop/ta-refactoring/constants.py:137 +msgid "box" msgstr "" -#: /home/walter/Desktop/ta-refactoring/constants.py:117 -msgid "show" +#: /home/walter/Desktop/ta-refactoring/constants.py:138 +#: /home/walter/Desktop/ta-refactoring/tahoverhelp.py:179 +msgid "box 1" msgstr "" -#: /home/walter/Desktop/ta-refactoring/constants.py:117 -#: /home/walter/Desktop/ta-refactoring/tahoverhelp.py:129 -msgid "set scale" +#: /home/walter/Desktop/ta-refactoring/constants.py:139 +#: /home/walter/Desktop/ta-refactoring/tahoverhelp.py:181 +msgid "box 2" msgstr "" -#: /home/walter/Desktop/ta-refactoring/constants.py:117 -#: /home/walter/Desktop/ta-refactoring/talogo.py:637 -#: /home/walter/Desktop/ta-refactoring/TurtleArtActivity.py:708 -#: /home/walter/Desktop/ta-refactoring/TurtleArtActivity.py:1150 -msgid "xcor" +#: /home/walter/Desktop/ta-refactoring/constants.py:140 +msgid "clean" msgstr "" -#: /home/walter/Desktop/ta-refactoring/constants.py:118 -#: /home/walter/Desktop/ta-refactoring/talogo.py:639 -#: /home/walter/Desktop/ta-refactoring/TurtleArtActivity.py:708 -#: /home/walter/Desktop/ta-refactoring/TurtleArtActivity.py:1150 -msgid "ycor" +#: /home/walter/Desktop/ta-refactoring/constants.py:141 +#: /home/walter/Desktop/ta-refactoring/tahoverhelp.py:163 +msgid "empty heap" msgstr "" -#: /home/walter/Desktop/ta-refactoring/constants.py:118 -#: /home/walter/Desktop/ta-refactoring/talogo.py:641 -#: /home/walter/Desktop/ta-refactoring/TurtleArtActivity.py:709 -#: /home/walter/Desktop/ta-refactoring/TurtleArtActivity.py:1151 -msgid "heading" +#: /home/walter/Desktop/ta-refactoring/constants.py:142 +#: /home/walter/Desktop/ta-refactoring/constants.py:146 +#: /home/walter/Desktop/ta-refactoring/tahoverhelp.py:142 +msgid "color" msgstr "" -#: /home/walter/Desktop/ta-refactoring/constants.py:118 -#: /home/walter/Desktop/ta-refactoring/tahoverhelp.py:133 -msgid "pen up" +#: /home/walter/Desktop/ta-refactoring/constants.py:143 +msgid "cyan" msgstr "" -#: /home/walter/Desktop/ta-refactoring/constants.py:119 -#: /home/walter/Desktop/ta-refactoring/tahoverhelp.py:132 -msgid "pen down" +#: /home/walter/Desktop/ta-refactoring/constants.py:146 +#: /home/walter/Desktop/ta-refactoring/tahoverhelp.py:130 +msgid "fill screen" msgstr "" -#: /home/walter/Desktop/ta-refactoring/constants.py:119 -#: /home/walter/Desktop/ta-refactoring/tahoverhelp.py:134 -msgid "set pen size" +#: /home/walter/Desktop/ta-refactoring/constants.py:146 +#: /home/walter/Desktop/ta-refactoring/constants.py:199 +msgid "shade" msgstr "" -#: /home/walter/Desktop/ta-refactoring/constants.py:120 -msgid "arc" +#: /home/walter/Desktop/ta-refactoring/constants.py:147 +msgid "forever" msgstr "" -#: /home/walter/Desktop/ta-refactoring/constants.py:120 -msgid "angle" +#: /home/walter/Desktop/ta-refactoring/constants.py:148 +msgid "forward" msgstr "" -#: /home/walter/Desktop/ta-refactoring/constants.py:120 -msgid "radius" +#: /home/walter/Desktop/ta-refactoring/constants.py:149 +msgid "green" msgstr "" -#: /home/walter/Desktop/ta-refactoring/constants.py:121 -#: /home/walter/Desktop/ta-refactoring/tahoverhelp.py:140 -msgid "set text size" +#: /home/walter/Desktop/ta-refactoring/constants.py:150 +#: /home/walter/Desktop/ta-refactoring/constants.py:202 +#: /home/walter/Desktop/ta-refactoring/constants.py:332 +#: /home/walter/Desktop/ta-refactoring/constants.py:353 +msgid "action" msgstr "" -#: /home/walter/Desktop/ta-refactoring/constants.py:121 -#: /home/walter/Desktop/ta-refactoring/tahoverhelp.py:135 -msgid "set color" +#: /home/walter/Desktop/ta-refactoring/constants.py:151 +#: /home/walter/Desktop/ta-refactoring/constants.py:203 +msgid "action 1" msgstr "" -#: /home/walter/Desktop/ta-refactoring/constants.py:122 -#: /home/walter/Desktop/ta-refactoring/tahoverhelp.py:136 -msgid "set shade" +#: /home/walter/Desktop/ta-refactoring/constants.py:152 +#: /home/walter/Desktop/ta-refactoring/constants.py:204 +msgid "action 2" msgstr "" -#: /home/walter/Desktop/ta-refactoring/constants.py:123 -#: /home/walter/Desktop/ta-refactoring/tahoverhelp.py:130 -msgid "fill screen" +#: /home/walter/Desktop/ta-refactoring/constants.py:153 +#: /home/walter/Desktop/ta-refactoring/talogo.py:168 +#: /home/walter/Desktop/ta-refactoring/TurtleArtActivity.py:709 +#: /home/walter/Desktop/ta-refactoring/TurtleArtActivity.py:1151 +msgid "heading" msgstr "" -#: /home/walter/Desktop/ta-refactoring/constants.py:123 -#: /home/walter/Desktop/ta-refactoring/constants.py:126 -#: /home/walter/Desktop/ta-refactoring/tahoverhelp.py:142 -msgid "color" +#: /home/walter/Desktop/ta-refactoring/constants.py:154 +#: /home/walter/Desktop/ta-refactoring/tahoverhelp.py:167 +msgid "height" msgstr "" -#: /home/walter/Desktop/ta-refactoring/constants.py:123 -#: /home/walter/Desktop/ta-refactoring/constants.py:124 -msgid "shade" +#: /home/walter/Desktop/ta-refactoring/constants.py:155 +#: /home/walter/Desktop/ta-refactoring/tahoverhelp.py:188 +msgid "hide blocks" msgstr "" -#: /home/walter/Desktop/ta-refactoring/constants.py:125 -#: /home/walter/Desktop/ta-refactoring/tahoverhelp.py:137 -msgid "pen size" +#: /home/walter/Desktop/ta-refactoring/constants.py:158 +#: /home/walter/Desktop/ta-refactoring/constants.py:159 +msgid "if" msgstr "" -#: /home/walter/Desktop/ta-refactoring/constants.py:125 -#: /home/walter/Desktop/ta-refactoring/tahoverhelp.py:138 -msgid "text size" +#: /home/walter/Desktop/ta-refactoring/constants.py:158 +msgid "then" msgstr "" -#: /home/walter/Desktop/ta-refactoring/constants.py:128 -#: /home/walter/Desktop/ta-refactoring/tahoverhelp.py:149 -msgid "mod" +#: /home/walter/Desktop/ta-refactoring/constants.py:159 +msgid "then else" msgstr "" -#: /home/walter/Desktop/ta-refactoring/constants.py:129 -msgid "random" +#: /home/walter/Desktop/ta-refactoring/constants.py:161 +msgid "query keyboard" msgstr "" -#: /home/walter/Desktop/ta-refactoring/constants.py:129 -msgid "min" +#: /home/walter/Desktop/ta-refactoring/constants.py:162 +msgid "keyboard" msgstr "" -#: /home/walter/Desktop/ta-refactoring/constants.py:129 -msgid "max" +#: /home/walter/Desktop/ta-refactoring/constants.py:163 +#: /home/walter/Desktop/ta-refactoring/constants.py:164 +msgid "left" msgstr "" -#: /home/walter/Desktop/ta-refactoring/constants.py:130 -msgid "and" +#: /home/walter/Desktop/ta-refactoring/constants.py:166 +msgid "list" msgstr "" -#: /home/walter/Desktop/ta-refactoring/constants.py:131 -msgid "not" +#: /home/walter/Desktop/ta-refactoring/constants.py:168 +msgid "Python" msgstr "" -#: /home/walter/Desktop/ta-refactoring/constants.py:131 -msgid "print" +#: /home/walter/Desktop/ta-refactoring/constants.py:168 +msgid "code" msgstr "" -#: /home/walter/Desktop/ta-refactoring/constants.py:131 -msgid "wait" +#: /home/walter/Desktop/ta-refactoring/constants.py:168 +msgid "value" msgstr "" -#: /home/walter/Desktop/ta-refactoring/constants.py:131 +#: /home/walter/Desktop/ta-refactoring/constants.py:169 +msgid " " +msgstr "" + +#: /home/walter/Desktop/ta-refactoring/constants.py:170 +msgid "not" +msgstr "" + +#: /home/walter/Desktop/ta-refactoring/constants.py:172 +msgid "orange" +msgstr "" + +#: /home/walter/Desktop/ta-refactoring/constants.py:173 msgid "or" msgstr "" -#: /home/walter/Desktop/ta-refactoring/constants.py:132 -msgid "forever" +#: /home/walter/Desktop/ta-refactoring/constants.py:174 +#: /home/walter/Desktop/ta-refactoring/tahoverhelp.py:132 +msgid "pen down" msgstr "" -#: /home/walter/Desktop/ta-refactoring/constants.py:132 -msgid "repeat" +#: /home/walter/Desktop/ta-refactoring/constants.py:175 +#: /home/walter/Desktop/ta-refactoring/tahoverhelp.py:137 +msgid "pen size" msgstr "" -#: /home/walter/Desktop/ta-refactoring/constants.py:132 -msgid "if then" +#: /home/walter/Desktop/ta-refactoring/constants.py:176 +#: /home/walter/Desktop/ta-refactoring/tahoverhelp.py:133 +msgid "pen up" msgstr "" -#: /home/walter/Desktop/ta-refactoring/constants.py:133 -msgid "stop action" +#: /home/walter/Desktop/ta-refactoring/constants.py:178 +msgid "pop" msgstr "" -#: /home/walter/Desktop/ta-refactoring/constants.py:134 -#: /home/walter/Desktop/ta-refactoring/taproject.py:220 -msgid "start" +#: /home/walter/Desktop/ta-refactoring/constants.py:179 +msgid "show heap" msgstr "" -#: /home/walter/Desktop/ta-refactoring/constants.py:134 -#: /home/walter/Desktop/ta-refactoring/constants.py:135 -msgid "action 1" +#: /home/walter/Desktop/ta-refactoring/constants.py:180 +msgid "print" msgstr "" -#: /home/walter/Desktop/ta-refactoring/constants.py:136 -msgid "action 2" +#: /home/walter/Desktop/ta-refactoring/constants.py:182 +msgid "purple" msgstr "" -#: /home/walter/Desktop/ta-refactoring/constants.py:137 -#: /home/walter/Desktop/ta-refactoring/constants.py:200 -msgid "action" +#: /home/walter/Desktop/ta-refactoring/constants.py:183 +msgid "push" msgstr "" -#: /home/walter/Desktop/ta-refactoring/constants.py:138 -#: /home/walter/Desktop/ta-refactoring/tahoverhelp.py:178 -msgid "store in box 1" +#: /home/walter/Desktop/ta-refactoring/constants.py:184 +msgid "random" msgstr "" -#: /home/walter/Desktop/ta-refactoring/constants.py:138 -#: /home/walter/Desktop/ta-refactoring/tahoverhelp.py:179 -msgid "box 1" +#: /home/walter/Desktop/ta-refactoring/constants.py:184 +msgid "min" msgstr "" -#: /home/walter/Desktop/ta-refactoring/constants.py:139 -#: /home/walter/Desktop/ta-refactoring/tahoverhelp.py:180 -msgid "store in box 2" +#: /home/walter/Desktop/ta-refactoring/constants.py:184 +msgid "max" msgstr "" -#: /home/walter/Desktop/ta-refactoring/constants.py:139 -#: /home/walter/Desktop/ta-refactoring/tahoverhelp.py:181 -msgid "box 2" +#: /home/walter/Desktop/ta-refactoring/constants.py:185 +msgid "red" msgstr "" -#: /home/walter/Desktop/ta-refactoring/constants.py:140 -#: /home/walter/Desktop/ta-refactoring/tahoverhelp.py:182 -msgid "store in" +#: /home/walter/Desktop/ta-refactoring/constants.py:186 +#: /home/walter/Desktop/ta-refactoring/tahoverhelp.py:149 +msgid "mod" msgstr "" -#: /home/walter/Desktop/ta-refactoring/constants.py:140 -msgid "box" +#: /home/walter/Desktop/ta-refactoring/constants.py:187 +msgid "repeat" msgstr "" -#: /home/walter/Desktop/ta-refactoring/constants.py:140 -#: /home/walter/Desktop/ta-refactoring/tahoverhelp.py:160 -msgid "string" +#: /home/walter/Desktop/ta-refactoring/constants.py:188 +msgid "restore" msgstr "" -#: /home/walter/Desktop/ta-refactoring/constants.py:141 -msgid "top" +#: /home/walter/Desktop/ta-refactoring/constants.py:189 +#: /home/walter/Desktop/ta-refactoring/constants.py:190 +msgid "right" msgstr "" -#: /home/walter/Desktop/ta-refactoring/constants.py:142 -#: /home/walter/Desktop/ta-refactoring/tahoverhelp.py:169 -msgid "bottom" +#: /home/walter/Desktop/ta-refactoring/constants.py:191 +msgid "scale" msgstr "" -#: /home/walter/Desktop/ta-refactoring/constants.py:142 -#: /home/walter/Desktop/ta-refactoring/tahoverhelp.py:168 -msgid "width" +#: /home/walter/Desktop/ta-refactoring/constants.py:192 +#: /home/walter/Desktop/ta-refactoring/tahoverhelp.py:135 +msgid "set color" msgstr "" -#: /home/walter/Desktop/ta-refactoring/constants.py:142 -#: /home/walter/Desktop/ta-refactoring/tahoverhelp.py:167 -msgid "height" +#: /home/walter/Desktop/ta-refactoring/constants.py:193 +msgid "set heading" msgstr "" -#: /home/walter/Desktop/ta-refactoring/constants.py:143 -#: /home/walter/Desktop/ta-refactoring/tahoverhelp.py:188 -msgid "hide blocks" +#: /home/walter/Desktop/ta-refactoring/constants.py:194 +#: /home/walter/Desktop/ta-refactoring/tahoverhelp.py:134 +msgid "set pen size" +msgstr "" + +#: /home/walter/Desktop/ta-refactoring/constants.py:195 +#: /home/walter/Desktop/ta-refactoring/tahoverhelp.py:129 +msgid "set scale" msgstr "" -#: /home/walter/Desktop/ta-refactoring/constants.py:144 +#: /home/walter/Desktop/ta-refactoring/constants.py:196 +#: /home/walter/Desktop/ta-refactoring/tahoverhelp.py:136 +msgid "set shade" +msgstr "" + +#: /home/walter/Desktop/ta-refactoring/constants.py:197 +#: /home/walter/Desktop/ta-refactoring/tahoverhelp.py:140 +msgid "set text size" +msgstr "" + +#: /home/walter/Desktop/ta-refactoring/constants.py:198 #: /home/walter/Desktop/ta-refactoring/tahoverhelp.py:127 msgid "set xy" msgstr "" -#: /home/walter/Desktop/ta-refactoring/constants.py:144 -#: /home/walter/Desktop/ta-refactoring/constants.py:201 +#: /home/walter/Desktop/ta-refactoring/constants.py:198 +#: /home/walter/Desktop/ta-refactoring/constants.py:339 msgid "x" msgstr "" -#: /home/walter/Desktop/ta-refactoring/constants.py:144 +#: /home/walter/Desktop/ta-refactoring/constants.py:198 msgid "y" msgstr "" -#: /home/walter/Desktop/ta-refactoring/constants.py:145 -msgid "scale" +#: /home/walter/Desktop/ta-refactoring/constants.py:200 +msgid "show" msgstr "" -#: /home/walter/Desktop/ta-refactoring/constants.py:145 -msgid "keyboard" +#: /home/walter/Desktop/ta-refactoring/constants.py:205 +#: /home/walter/Desktop/ta-refactoring/tawindow.py:1502 +msgid "start" msgstr "" -#: /home/walter/Desktop/ta-refactoring/constants.py:146 -msgid "push" +#: /home/walter/Desktop/ta-refactoring/constants.py:206 +msgid "stop action" msgstr "" -#: /home/walter/Desktop/ta-refactoring/constants.py:146 -msgid "pop" +#: /home/walter/Desktop/ta-refactoring/constants.py:207 +#: /home/walter/Desktop/ta-refactoring/tahoverhelp.py:182 +msgid "store in" msgstr "" -#: /home/walter/Desktop/ta-refactoring/constants.py:146 -msgid "query keyboard" +#: /home/walter/Desktop/ta-refactoring/constants.py:208 +#: /home/walter/Desktop/ta-refactoring/tahoverhelp.py:178 +msgid "store in box 1" msgstr "" -#: /home/walter/Desktop/ta-refactoring/constants.py:147 -msgid "python" +#: /home/walter/Desktop/ta-refactoring/constants.py:209 +#: /home/walter/Desktop/ta-refactoring/tahoverhelp.py:180 +msgid "store in box 2" msgstr "" -#: /home/walter/Desktop/ta-refactoring/constants.py:147 -msgid "code" +#: /home/walter/Desktop/ta-refactoring/constants.py:210 +#: /home/walter/Desktop/ta-refactoring/constants.py:352 +#: /home/walter/Desktop/ta-refactoring/constants.py:357 +msgid "text" msgstr "" -#: /home/walter/Desktop/ta-refactoring/constants.py:147 -msgid "value" +#: /home/walter/Desktop/ta-refactoring/constants.py:215 +#: /home/walter/Desktop/ta-refactoring/tahoverhelp.py:138 +msgid "text size" msgstr "" -#: /home/walter/Desktop/ta-refactoring/constants.py:148 -msgid "show heap" +#: /home/walter/Desktop/ta-refactoring/constants.py:216 +msgid "top" msgstr "" -#: /home/walter/Desktop/ta-refactoring/constants.py:149 -#: /home/walter/Desktop/ta-refactoring/tahoverhelp.py:163 -msgid "empty heap" +#: /home/walter/Desktop/ta-refactoring/constants.py:217 +msgid "turtle" msgstr "" -#: /home/walter/Desktop/ta-refactoring/constants.py:195 -msgid "text" +#: /home/walter/Desktop/ta-refactoring/constants.py:219 +msgid "wait" msgstr "" -#: /home/walter/Desktop/ta-refactoring/constants.py:199 +#: /home/walter/Desktop/ta-refactoring/constants.py:220 +#: /home/walter/Desktop/ta-refactoring/tahoverhelp.py:168 +msgid "width" +msgstr "" + +#: /home/walter/Desktop/ta-refactoring/constants.py:221 +#: /home/walter/Desktop/ta-refactoring/talogo.py:168 +#: /home/walter/Desktop/ta-refactoring/TurtleArtActivity.py:708 +#: /home/walter/Desktop/ta-refactoring/TurtleArtActivity.py:1150 +msgid "xcor" +msgstr "" + +#: /home/walter/Desktop/ta-refactoring/constants.py:222 +#: /home/walter/Desktop/ta-refactoring/talogo.py:168 +#: /home/walter/Desktop/ta-refactoring/TurtleArtActivity.py:708 +#: /home/walter/Desktop/ta-refactoring/TurtleArtActivity.py:1150 +msgid "ycor" +msgstr "" + +#: /home/walter/Desktop/ta-refactoring/constants.py:223 +msgid "yellow" +msgstr "" + +#: /home/walter/Desktop/ta-refactoring/constants.py:328 +#: /home/walter/Desktop/ta-refactoring/constants.py:356 msgid "my box" msgstr "" +#: /home/walter/Desktop/ta-refactoring/constants.py:337 +#: /home/walter/Desktop/ta-refactoring/constants.py:358 +#: /home/walter/Desktop/ta-refactoring/constants.py:359 +#: /home/walter/Desktop/ta-refactoring/constants.py:360 +#: /home/walter/Desktop/ta-refactoring/constants.py:361 +msgid "Title" +msgstr "" + #: /home/walter/Desktop/ta-refactoring/tahoverhelp.py:26 msgid "palette of turtle commands" msgstr "" @@ -816,6 +878,10 @@ msgstr "" msgid "stopstack" msgstr "" +#: /home/walter/Desktop/ta-refactoring/tahoverhelp.py:160 +msgid "string" +msgstr "" + #: /home/walter/Desktop/ta-refactoring/tahoverhelp.py:161 msgid "Extras" msgstr "" @@ -903,6 +969,10 @@ msgstr "" msgid "template" msgstr "" +#: /home/walter/Desktop/ta-refactoring/talogo.py:588 +msgid "I don't know how to" +msgstr "" + #: /home/walter/Desktop/ta-refactoring/TurtleArtActivity.py:135 msgid "presentation" msgstr "" diff --git a/tagplay.py b/tagplay.py index dff272d..00d0019 100644 --- a/tagplay.py +++ b/tagplay.py @@ -37,10 +37,8 @@ gobject.threads_init() try: from sugar.datastore import datastore -except: - # probably launched from outside of Sugar +except ImportError: pass -from talogo import * class Gplay: @@ -145,18 +143,6 @@ def play_audio(lc, filepath): lc.gplay = Gplay() lc.gplay.setFile("file:///" + filepath) -def play_video(lc, media, x, y, w, h): - print "loading media id: " + str(media) - if media == "" or media[6:] == "": - raise logoerror("#nomedia") - elif media[6:] != "None": - try: - dsobject = datastore.get(media[6:]) - print dsobject.file_path - except: - print "Couldn't open id: " + str(media[6:]) - play_dsobject(lc, dsobject, x, y, w, h) - def play_movie_from_file(lc, filepath, x, y, w, h): if lc.gplay == None: lc.gplay = Gplay() diff --git a/tahoverhelp.py b/tahoverhelp.py deleted file mode 100644 index db2cdfc..0000000 --- a/tahoverhelp.py +++ /dev/null @@ -1,198 +0,0 @@ -# -*- coding: utf-8 -*- -#Copyright (c) 2009, Walter Bender, Raúl Gutiérrez Segalés - -#Permission is hereby granted, free of charge, to any person obtaining a copy -#of this software and associated documentation files (the "Software"), to deal -#in the Software without restriction, including without limitation the rights -#to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -#copies of the Software, and to permit persons to whom the Software is -#furnished to do so, subject to the following conditions: - -#The above copyright notice and this permission notice shall be included in -#all copies or substantial portions of the Software. - -#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -#IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -#FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -#AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -#LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -#OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -#THE SOFTWARE. - -# popup help dictionary - -from gettext import gettext as _ -hover_dict = { \ - "turtle":_("palette of turtle commands"), \ - "pen":_("palette of pen commands"), \ - "numbers":_("palette of numeric operators"), \ - "sensors":_("palette of extra options"), \ - "flow":_("palette of flow operators"), \ - "myblocks":_("palette of variable blocks"), \ - "templates":_("palette of presentation templates"), \ - "clean":_("clear the screen and reset the turtle"), \ - "forward":_("move turtle forward"), \ - "back":_("move turtle backward"), \ - "left":_("turn turtle counterclockwise (angle in degrees)"), \ - "right":_("turn turtle clockwise (angle in degrees)"), \ - "arc":_("move turtle along an arc"), \ - "setxy":_("move turtle to position xcor, ycor; (0, 0) is in the center of the screen."), \ - "seth":_("set the heading of the turtle (0 is towards the top of the screen.)"), \ - "show":_("draw text or show media from the Journal"), \ - "setscale":_("set the scale of media"), \ - "xcor":_("holds current x-coordinate value of the turtle (can be used in place of a number block)"), \ - "ycor":_("holds current y-coordinate value of the turtle (can be used in place of a number block)"), \ - "heading":_("holds current heading value of the turtle (can be used in place of a number block)"), \ - "scale":_("holds current scale value (can be used in place of a number block)"), \ - "penup":_("turtle will not draw when moved"), \ - "pendown":_("turtle will draw when moved"), \ - "setpensize":_("set size of the line drawn by the turtle"), \ - "setcolor":_("set color of the line drawn by the turtle"), \ - "setshade":_("set shade of the line drawn by the turtle"), \ - "settextcolor":_("set color of text drawn by the turtle"), \ - "settextsize":_("set size of text drawn by turtle"), \ - "fillscreen":_("fills the background with (color, shade)"), \ - "pensize":_("holds current pen size (can be used in place of a number block)"), \ - "color":_("holds current pen color (can be used in place of a number block)"), \ - "shade":_("holds current pen shade (can be used in place of a number block)"), \ - "textsize":_("holds current text size (can be used in place of a number block)"), \ - "textcolor":_("holds current text color (can be used in place of a number block)"), \ - "number":_("used as numeric input in mathematic operators"), \ - "plus2":_("adds two numeric inputs"), \ - "minus2":_("subtracts bottom numeric input from top numeric input"), \ - "product2":_("multiplies two numeric inputs"), \ - "division2":_("divides top numeric input (numerator) by bottom numeric input (denominator)"), \ - "remainder2":_("modular (remainder) operator"), \ - "identity":_("identity operator used for extending blocks"), \ - "identity2":_("identity operator used for extending blocks"), \ - "sqrt":_("calculate square root"), \ - "random":_("returns random number between minimum (left) and maximum (right) values"), \ - "equal":_("logical equal-to operator"), \ - "greater":_("logical greater-than operator"), \ - "less":_("logical less-than operator"), \ - "and":_("logical AND operator"), \ - "or":_("logical OR operator"), \ - "not":_("logical NOT operator"), \ - "print":_("prints value in status block at bottom of the screen"), \ - "kbinput":_("query for keyboard input (results stored in keyboard block)"), \ - "keyboard":_("holds results of query-keyboard block"), \ - "nop":_("runs code found in the tamyblock.py module found in the Journal"), \ - "myfunc":_("a programmable block: add your own math equation in the block, e.g., sin(x)"), \ - "hres":_("the canvas width"), \ - "vres":_("the canvas height"), \ - "leftpos":_("xcor of left of screen"), \ - "toppos":_("ycor of top of screen"), \ - "rightpos":_("xcor of right of screen"), \ - "bottompos":_("ycor of bottom of screen"), \ - "push":_("push value onto FILO (first-in last-out) heap"), \ - "pop":_("pop value off FILO"), \ - "prnthear":_("show FILO in status block"), \ - "clearheap":_("empty FILO"), \ - "wait":_("wait specified number of seconds"), \ - "forever":_("loop forever"), \ - "repeat":_("loop specified number of times"), \ - "if":_("if-then operator that uses boolean operators from Numbers palette"), \ - "ifelse":_("if-then-else operator that uses boolean operators from Numbers palette"), \ - "stopstack":_("do not continue current action"), \ - "hspace":_("jog stack right"), \ - "vspace":_("jog stack down"), \ - "start":_("connects action to toolbar run buttons"), \ - "hat1":_("top of action 1 stack"), \ - "stack1":_("invoke action 1 stack"), \ - "hat2":_("top of action 2 stack"), \ - "stack2":_("invoke action 2 stack"), \ - "hat":_("top of nameable action stack"), \ - "stack":_("invoke named action stack"), \ - "storeinbox1":_("store numeric value in variable 1"), \ - "box1":_("variable 1 (numeric value)"), \ - "storeinbox2":_("store numeric value in variable 2"), \ - "box2":_("variable 2 (numeric value)"), \ - "storein":_("store numeric value in named variable"), \ - "box":_("named variable (numeric value)"), \ - "string":_("string value"), \ - "journal":_("Sugar Journal media object"), \ - "audiooff":_("Sugar Journal audio object"), \ - "descriptionoff":_("Sugar Journal description field"), \ - "template1":_("presentation template: select Journal object (with description)"), \ - "template2":_("presentation template: select two Journal objects"), \ - "template6":_("presentation template: select two Journal objects"), \ - "template7":_("presentation template: select four Journal objects"), \ - "template4":_("presentation template: select Journal object (no description)"), \ - "template3":_("presentation template: seven bullets"), \ - "hideblocks":_("declutter canvas by hiding blocks")} - -blocks_dict = { - 'TurtleArt' : _('Turtle Art'), - 'turtle' : _('Turtle'), - 'setxy' : _('set xy'), - 'seth' : _('seth'), - 'setscale' : _('set scale'), - 'fillscreen' : _('fill screen'), - 'pen' : _('Pen'), - 'pendown' : _('pen down'), - 'penup' : _('pen up'), - 'setpensize' : _('set pen size'), - 'setcolor' : _('set color'), - 'setshade' : _('set shade'), - 'pensize' : _('pen size'), - 'textsize' : _('text size'), - 'textcolor' : _('text color'), - 'settextsize' : _('set text size'), - 'settextcolor' : _('set text color'), - 'color' : _('color'), - 'greater' : _('greater'), - 'numbers' : _('Numbers'), - 'division2' : _('division'), - 'equal' : _('equal'), - 'plus2' : _('plus2'), - 'product2' : _('product2'), - 'remainder2' : _('mod'), - 'identity' : _('identity'), - 'identity2' : _('identity2'), - 'less' : _('less'), - 'minus2' : _('minus2'), - 'sqrt' : _('sqrt'), - 'ifelse' : _('else'), - 'flow' : _('Flow'), - 'hspace' : _('hspace'), - 'vspace' : _('vspace'), - 'stopstack' : _('stopstack'), - 'string' : _('string'), - 'sensors' : _('Extras'), - 'clearheap' : _('clearheap'), - 'emptyheap' : _('empty heap'), - 'loadmyblock' : _('load my block'), - 'myfunc' : _('myfunc'), - 'toppos' : _('toppos'), - 'vres' : _('height'), - 'hres' : _('width'), - 'bottompos' : _('bottom'), - 'kbinput' : _('read key'), - 'leftpos' : _('leftpos'), - 'rightpos' : _('rightpos'), - 'printheap' : _('printheap'), - 'myblocks' : _('My Blocks'), - 'stack' : _('stack'), - 'stack2' : _('stack 2'), - 'stack1' : _('stack 1'), - 'storeinbox1' : _('store in box 1'), - 'box1' : _('box 1'), - 'storeinbox2' : _('store in box 2'), - 'box2' : _('box 2'), - 'storein' : _('store in'), - 'hat' : _('hat'), - 'hat1' : _('hat1'), - 'hat2' : _('hat2'), - 'nop' : _('nop'), - 'templates' : _('Templates'), - 'hideblocks' : _('hide blocks'), - 'journal' : _('journal'), - 'audiooff' : _('journal'), - 'descriptionoff' : _('journal'), - 'template1' : _('template'), - 'template2' : _('template'), - 'template3' : _('template'), - 'template4' : _('template'), - 'template6' : _('template'), - 'template7' : _('template') -} diff --git a/tajail.py b/tajail.py index 10ec9d9..3283723 100644 --- a/tajail.py +++ b/tajail.py @@ -25,7 +25,6 @@ try: from numpy import * except ImportError: pass -from tacanvas import * def myfunc(lc, f, x): # check to make sure no import calls are made diff --git a/talogo.py b/talogo.py index d812ddb..c266433 100644 --- a/talogo.py +++ b/talogo.py @@ -36,7 +36,6 @@ except: pass from constants import * -from tacanvas import * from tagplay import play_audio, play_movie_from_file, stop_media from tajail import myfunc, myfunc_import diff --git a/taproject.py b/taproject.py deleted file mode 100644 index 5227d97..0000000 --- a/taproject.py +++ /dev/null @@ -1,354 +0,0 @@ -#Copyright (c) 2007-8, Playful Invention Company. -#Copyright (c) 2008-10, Walter Bender - -#Permission is hereby granted, free of charge, to any person obtaining a copy -#of this software and associated documentation files (the "Software"), to deal -#in the Software without restriction, including without limitation the rights -#to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -#copies of the Software, and to permit persons to whom the Software is -#furnished to do so, subject to the following conditions: - -#The above copyright notice and this permission notice shall be included in -#all copies or substantial portions of the Software. - -#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -#IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -#FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -#AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -#LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -#OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -#THE SOFTWARE. - -import pygtk -pygtk.require('2.0') -import gtk -import pickle -try: - _old_Sugar_system = False - import json - json.dumps - from json import load as jload - from json import dump as jdump -except (ImportError, AttributeError): - try: - import simplejson as json - from simplejson import load as jload - from simplejson import dump as jdump - except: - _old_Sugar_system = True - -from StringIO import StringIO -import os.path - -from tacanvas import * -from talogo import stop_logo, get_pixbuf_from_journal, movie_media_type -try: - from sugar.datastore import datastore -except: - pass -import block -import sprites -from constants import * -from gettext import gettext as _ - -def new_project(tw): - stop_logo(tw) - for b in tw._just_blocks(): - b.spr.hide() - tw.canvas.clearscreen() - tw.save_file_name = None - -def load_file(tw, create_new_project=True): - fname = get_load_name(tw, '.ta') - if fname==None: - return - if fname[-3:] == '.ta': - fname=fname[0:-3] - load_files(tw, fname+'.ta', create_new_project) - if create_new_project is True: - tw.save_file_name = os.path.basename(fname) - -# From Suger, we use the Journal, but from outside of Sugar, we load from a file -def load_python_code(tw): - fname = get_load_name(tw, '.py') - if fname==None: - return - f = open(fname, 'r') - tw.myblock = f.read() - f.close() - -# -# We try to maintain read-compatibility with all versions of Turtle Art. -# Try pickle first; then two different versions of json. -# -def load_files(tw, ta_file, create_new_project=True): - # Just open the .ta file, ignoring any .png file that might be present. - f = open(ta_file, "r") - try: - data = pickle.load(f) - except: - # Rewind necessary because of failed pickle.load attempt - f.seek(0) - text = f.read() - data = _json_load(text) - f.close() - if create_new_project is True: - new_project(tw) - read_data(tw, data) - -def _json_load(text): - if _old_Sugar_system is True: - listdata = json.read(text) - else: - io = StringIO(text) - listdata = jload(io) - # json converts tuples to lists, so we need to convert back, - return _tuplify(listdata) - -def get_load_name(tw, suffix): - dialog = gtk.FileChooserDialog("Load...", None, - gtk.FILE_CHOOSER_ACTION_OPEN, - (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, - gtk.STOCK_OPEN, gtk.RESPONSE_OK)) - dialog.set_default_response(gtk.RESPONSE_OK) - return _do_dialog(tw, dialog, suffix) - -# Unpack serialized data sent across a share. -def load_string(tw, text): - data = _json_load(text) - new_project(tw) - read_data(tw, data) - -# Unpack serialized data from the clipboard. -def clone_stack(tw, text): - data = _json_load(text) - read_data(tw, data) - -def _tuplify(t): - if type(t) is not list: - return t - return tuple(map(_tuplify, t)) - -def read_data(tw, data): - # First we create the blocks - blocks = [] - t = 0 - for b in data: - if b[1] == 'turtle': - load_turtle(tw, b) - t = 1 - else: - blk = load_block(tw, b); blocks.append(blk) - # Then we make the connections - for i in range(len(blocks)): - cons=[] - for c in data[i][4]: - if c is None: - cons.append(None) - else: - cons.append(blocks[c]) - blocks[i].connections = cons - # Then we need to adjust the x,y positions, as block sizes may have changed - for b in blocks: - (sx, sy) = b.spr.get_xy() - for i, c in enumerate(b.connections): - if c is not None: - bdock = b.docks[i] - 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): - # A block is saved as: (i, (btype, value), x, y, (c0,... cn)) - # The x,y position is saved/loaded for backward compatibility reasons only - btype, value = b[1], None - if type(btype) == type((1,2)): - btype, value = btype - if btype in CONTENT_BLOCKS: - if btype == 'number': - try: - values = [int(value)] - except ValueError: - values = [float(value)] - else: - values = [value] - else: - values = [] - - if OLD_NAMES.has_key(btype): - btype = OLD_NAMES[btype] - - blk = block.Block(tw.block_list, tw.sprite_list, - btype, b[2]+tw.canvas.cx, - b[3]+tw.canvas.cy, 'block', values) - # Some blocks get a skin. - if btype == 'nop': - if tw.nop == 'pythonloaded': - blk.spr.set_image(tw.media_shapes['pythonon'], 1, 17, 8) - else: - blk.spr.set_image(tw.media_shapes['pythonoff'], 1, 17, 8) - blk.spr.set_label(' ') - elif btype in EXPANDABLE: - if btype == 'vspace': - blk.expand_in_y(value) - elif btype == 'hspace': - blk.expand_in_x(value) - elif btype == 'list': - for i in range(len(b[4])-4): - dy = blk.add_arg() - elif btype in BOX_STYLE_MEDIA and len(blk.values)>0: - if btype == 'audio' or btype == 'description': - print "restoring %s to %s block" % (blk.values[0],blk.name) - blk.spr.set_image(tw.media_shapes[btype+'on'], 1, 37, 6) - elif tw.running_sugar(): - try: - if blk.values[0] != 'None': - dsobject = datastore.get(blk.values[0]) - if not movie_media_type(dsobject.file_path[-4:]): - pixbuf = get_pixbuf_from_journal(dsobject, 80, 60) - if pixbuf is not None: - blk.spr.set_image(pixbuf, 1, 17, 2) - else: - blk.spr.set_image(tw.media_shapes['journalon'], - 1, 37, 6) - dsobject.destroy() - except: - print "couldn't open dsobject (%s)" % (blk.values[0]) - else: - if not movie_media_type(blk.values[0][-4:]): - pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(blk.values[0], - 80, 60) - if pixbuf is not None: - blk.spr.set_image(pixbuf, 1, 17, 2) - else: - blk.spr.set_image(tw.media_shapes['journalon'], 1, 37, 6) - blk.spr.set_label(' ') - blk.resize() - elif btype in BOX_STYLE_MEDIA: - blk.spr.set_label(' ') - blk.spr.set_image(tw.media_shapes[btype+'off'], 1, 37, 6) - - blk.spr.set_layer(BLOCK_LAYER) - return blk - -def load_turtle(tw, b): - id, name, xcor, ycor, heading, color, shade, pensize = b - tw.canvas.setxy(xcor, ycor) - tw.canvas.seth(heading) - tw.canvas.setcolor(color) - tw.canvas.setshade(shade) - tw.canvas.setpensize(pensize) - -# start a new project with a start brick -def load_start(tw): - clone_stack(tw,"%s%s%s" % ("[[0,[\"start\",\"", _("start"), - "\"],250,250,[null,null]]]")) - -# -# Everything below is suspect -# mix and match of old and new -# procced with caution -# -def save_file(tw): - if tw.save_folder is not None: - tw.load_save_folder = tw.save_folder - fname = _get_save_name(tw) - if fname is None: - return - if fname[-3:]=='.ta': - fname=fname[0:-3] - save_data(tw,fname+".ta") - tw.save_file_name = os.path.basename(fname) - -def _get_save_name(tw): - dialog = gtk.FileChooserDialog("Save...", None, - gtk.FILE_CHOOSER_ACTION_SAVE, - (gtk.STOCK_CANCEL, - gtk.RESPONSE_CANCEL, - gtk.STOCK_SAVE, - gtk.RESPONSE_OK)) - dialog.set_default_response(gtk.RESPONSE_OK) - if tw.save_file_name is not None: - dialog.set_current_name(tw.save_file_name+'.ta') - return _do_dialog(tw, dialog, '.ta') - -def save_data(tw, fname): - f = file(fname, "w") - data = _assemble_data_to_save(tw) - f.write(_json_dump(data)) - f.close() - -def _json_dump(data): - if _old_Sugar_system is True: - return json.write(data) - else: - io = StringIO() - jdump(data,io) - return io.getvalue() - -# Used to send data across a shared session -def save_string(tw, save_turtle=True): - data = _assemble_data_to_save(tw, save_turtle) - return _json_dump(data) - -def _assemble_data_to_save(tw, save_turtle=True): - data = [] - for i, b in enumerate(tw._just_blocks()): - b.id = i - for b in tw._just_blocks(): - if b.name in CONTENT_BLOCKS: - name = (b.name, b.values[0]) - elif b.name in EXPANDABLE: - ex, ey = b.get_expand_x_y() - if ex > 0: - name = (b.name, ex) - elif ey > 0: - name = (b.name, ey) - else: - name = (b.name, 0) - else: - name = (b.name) - if hasattr(b, 'connections'): - connections = [get_id(c) for c in b.connections] - else: - connections = None - (sx, sy) = b.spr.get_xy() - data.append((b.id, name, sx-tw.canvas.cx, sy-tw.canvas.cy, connections)) - if save_turtle is True: - data.append((-1,'turtle', - tw.canvas.xcor,tw.canvas.ycor,tw.canvas.heading, - tw.canvas.color,tw.canvas.shade,tw.canvas.pensize)) - return data - -# Serialize a stack to save to the clipboard -# TODO: check to make sure just the stack and not the project is saved -def serialize_stack(tw): - data = _assemble_data_to_save(tw, False) - if data == []: - return None - return _json_dump(data) - -def get_id(c): - if c is None: - return None - return c.id - -def _do_dialog(tw, dialog, suffix): - result = None - filter = gtk.FileFilter() - filter.add_pattern('*'+suffix) - filter.set_name("Turtle Art") - dialog.add_filter(filter) - dialog.set_current_folder(tw.load_save_folder) - response = dialog.run() - if response == gtk.RESPONSE_OK: - result = dialog.get_filename() - tw.load_save_folder = dialog.get_current_folder() - dialog.destroy() - return result - diff --git a/tawindow.py b/tawindow.py index 0f671e2..d4c81d0 100644 --- a/tawindow.py +++ b/tawindow.py @@ -47,7 +47,6 @@ except: pass from gettext import gettext as _ -from tahoverhelp import * from tautils import * from sprite_factory import SVG, svg_str_to_pixbuf from talogo import LogoCode, stop_logo, get_pixbuf_from_journal,\ @@ -354,6 +353,8 @@ class TurtleArtWindow(): self.palette_button.append(Sprite(self.sprite_list, 0, 0, self._load_sprite_from_file( "%s/palettevertical.svg" % (self.path)))) + self.palette_button[0].name = 'orientation' + self.palette_button[1].name = 'orientation' self.palette_button[0].type = 'palette' self.palette_button[1].type = 'palette' self.palette_button[self.palette_orientation].set_layer(TAB_LAYER) @@ -601,7 +602,8 @@ class TurtleArtWindow(): self.timeout_tag[0] = 0 except: self.timeout_tag[0] = 0 - elif spr and hasattr(spr,'type') and spr.type == 'selector': + elif spr and hasattr(spr,'type') and (spr.type == 'selector' or\ + spr.type == 'palette'): if self.timeout_tag[0] == 0: self.timeout_tag[0] = self._do_show_popup(spr.name) self.selected_spr = spr @@ -624,12 +626,14 @@ class TurtleArtWindow(): Fetch the help text and display it. """ def _do_show_popup(self, block_name): - if blocks_dict.has_key(block_name): - block_name_s = _(blocks_dict[block_name]) + if SPECIAL_NAMES.has_key(block_name): + block_name_s = SPECIAL_NAMES[block_name] + elif BLOCK_NAMES.has_key(block_name): + block_name_s = BLOCK_NAMES[block_name][0] else: block_name_s = _(block_name) - if hover_dict.has_key(block_name): - label = block_name_s + ": " + hover_dict[block_name] + if HELP_STRINGS.has_key(block_name): + label = block_name_s + ": " + HELP_STRINGS[block_name] else: label = block_name_s if self.running_sugar: @@ -1467,7 +1471,7 @@ class TurtleArtWindow(): cons=[] # Ugly corner case to support old-style booleans if blocks[i].connections == 'check': - cons.append(None) # add an extra connection + cons.append(None) # Add an extra connection. for c in data[i][4]: if c is None: cons.append(None) @@ -1485,7 +1489,7 @@ class TurtleArtWindow(): blocks[c].connections[3] = None else: print "WARNING: could not look into the future" - # Normally, it is simply a matter of copying the connections + # Normally, it is simply a matter of copying the connections. else: for c in data[i][4]: if c is None: @@ -1493,7 +1497,7 @@ class TurtleArtWindow(): else: cons.append(blocks[c]) blocks[i].connections = cons[:] - # Adjust the x,y positions, as block sizes may have changed. + # Adjust the x,y positions, as block sizes and shapes may have changed. for b in blocks: (sx, sy) = b.spr.get_xy() for i, c in enumerate(b.connections): -- cgit v0.9.1