From eafb5ae741681d8eb4f091721735f6ccf1b951f2 Mon Sep 17 00:00:00 2001 From: Walter Bender Date: Fri, 18 Sep 2009 16:27:20 +0000 Subject: merge of walters-clone --- diff --git a/NEWS b/NEWS index bb99384..07c056f 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,35 @@ +68 + +* consistant case on tool tips +* speeding up debug +* added i18n to debug panel +* new artwork for es and fr +* fixed some problems with svg factory + +67 + +* added mime-type icon +* changed keyboard shortcuts to use Ctrl instead of Alt as per guidelines +* wait time in seconds +* fixed problem with fractional wait times +* fixed i18n problem with labels in hover help +* reorganization of extras palette +* added screen capture to "Save as HTML" + +66 + +* added support for old toolbar design (0.82-0.84) +* work around Rainbow problem with image save +* activate Stop Button on launch (thanks to rgs) +* added open from journal button (with rgs) +* Erase Button hides status blocks +* cleaned up some sample code + +65 + +* fixed problem with View Toolbar +* moved Samples button to Help Toolbar + 64 * major refactoring for new toolbar design diff --git a/TurtleArtActivity.py b/TurtleArtActivity.py index 64c9622..d91be2d 100644 --- a/TurtleArtActivity.py +++ b/TurtleArtActivity.py @@ -130,6 +130,15 @@ class TurtleArtActivity(activity.Activity): self.load_python.connect('clicked', self._do_loadpython_cb) self.load_python.show() activity_button.props.page.insert(self.load_python, -1) + + # Open project from the Journal + self.load_ta_project = ToolButton('load-from-journal') + self.load_ta_project.set_tooltip(\ + _("Import project from the Journal")) + self.load_ta_project.connect('clicked', self._do_load_ta_project_cb) + self.load_ta_project.show() + activity_button.props.page.insert(self.load_ta_project, -1) + toolbar_box.toolbar.insert(activity_button, 0) activity_button.show() @@ -163,7 +172,7 @@ class TurtleArtActivity(activity.Activity): self.palette.set_tooltip(_('Hide palette')) self.palette.props.sensitive = True self.palette.connect('clicked', self._do_palette_cb) - self.palette.props.accelerator = _('p') + self.palette.props.accelerator = _('p') toolbar_box.toolbar.insert(self.palette, -1) self.palette.show() @@ -172,7 +181,7 @@ class TurtleArtActivity(activity.Activity): self.blocks.set_tooltip(_('Hide blocks')) self.blocks.props.sensitive = True self.blocks.connect('clicked', self.do_hideshow) - self.blocks.props.accelerator = _('b') + self.blocks.props.accelerator = _('b') toolbar_box.toolbar.insert(self.blocks, -1) self.blocks.show() @@ -181,7 +190,7 @@ class TurtleArtActivity(activity.Activity): self.eraser_button.set_tooltip(_('Clean')) self.eraser_button.props.sensitive = True self.eraser_button.connect('clicked', self._do_eraser_cb) - self.eraser_button.props.accelerator = _('e') + self.eraser_button.props.accelerator = _('e') toolbar_box.toolbar.insert(self.eraser_button, -1) self.eraser_button.show() @@ -190,7 +199,7 @@ class TurtleArtActivity(activity.Activity): self.runproject.set_tooltip(_('Run')) self.runproject.props.sensitive = True self.runproject.connect('clicked', self._do_run_cb) - self.runproject.props.accelerator = _('r') + self.runproject.props.accelerator = _('r') toolbar_box.toolbar.insert(self.runproject, -1) self.runproject.show() @@ -199,7 +208,7 @@ class TurtleArtActivity(activity.Activity): self.stepproject.set_tooltip(_('Step')) self.stepproject.props.sensitive = True self.stepproject.connect('clicked', self._do_step_cb) - self.stepproject.props.accelerator = _('w') + self.stepproject.props.accelerator = _('w') toolbar_box.toolbar.insert(self.stepproject, -1) self.stepproject.show() @@ -217,7 +226,7 @@ class TurtleArtActivity(activity.Activity): self.stop.set_tooltip(_('Stop turtle')) self.stop.props.sensitive = True self.stop.connect('clicked', self._do_stop_cb) - self.stop.props.accelerator = _('s') + self.stop.props.accelerator = _('s') toolbar_box.toolbar.insert(self.stop, -1) self.stop.show() @@ -422,7 +431,8 @@ class TurtleArtActivity(activity.Activity): # Write any metadata (here we specifically set the title of the file # and specify that this is a plain text file). - dsobject.metadata['title'] = self.get_title() + " " + _("presentation") + dsobject.metadata['title'] = self.get_title() + " " + \ + _("presentation") dsobject.metadata['icon-color'] = profile.get_color().to_string() if embed_flag == True: dsobject.metadata['mime_type'] = 'text/html' @@ -479,6 +489,25 @@ class TurtleArtActivity(activity.Activity): gobject.timeout_add(250,self.load_python.set_icon, "pippy-openoff") return + def _do_load_ta_project_cb(self, button): + from sugar.graphics.objectchooser import ObjectChooser + chooser = ObjectChooser(_("Project"), None, gtk.DIALOG_MODAL | \ + gtk.DIALOG_DESTROY_WITH_PARENT) + try: + result = chooser.run() + if result == gtk.RESPONSE_ACCEPT: + dsobject = chooser.get_selected_object() + try: + _logger.debug("opening %s " % dsobject.file_path) + self.read_file(dsobject.file_path, False) + except: + _logger.debug("couldn't open %s" % dsobject.file_path) + dsobject.destroy() + finally: + chooser.destroy() + del chooser + return + # Import Python code from the Journal to load into "myblock" def _import_py(self): from sugar.graphics.objectchooser import ObjectChooser @@ -633,7 +662,7 @@ class TurtleArtActivity(activity.Activity): self.debugproject.set_icon("debugon") self.stop.set_icon("stopiton") self.tw.lc.trace = 1 - tawindow.runbutton(self.tw, 30) + tawindow.runbutton(self.tw, 6) gobject.timeout_add(1000,self.debugproject.set_icon,"debugoff") def _do_stop_cb(self, button): @@ -644,8 +673,9 @@ class TurtleArtActivity(activity.Activity): """ Sample projects open dialog """ def _do_samples_cb(self, button): - tawindow.load_file(self.tw) + tawindow.load_file(self.tw, True) # run the activity + self.stop.set_icon("stopiton") tawindow.runbutton(self.tw, 0) """ @@ -836,7 +866,7 @@ class TurtleArtActivity(activity.Activity): """ Read a project in and then run it """ - def read_file(self, file_path): + def read_file(self, file_path, run_it = True): import tarfile,os,tempfile,shutil if hasattr(self, 'tw'): @@ -847,26 +877,30 @@ class TurtleArtActivity(activity.Activity): tmpdir = tempfile.mkdtemp() try: # We'll get 'ta_code.ta' and possibly a 'ta_image.png' + # but we will ignore the .png file + # If run_it is True, we want to create a new project tar_fd.extractall(tmpdir) - tawindow.load_files(self.tw, os.path.join(tmpdir, \ - 'ta_code.ta'), os.path.join(tmpdir, 'ta_image.png')) + tawindow.load_files(self.tw, \ + os.path.join(tmpdir,'ta_code.ta'), \ + run_it) # create a new project flag finally: shutil.rmtree(tmpdir) tar_fd.close() # Otherwise, assume it is a .ta file else: print "trying to open a .ta file:" + file_path - tawindow.load_files(self.tw, file_path, "") + tawindow.load_files(self.tw, file_path, run_it) # run the activity - try: - # Use 0.86 toolbar design - self.stop.set_icon("stopiton") - except: - # Use pre-0.86 toolbar design - self.projectToolbar.stop.set_icon("stopiton") + if run_it: + try: + # Use 0.86 toolbar design + self.stop.set_icon("stopiton") + except: + # Use pre-0.86 toolbar design + self.projectToolbar.stop.set_icon("stopiton") - tawindow.runbutton(self.tw, 0) + tawindow.runbutton(self.tw, 0) else: _logger.debug("Deferring reading file %s" % file_path) @@ -1025,12 +1059,20 @@ class SaveAsToolbar(gtk.Toolbar): # Pippy load myblock source button self.loadmyblock = ToolButton( "pippy-openoff" ) - self.loadmyblock.set_tooltip(_('load my block')) + self.loadmyblock.set_tooltip(_('Load my block')) self.loadmyblock.props.sensitive = True self.loadmyblock.connect('clicked', self.do_loadmyblock) self.insert(self.loadmyblock, -1) self.loadmyblock.show() + # Open TA project from the Journal + self.load_ta_project = ToolButton('load-from-journal') + self.load_ta_project.set_tooltip(_("Import project from the Journal")) + self.load_ta_project.props.sensitive = True + self.load_ta_project.connect('clicked', self.do_load_ta_project_cb) + self.insert(self.load_ta_project, -1) + self.load_ta_project.show() + def do_savehtml(self, button): # write html out to datastore self.savehtml.set_icon("htmlon") @@ -1076,7 +1118,7 @@ class SaveAsToolbar(gtk.Toolbar): # Write any metadata (here we specifically set the title of the file # and specify that this is a plain text file). dsobject.metadata['title'] = self.activity.get_title() + " " + \ - _("presentation") + _("presentation") dsobject.metadata['icon-color'] = profile.get_color().to_string() if embed_flag == True: dsobject.metadata['mime_type'] = 'text/html' @@ -1139,6 +1181,25 @@ class SaveAsToolbar(gtk.Toolbar): gobject.timeout_add(250,self.loadmyblock.set_icon, "pippy-openoff") return + def do_load_ta_project_cb(self, button): + from sugar.graphics.objectchooser import ObjectChooser + chooser = ObjectChooser(_("Project"), None, gtk.DIALOG_MODAL | \ + gtk.DIALOG_DESTROY_WITH_PARENT) + try: + result = chooser.run() + if result == gtk.RESPONSE_ACCEPT: + dsobject = chooser.get_selected_object() + try: + _logger.debug("opening %s " % dsobject.file_path) + self.activity.read_file(dsobject.file_path, False) + except: + _logger.debug("couldn't open %s" % dsobject.file_path) + dsobject.destroy() + finally: + chooser.destroy() + del chooser + return + # Import Python code from the Journal to load into "myblock" def import_py(self): from sugar.graphics.objectchooser import ObjectChooser @@ -1204,7 +1265,7 @@ class ProjectToolbar(gtk.Toolbar): self.palette.props.sensitive = True self.palette.connect('clicked', self.do_palette) try: - self.palette.props.accelerator = _('p') + self.palette.props.accelerator = _('p') except: pass self.insert(self.palette, -1) @@ -1216,7 +1277,7 @@ class ProjectToolbar(gtk.Toolbar): self.blocks.props.sensitive = True self.blocks.connect('clicked', self.do_hideshow) try: - self.blocks.props.accelerator = _('b') + self.blocks.props.accelerator = _('b') except: pass self.insert(self.blocks, -1) @@ -1233,7 +1294,7 @@ class ProjectToolbar(gtk.Toolbar): self.runproject.props.sensitive = True self.runproject.connect('clicked', self.do_run) try: - self.runproject.props.accelerator = _('r') + self.runproject.props.accelerator = _('r') except: pass self.insert(self.runproject, -1) @@ -1245,7 +1306,7 @@ class ProjectToolbar(gtk.Toolbar): self.stepproject.props.sensitive = True self.stepproject.connect('clicked', self.do_step) try: - self.stepproject.props.accelerator = _('w') + self.stepproject.props.accelerator = _('w') except: pass self.insert(self.stepproject, -1) @@ -1257,7 +1318,7 @@ class ProjectToolbar(gtk.Toolbar): self.debugproject.props.sensitive = True self.debugproject.connect('clicked', self.do_debug) try: - self.debugproject.props.accelerator = _('d') + self.debugproject.props.accelerator = _('d') except: pass self.insert(self.debugproject, -1) @@ -1269,7 +1330,7 @@ class ProjectToolbar(gtk.Toolbar): self.stop.props.sensitive = True self.stop.connect('clicked', self.do_stop) try: - self.stop.props.accelerator = _('s') + self.stop.props.accelerator = _('s') except: pass self.insert(self.stop, -1) @@ -1286,7 +1347,7 @@ class ProjectToolbar(gtk.Toolbar): self.eraser.props.sensitive = True self.eraser.connect('clicked', self.do_eraser) try: - self.eraser.props.accelerator = _('e') + self.eraser.props.accelerator = _('e') except: pass self.insert(self.eraser, -1) @@ -1337,7 +1398,7 @@ class ProjectToolbar(gtk.Toolbar): self.sampb.props.sensitive = True self.sampb.connect('clicked', self.do_samples) try: - self.sampb.props.accelerator = _('o') + self.sampb.props.accelerator = _('o') except: pass self.insert(self.sampb, -1) @@ -1381,7 +1442,7 @@ class ProjectToolbar(gtk.Toolbar): self.debugproject.set_icon("debugon") self.stop.set_icon("stopiton") self.activity.tw.lc.trace = 1 - tawindow.runbutton(self.activity.tw, 30) + tawindow.runbutton(self.activity.tw, 6) gobject.timeout_add(1000,self.debugproject.set_icon,"debugoff") def do_stop(self, button): @@ -1429,8 +1490,9 @@ class ProjectToolbar(gtk.Toolbar): self.activity.recenter() def do_samples(self, button): - tawindow.load_file(self.activity.tw) + tawindow.load_file(self.activity.tw, True) # run the activity + self.stop.set_icon("stopiton") tawindow.runbutton(self.activity.tw, 0) def do_savesnapshot(self, button): diff --git a/activity/activity.info b/activity/activity.info index 31c9b6e..2840b43 100644 --- a/activity/activity.info +++ b/activity/activity.info @@ -1,6 +1,6 @@ [Activity] name = Turtle Art -activity_version = 64 +activity_version = 68 license = MIT bundle_id = org.laptop.TurtleArtActivity exec = sugar-activity TurtleArtActivity.TurtleArtActivity diff --git a/icons/help-toolbar.svg b/icons/help-toolbar.svg index d763270..d997562 100644 --- a/icons/help-toolbar.svg +++ b/icons/help-toolbar.svg @@ -1,28 +1,20 @@ - - - - - - ? - - \ No newline at end of file + style="fill:#010101;stroke:#ffffff;stroke-width:3.5;stroke-linecap:round;stroke-linejoin:round"> + + + + diff --git a/images/de/sensors/sensorsgroup.svg b/images/de/sensors/sensorsgroup.svg index ae0d34f..856117b 100644 --- a/images/de/sensors/sensorsgroup.svg +++ b/images/de/sensors/sensorsgroup.svg @@ -252,7 +252,7 @@ style="font-size:11px">tastatur keyboard keyboard X clean forward back left right arc angle radius setyx x y seth xcor ycor heading Turtle show set scale show name \ No newline at end of file + X clean forward back left right arc angle radius setxy x y seth xcor ycor heading Turtle show set scale show text diff --git a/images/es/sensors/sensorsgroup.svg b/images/es/sensors/sensorsgroup.svg index 5bb868f..1fa6a9c 100644 --- a/images/es/sensors/sensorsgroup.svg +++ b/images/es/sensors/sensorsgroup.svg @@ -253,7 +253,7 @@ x="72.5" y="21.5" id="tspan30" - style="font-size:20px">Mas opciones + style="font-size:20px">Extras teclado - inferior + + + + + diff --git a/images/fi/sensors/sensorsgroup.svg b/images/fi/sensors/sensorsgroup.svg index c1c71e6..8745ac7 100644 --- a/images/fi/sensors/sensorsgroup.svg +++ b/images/fi/sensors/sensorsgroup.svg @@ -252,7 +252,7 @@ style="font-size:11px">keyboard arrête @@ -308,4 +309,15 @@ d="M 49.4155,411.64166 C 60.0827,411.64166 60.0827,411.64166 60.0827,411.64166 C 60.0827,411.64166 62.83737,413.29944 63.74955,414.30846 C 64.68124,415.33906 66.083,418.30866 66.083,418.30866 L 66.083,450.97696 C 66.083,450.97696 64.60489,453.43952 63.74955,454.31046 C 62.79646,455.28093 60.0827,456.97726 60.0827,456.97726 L 48.7488,456.97726 L 48.7488,456.97726 L 48.7488,459.64406 L 35.4148,459.64406 L 35.4148,456.97726 L 24.0809,456.97726 C 24.0809,456.97726 21.367138,455.28093 20.41405,454.31046 C 19.558707,453.43952 18.0806,450.97696 18.0806,450.97696 L 18.0806,418.30866 C 18.0806,418.30866 19.482356,415.33906 20.41405,414.30846 C 21.32623,413.29944 24.0809,411.64166 24.0809,411.64166 L 34.7481,411.64166 L 34.7481,414.97516 L 49.4155,414.97516 L 49.4155,411.64166 z" id="path105" style="fill:url(#linearGradient4683);fill-opacity:1;stroke:#a97513;stroke-width:1.5px;stroke-opacity:1" /> + + l'action + diff --git a/images/fr/flow/stopstack.svg b/images/fr/flow/stopstack.svg index 5df0f2b..6085090 100644 --- a/images/fr/flow/stopstack.svg +++ b/images/fr/flow/stopstack.svg @@ -39,6 +39,13 @@ arrête + + l'action diff --git a/images/fr/pen/pengroup.svg b/images/fr/pen/pengroup.svg index bdf3591..82e5c38 100644 --- a/images/fr/pen/pengroup.svg +++ b/images/fr/pen/pengroup.svg @@ -1,623 +1,707 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - X - - - Crayon - - - - - crayon - - - levé - - - - - - crayon - - - abaissé - - - - - - - - fixe - - - l'épaisseur - - - du trait - - - - - - - - fixe - - - la couleur - - - - - - - - fixe - - - la teinte - - - - - - - - - - peins - - - fond - - - couleur - - - teinte - - - - - - épaisseur - - - - - - couleur - - - - - - teinte - - - - - - - - définir la - - - épaisseur - - - du texte - - - - - - - - définir la - - - couleur - - - du texte - - - - - - c. du texte - - - - - - é. du texte - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + X + + + Crayon + + + + + crayon + + + levé + + + + + + crayon + + + abaissé + + + + + + + + fixe + + + l'épaisseur + + + du trait + + + + + + + + fixe + + + la couleur + + + + + + + + fixe + + + la teinte + + + + + + + + + + peins + + + fond + + + couleur + + + teinte + + + + + + épaisseur + + + + + + couleur + + + + + + teinte + + + + + + + + définir la + + + épaisseur + + + du texte + + + + + + + + définir la + + + couleur + + + du texte + + + + + + couleur du texte + + + + + + taille du texte + + + diff --git a/images/fr/pen/textsize.svg b/images/fr/pen/textsize.svg index 8c49bda..78fc259 100644 --- a/images/fr/pen/textsize.svg +++ b/images/fr/pen/textsize.svg @@ -1,40 +1,46 @@ - - - - - - - - - - - - é du texte - - - + + + + + + + + + + + + + taille du texte + + diff --git a/images/fr/sensors/bottompos.svg b/images/fr/sensors/bottompos.svg index acf79cb..8bdfdb5 100644 --- a/images/fr/sensors/bottompos.svg +++ b/images/fr/sensors/bottompos.svg @@ -1,46 +1,46 @@ - - - - - - - - - - - - - bottom - - + + + + + + + + + + + + + bas + + diff --git a/images/fr/sensors/clearheap.svg b/images/fr/sensors/clearheap.svg index f277b41..f0e483d 100644 --- a/images/fr/sensors/clearheap.svg +++ b/images/fr/sensors/clearheap.svg @@ -1,46 +1,68 @@ - - - - - - - - - - - - clear - - - heap - - + + + + + + + + + + + + + vide + + + le + + + tas + + diff --git a/images/fr/sensors/hres.svg b/images/fr/sensors/hres.svg index 630111c..8788189 100644 --- a/images/fr/sensors/hres.svg +++ b/images/fr/sensors/hres.svg @@ -1,46 +1,46 @@ - - - - - - - - - - - - - hres - - + + + + + + + + + + + + + largeur + + diff --git a/images/fr/sensors/kbinput.svg b/images/fr/sensors/kbinput.svg index 1ffc165..3c94a2b 100644 --- a/images/fr/sensors/kbinput.svg +++ b/images/fr/sensors/kbinput.svg @@ -1,55 +1,68 @@ - - - - - - - - - - - + + + + + + + + + + + + style="font-size:16px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:center;line-height:125%;writing-mode:lr-tb;text-anchor:middle;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"> query + style="font-size:16px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:center;line-height:125%;writing-mode:lr-tb;text-anchor:middle;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans">vide + style="font-size:16px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:center;line-height:125%;writing-mode:lr-tb;text-anchor:middle;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"> kb + style="font-size:16px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:center;line-height:125%;writing-mode:lr-tb;text-anchor:middle;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans">la - + + touche + + diff --git a/images/fr/sensors/printheap.svg b/images/fr/sensors/printheap.svg index 026631e..91dc463 100644 --- a/images/fr/sensors/printheap.svg +++ b/images/fr/sensors/printheap.svg @@ -29,18 +29,35 @@ - - show - - - heap - + + affiche + + + le + + + tas + diff --git a/images/fr/sensors/push.svg b/images/fr/sensors/push.svg index 9683008..7d7de13 100644 --- a/images/fr/sensors/push.svg +++ b/images/fr/sensors/push.svg @@ -39,6 +39,6 @@ push + style="font-size:16px;;font-family:Bitstream Vera Sans">pousse diff --git a/images/fr/sensors/sensorsgroup.svg b/images/fr/sensors/sensorsgroup.svg index c0a5c41..977be73 100644 --- a/images/fr/sensors/sensorsgroup.svg +++ b/images/fr/sensors/sensorsgroup.svg @@ -1,444 +1,622 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - X - - - - - - - Clavier - - - - read - - - key - - - - clavier - - - - - hres - - - - - - vres - - - - - - - - - - x - - - - - - - pop - - - - - - - show - - - heap - - - - - - empty - - - heap - - - - - - - - push - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + X + + + + + + + Extras + + + + lit + + + la + + + + clavier + + + + + largeur + + + + + + hauteur + + + + + + + + + + x + + + + + + + dépile + + + + + + affiche + + + le + + + + vide + + + le + + + tas + + + tas + + + + + + + pousse + + + + + + + + gauche + + + + + + haut + + + + + + droite + + + + + + bas + + + + + + + + + touche + + diff --git a/images/fr/sensors/toppos.svg b/images/fr/sensors/toppos.svg index 7b9e287..c522fee 100644 --- a/images/fr/sensors/toppos.svg +++ b/images/fr/sensors/toppos.svg @@ -1,46 +1,46 @@ - - - - - - - - - - - - - top - - + + + + + + + + + + + + + haut + + diff --git a/images/fr/sensors/vres.svg b/images/fr/sensors/vres.svg index cd25565..50074b2 100644 --- a/images/fr/sensors/vres.svg +++ b/images/fr/sensors/vres.svg @@ -1,46 +1,46 @@ - - - - - - - - - - - - - vres - - + + + + + + + + + + + + + hauteur + + diff --git a/images/it/sensors/sensorsgroup.svg b/images/it/sensors/sensorsgroup.svg index 825e428..e50645b 100644 --- a/images/it/sensors/sensorsgroup.svg +++ b/images/it/sensors/sensorsgroup.svg @@ -252,7 +252,7 @@ style="font-size:11px">tastiera extras гар tastatur toetsenbord teclado keyboard keyboard tangentbord extras keyboard bàn phím 鍵盤 \n\ \n\ \n\ \n\ \n\ \n\ \n\ - \n\ \n\ \n\ \n\ \n\ + \n\ + \n\ + \n\ + \n\ + \n\ \n" @@ -701,7 +712,7 @@ def main(): FILE.write(data3b) FILE.write(strings[1].encode("utf-8")) FILE.write(data4) - FILE.write(s3lower.encode("utf-8")) + FILE.write(mystring3.encode("utf-8")) FILE.write(data5) FILE.write(mystring4.encode("utf-8")) FILE.write(data6) @@ -746,6 +757,3 @@ if __name__ == "__main__": main() - - - diff --git a/svg/turtlegroup.py b/svg/turtlegroup.py index d217b94..e932648 100644 --- a/svg/turtlegroup.py +++ b/svg/turtlegroup.py @@ -46,7 +46,7 @@ def main(): mystring6 = _("arc") mystring7 = _("angle") mystring8 = _("radius") - mystring9 = _("setyx") + mystring9 = _("set xy") mystring10 = _("x") mystring11 = _("y") mystring12 = _("set heading") @@ -80,929 +80,929 @@ def main(): print mystring19 data0 = \ -"\ -\ -\ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - X\ - \ - \ - \ - \n\ +\n\ +\n\ + \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + X\n\ + \n\ + \n\ + \n\ + " data1 = \ -"\ - \ - \ - \ - \ - \ - \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + " data2 = \ -"\ - \ - \ - \ - \ - \ - \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + " data3 = \ -"\ - \ - \ - \ - \ - \ - \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + " data4 = \ -"\ - \ - \ - \ - \ - \ - \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + " data5 = \ -"\ - \ - \ - \ - \ - \ - \ - \ - \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + " data6 = \ -"\ - \ - \ - \n\ + \n\ + \n\ + " data7 = \ -"\ - \n\ + " data8 = \ -"\ - \ - \ - \ - \ - \ - \ - \ - \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + " data9 = \ -"\ - \ - \ - \n\ + \n\ + \n\ + " data10 = \ -"\ - \n\ + " data11 = \ -"\ - \ - \ - \ - \ - \ - \ - \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + " data12 = \ -"\ - \ - \ - \ - \ - \n\ + \n\ + \n\ + \n\ + \n\ + " data13 = \ -"\ - \ - \ - \ - \n\ + \n\ + \n\ + \n\ + " data14 = \ -"\ - \ - \ - \ - \n\ + \n\ + \n\ + \n\ + " data15 = \ -"\ - \ - \ - \n\ + \n\ + \n\ + " data16 = \ -"\ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + " data17 = \ -"\ - \ - \ - \ - \ - \ - \ - \ - \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + " data18 = \ -"\ - \ - \ - \n\ + \n\ + \n\ + " data19 = \ -"\ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + " data20 = \ -"\ - \ - \ - \ - \ - \n\ + \n\ + \n\ + \n\ + \n\ + " data21 = \ -"\ - \ +"\n\ + \n\ " diff --git a/taexporthtml.py b/taexporthtml.py index b0ad8ab..ac36475 100644 --- a/taexporthtml.py +++ b/taexporthtml.py @@ -43,7 +43,7 @@ def save_html(self, tw, embed_flag=True): 'doctype': ("\n", ""), 'html': ("\n", "\n"), - 'head': ("\n\n", \ + 'head': ("\n\n", \ "\n"), 'meta': ("\n", ""), @@ -59,19 +59,24 @@ charset=UTF-8\">\n", ""), "\n\n"), 'img': ("\"Image\"\n"), + 'img2': ("\"Image\"\n"), 'ul': ("
    \n", "
\n"), 'li': ("
  • ", "
  • \n") } if embed_flag == True: + # store images in-line as base64 html_glue['img'] = ("\"Image\"\n") + html_glue['img2'] = ("\"Image\"\n") + bs = tawindow.blocks(tw) code = "" imagecount = 0 slidecount = 0 for b in bs: this_stack = "" - data = walk_stack(self,tw, b) + data = walk_stack(self, tw, b) show = 0 onepic = 0 twopic = 0 @@ -83,47 +88,56 @@ src=\"data:image/png;base64,\n", " \"/>\n") if type(d) is float: continue else: - # transalate some TA terms into html - # ignores most turtle gr - # print d + # transalate some Turtle Art blocks into HTML + # show and template blocks + # ignores most turtle graphics if d == "show": show = 1 elif d == "container": show = 2 - elif show == 1 and d[0:2] == '#s': - # show a string - this_stack += d[2:] - show = 0 - elif show == 2: - # show an image - if d[8:] != None: - try: - dsobject = datastore.get(d[8:]) - pixbuf = get_pixbuf_from_journal(dsobject,400,300) + elif show > 0: + if show == 1: + try: # is it media or a string? + tmp = d[0:8] except: - pixbuf = None - if pixbuf != None: - filename = os.path.join(datapath, 'image' + \ - str(imagecount) + ".png") - pixbuf.save(filename, "png") - # if the embed flag is True - # embed base64 into the html - if embed_flag == True: - base64 = os.path.join(datapath, 'base64tmp') - cmd = "base64 <" + filename + " >" + base64 - subprocess.check_call(cmd, shell=True) - f = open( base64, 'r') - imgdata = f.read() - f.close() - tmp = html_glue['img'][0] - if embed_flag == True: - tmp = tmp + imgdata - else: - tmp = tmp + str(imagecount) - imagecount += 1 - tmp = tmp + html_glue['img'][1] - this_stack += tmp - show = 0 + tmp = "" + if tmp == '#smedia_': # show media + show = 2 + else: # show a string + this_stack += d[2:] + show = 0 + if show == 2: + # show an image + if d[8:] != None: + try: + dsobject = datastore.get(d[8:]) + pixbuf = \ + get_pixbuf_from_journal(dsobject,400,300) + except: + pixbuf = None + if pixbuf != None: + filename = os.path.join(datapath, 'image' + \ + str(imagecount) + ".png") + pixbuf.save(filename, "png") + # if the embed flag is True + # embed base64 into the html + if embed_flag == True: + base64 = \ + os.path.join(datapath, 'base64tmp') + cmd = "base64 <" + filename + " >" + base64 + subprocess.check_call(cmd, shell=True) + f = open( base64, 'r') + imgdata = f.read() + f.close() + tmp = html_glue['img2'][0] + if embed_flag == True: + tmp = tmp + imgdata + else: + tmp = tmp + str(imagecount) + imagecount += 1 + tmp = tmp + html_glue['img2'][1] + this_stack += tmp + show = 0 elif d == "tp1" or d == 'tp8': onepic = 1 elif d == "tp2" or d == 'tp6': @@ -159,7 +173,6 @@ src=\"data:image/png;base64,\n", " \"/>\n") # Need filename to copy it into instance directory # if it is not an image, save the preview # save the description too. - print str(onepic) + " " + str(twopic) + " " + str(fourpic) if d[8:] != None: try: dsobject = datastore.get(d[8:]) @@ -224,13 +237,46 @@ src=\"data:image/png;base64,\n", " \"/>\n") this_stack += " " if len(data) > 0: code += this_stack - code = html_glue['doctype'][0] + html_glue['html'][0] + \ - html_glue['head'][0] + \ - html_glue['meta'][0] + html_glue['title'][0] + _("Turtle Art") + \ - html_glue['title'][1] + html_glue['style'][0] + \ - html_glue['style'][1] + \ - html_glue['head'][1] + html_glue['body'][0] + code + \ - html_glue['body'][1] + html_glue['html'][1] + + # if no show or template blocks were present, we've got no slides, + # so save a screendump instead + if slidecount == 0: + # save a screen dump instead + filename = os.path.join(datapath, 'image.png') + tawindow.save_pict(self.tw,filename) + # if the embed flag is True + # embed base64 into the html + if embed_flag == True: + base64 = os.path.join(datapath, 'base64tmp') + cmd = "base64 <" + filename + " >" + base64 + subprocess.check_call(cmd, shell=True) + f = open( base64, 'r') + imgdata = f.read() + f.close() + code = html_glue['img'][0] + \ + imgdata + \ + html_glue['img'][1] + for b in bs: # "show me the code" + code = code + html_glue['div'][0] + data = walk_stack(self, tw, b) + for d in data: + code = code + str(d) + " " + code = code + html_glue['div'][1] + + code = html_glue['doctype'][0] + \ + html_glue['html'][0] + \ + html_glue['head'][0] + \ + html_glue['meta'][0] + \ + html_glue['title'][0] + \ + _("Turtle Art") + \ + html_glue['title'][1] + \ + html_glue['style'][0] + \ + html_glue['style'][1] + \ + html_glue['head'][1] + \ + html_glue['body'][0] + \ + code + \ + html_glue['body'][1] + \ + html_glue['html'][1] return code def walk_stack(self, tw, spr): @@ -242,4 +288,3 @@ def walk_stack(self, tw, spr): # not top of stack, then return empty list return [] - diff --git a/talogo.py b/talogo.py index 8a7bbed..0a25389 100644 --- a/talogo.py +++ b/talogo.py @@ -164,7 +164,10 @@ def setup_cmd(lc, str): def start_eval(lc, list): icall(lc, evline, list); yield True # turn off stop icon when execution is finished - lc.tw.activity.stop.set_icon("stopitoff") + try: + lc.tw.activity.stop.set_icon("stopitoff") + except: + lc.tw.activity.projectToolbar.stop.set_icon("stopitoff") yield False def evline(lc, list): @@ -268,7 +271,7 @@ def debug_trace(lc, token): my_string += tmp shp = 'info' setshape(lc.tw.status_spr, lc.tw.status_shapes[shp]) - setlabel(lc.tw.status_spr, my_string) + setlabel(lc.tw.status_spr, _(my_string)) setlayer(lc.tw.status_spr, 710) return @@ -282,7 +285,7 @@ def no_args_check(lc): def prim_wait(lc,time): setlayer(lc.tw.turtle.spr,630) - endtime = millis()+an_int(lc,time)*100 + endtime = millis()+an_int(lc,time*1000) while millis()