Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--TurtleArt/tabasics.py30
-rw-r--r--TurtleArt/tapalette.py13
-rw-r--r--TurtleArt/tawindow.py60
3 files changed, 63 insertions, 40 deletions
diff --git a/TurtleArt/tabasics.py b/TurtleArt/tabasics.py
index 667486f..8586ad9 100644
--- a/TurtleArt/tabasics.py
+++ b/TurtleArt/tabasics.py
@@ -70,7 +70,7 @@ from gettext import gettext as _
from tapalette import (make_palette, define_logo_function)
from talogo import (primitive_dictionary, logoerror)
-from tautils import (convert, chr_to_ord, round_int, strtype)
+from tautils import (convert, chr_to_ord, round_int, strtype, debug_output)
from taconstants import (COLORDICT, CONSTANTS)
@@ -119,7 +119,9 @@ class Palettes():
def _turtle_palette(self):
''' The basic Turtle Art turtle palette '''
- palette = make_palette(_('turtle'),
+ debug_output('creating %s palette' % _('turtle'),
+ self.tw.running_sugar)
+ palette = make_palette('turtle',
colors=["#00FF00", "#00A000"],
help_string=_('Palette of turtle commands'))
@@ -303,7 +305,9 @@ setxy :x :y\npendown\nend\n')
def _pen_palette(self):
''' The basic Turtle Art pen palette '''
- palette = make_palette(_('pen'),
+ debug_output('creating %s palette' % _('pen'),
+ self.tw.running_sugar)
+ palette = make_palette('pen',
colors=["#00FFFF", "#00A0A0"],
help_string=_('Palette of pen commands'))
@@ -503,7 +507,9 @@ pensize\nend\n')
def _color_palette(self):
''' The basic Turtle Art color palette '''
- palette = make_palette(_('colors'),
+ debug_output('creating %s palette' % _('colors'),
+ self.tw.running_sugar)
+ palette = make_palette('colors',
colors=["#00FFFF", "#00A0A0"],
help_string=_('Palette of pen colors'))
@@ -596,7 +602,9 @@ tasetshade :shade \n')
def _numbers_palette(self):
''' The basic Turtle Art numbers palette '''
- palette = make_palette(_('numbers'),
+ debug_output('creating %s palette' % _('numbers'),
+ self.tw.running_sugar)
+ palette = make_palette('numbers',
colors=["#FF00FF", "#A000A0"],
help_string=_('Palette of numeric operators'))
@@ -779,7 +787,9 @@ operators'))
def _flow_palette(self):
''' The basic Turtle Art flow palette '''
- palette = make_palette(_('flow'),
+ debug_output('creating %s palette' % _('flow'),
+ self.tw.running_sugar)
+ palette = make_palette('flow',
colors=["#FFC000", "#A08000"],
help_string=_('Palette of flow operators'))
@@ -879,7 +889,9 @@ boolean operators from Numbers palette'))
def _blocks_palette(self):
''' The basic Turtle Art blocks palette '''
- palette = make_palette(_('blocks'),
+ debug_output('creating %s palette' % _('blocks'),
+ self.tw.running_sugar)
+ palette = make_palette('blocks',
colors=["#FFFF00", "#A0A000"],
help_string=_('Palette of variable blocks'))
@@ -1040,7 +1052,9 @@ variable'))
def _trash_palette(self):
''' The basic Turtle Art turtle palette '''
- palette = make_palette(_('trash'),
+ debug_output('creating %s palette' % _('trash'),
+ self.tw.running_sugar)
+ palette = make_palette('trash',
colors=["#FFFF00", "#A0A000"],
help_string=_('trash'))
diff --git a/TurtleArt/tapalette.py b/TurtleArt/tapalette.py
index 71d572a..7341c3e 100644
--- a/TurtleArt/tapalette.py
+++ b/TurtleArt/tapalette.py
@@ -22,6 +22,7 @@
help_palettes = {}
help_windows = {}
palette_names = []
+palette_i18n_names = []
palette_init_on_start = []
palette_blocks = []
block_colors = []
@@ -128,12 +129,14 @@ class Palette():
def add_palette(self, position=None, init_on_start=False):
if self._name is None:
- debug_output('You must specify a name for your palette')
+ debug_output('You must specify a name for your palette', True)
return
# Insert new palette just before the trash
if 'trash' in palette_names:
- i = palette_names.index(_('trash'))
+ i = palette_names.index('trash')
+ elif _('trash') in palette_i18n_names:
+ i = palette_i18n_names.index(_('trash'))
else:
i = len(palette_names)
@@ -142,6 +145,9 @@ class Palette():
if self._name not in palette_names:
palette_names.insert(i, self._name)
+ debug_output('adding %s to palette_i18n_names' % _(self._name),
+ True)
+ palette_i18n_names.insert(i, _(self._name))
palette_blocks.insert(i, [])
block_colors.insert(i, self._colors)
if init_on_start:
@@ -234,8 +240,11 @@ def make_palette(palette_name, colors=None, help_string=None, position=None,
def palette_name_to_index(palette_name):
''' Find the index associated with palette_name. '''
+ debug_output(palette_name, True)
if palette_name in palette_names:
return palette_names.index(palette_name)
+ elif palette_name in palette_i18n_names:
+ return palette_i18n_names.index(palette_name)
else:
return None
diff --git a/TurtleArt/tawindow.py b/TurtleArt/tawindow.py
index 1b6e1fd..ecdf090 100644
--- a/TurtleArt/tawindow.py
+++ b/TurtleArt/tawindow.py
@@ -1002,8 +1002,8 @@ class TurtleArtWindow():
self.running_sugar)
else:
blk.spr.hide()
- if _('trash') in palette_names and \
- n == palette_names.index(_('trash')):
+ if 'trash' in palette_names and \
+ n == palette_names.index('trash'):
for blk in self.trash_stack:
# Deprecated
for gblk in find_group(blk):
@@ -1279,8 +1279,8 @@ class TurtleArtWindow():
and not self.activity.has_toolbarbox:
self.activity.palette_buttons[palette].set_icon(
palette_names[palette] + 'off')
- if _('trash') in palette_names and \
- palette == palette_names.index(_('trash')):
+ if 'trash' in palette_names and \
+ palette == palette_names.index('trash'):
for blk in self.trash_stack:
for gblk in find_group(blk):
gblk.spr.hide()
@@ -1360,8 +1360,8 @@ class TurtleArtWindow():
if self.orientation == HORIZONTAL_PALETTE:
x, y = _BUTTON_SIZE, self.toolbar_offset + _MARGIN
x, y, max_w = self._horizontal_layout(x, y, self.palettes[n])
- if _('trash') in palette_names and \
- n == palette_names.index(_('trash')):
+ if 'trash' in palette_names and \
+ n == palette_names.index('trash'):
x, y, max_w = self._horizontal_layout(x + max_w, y,
self.trash_stack)
w = x + max_w + _BUTTON_SIZE + _MARGIN
@@ -1377,8 +1377,8 @@ class TurtleArtWindow():
else:
x, y = _MARGIN, self.toolbar_offset + _BUTTON_SIZE + _MARGIN
x, y, max_h = self._vertical_layout(x, y, self.palettes[n])
- if _('trash') in palette_names and \
- n == palette_names.index(_('trash')):
+ if 'trash' in palette_names and \
+ n == palette_names.index('trash'):
x, y, max_h = self._vertical_layout(x, y + max_h,
self.trash_stack)
h = y + max_h + _BUTTON_SIZE + _MARGIN - self.toolbar_offset
@@ -1423,8 +1423,8 @@ class TurtleArtWindow():
'category-shift-vertical'
else:
self.palette_sprs[n][self.orientation].type = 'category'
- if _('trash') in palette_names and \
- n == palette_names.index(_('trash')):
+ if 'trash' in palette_names and \
+ n == palette_names.index('trash'):
svg = SVG()
self.palette_sprs[n][self.orientation].set_shape(
svg_str_to_pixbuf(svg.palette(w, h)))
@@ -1546,9 +1546,9 @@ before making changes to your program'))
self._restore_from_trash(find_top_block(blk))
elif blk.type == 'proto':
if self.deleting_blocks:
- if 'myblocks' in palette_names and \
+ if 'my blocks' in palette_names and \
self.selected_palette == \
- palette_names.index('myblocks'):
+ palette_names.index('my blocks'):
self._delete_stack_alert(blk)
self.parent.get_window().set_cursor(
gtk.gdk.Cursor(gtk.gdk.LEFT_PTR))
@@ -1570,9 +1570,9 @@ before making changes to your program'))
self._put_in_trash(b1)
else:
self._put_in_trash(find_top_block(b))
- if _('trash') in palette_names:
+ if 'trash' in palette_names:
self.show_toolbar_palette(
- palette_names.index(_('trash')), regenerate=True)
+ palette_names.index('trash'), regenerate=True)
elif blk.name in MACROS:
self.new_macro(blk.name, x + 20, y + 20)
else:
@@ -1754,7 +1754,7 @@ before making changes to your program'))
error_output('Could not remove macro %s: %s' %
(macro_path, e))
return
- i = palette_names.index('myblocks')
+ i = palette_names.index('my blocks')
palette_blocks[i].remove(blk.name)
for pblk in self.palettes[i]:
if pblk.name == blk.name:
@@ -1877,7 +1877,7 @@ before making changes to your program'))
'storein_%s' % (name), 'basic-style-2arg',
label=1)
- def _update_proto_name(self, name, old, new, style, palette=_('blocks'),
+ def _update_proto_name(self, name, old, new, style, palette='blocks',
label=0):
''' Change the name of a proto block '''
# The name change has to happen in multiple places:
@@ -2012,8 +2012,8 @@ before making changes to your program'))
if gblk.name in BLOCKS_WITH_SKIN:
self._resize_skin(gblk)
- if not _('trash') in palette_names or \
- self.selected_palette != palette_names.index(_('trash')):
+ if not 'trash' in palette_names or \
+ self.selected_palette != palette_names.index('trash'):
for gblk in group:
gblk.spr.hide()
@@ -2057,9 +2057,9 @@ before making changes to your program'))
'storein_%s' % gblk.connections[1].values[0],
'basic-style-2arg')
- def _remove_palette_blocks(self, name, style, palette=_('blocks')):
+ def _remove_palette_blocks(self, name, style, palette='blocks'):
''' Remove blocks from palette and block, style lists '''
- i = palette_name_to_index(_('blocks'))
+ i = palette_name_to_index('blocks')
if name in palette_blocks[i]:
palette_blocks[i].remove(name)
for blk in self.palettes[i]:
@@ -2119,8 +2119,8 @@ before making changes to your program'))
blk.type = 'deleted'
blk.spr.hide()
self.trash_stack = []
- if _('trash') in palette_names:
- self.show_toolbar_palette(palette_names.index(_('trash')),
+ if 'trash' in palette_names:
+ self.show_toolbar_palette(palette_names.index('trash'),
regenerate=True)
def _in_the_trash(self, x, y):
@@ -3869,7 +3869,7 @@ before making changes to your program'))
self.process_data(data_from_file(ta_file))
self._loaded_project = ta_file
# Always start on the Turtle palette
- self.show_toolbar_palette(palette_name_to_index(_('turtle')))
+ self.show_toolbar_palette(palette_name_to_index('turtle'))
def load_file_from_chooser(self, create_new_project=True):
''' Load a project from file chooser '''
@@ -4540,7 +4540,7 @@ before making changes to your program'))
x, y = self._calc_image_offset('', blk.spr, w, h)
blk.scale_image(x, y, w, h)
- def _find_proto_name(self, name, label, palette=_('blocks')):
+ def _find_proto_name(self, name, label, palette='blocks'):
''' Look for a protoblock with this name '''
if not self.interactive_mode:
return False
@@ -4575,7 +4575,7 @@ before making changes to your program'))
if name == _('action'):
return
# Choose a palette for the new block.
- palette = make_palette(_('blocks'))
+ palette = make_palette('blocks')
# Create a new block prototype.
primitive_dictionary['stack'] = self._prim_stack
@@ -4590,7 +4590,7 @@ before making changes to your program'))
self.lc.def_prim('stack', 1, primitive_dictionary['stack'], True)
# Regenerate the palette, which will now include the new block.
- self.show_toolbar_palette(palette_name_to_index(_('blocks')),
+ self.show_toolbar_palette(palette_name_to_index('blocks'),
regenerate=True)
def _new_box_block(self, name):
@@ -4604,7 +4604,7 @@ before making changes to your program'))
if name == _('my box'):
return
# Choose a palette for the new block.
- palette = make_palette(_('blocks'))
+ palette = make_palette('blocks')
# Create a new block prototype.
primitive_dictionary['box'] = self._prim_box
@@ -4620,7 +4620,7 @@ before making changes to your program'))
lambda self, x: primitive_dictionary['box'](x))
# Regenerate the palette, which will now include the new block.
- self.show_toolbar_palette(palette_name_to_index(_('blocks')),
+ self.show_toolbar_palette(palette_name_to_index('blocks'),
regenerate=True)
def _new_storein_block(self, name):
@@ -4634,7 +4634,7 @@ before making changes to your program'))
if name == _('my box'):
return
# Choose a palette for the new block.
- palette = make_palette(_('blocks'))
+ palette = make_palette('blocks')
# Create a new block prototype.
primitive_dictionary['setbox'] = self._prim_setbox
@@ -4653,7 +4653,7 @@ variable'))
lambda self, x, y: primitive_dictionary['setbox']('box3', x, y))
# Regenerate the palette, which will now include the new block.
- self.show_toolbar_palette(palette_name_to_index(_('blocks')),
+ self.show_toolbar_palette(palette_name_to_index('blocks'),
regenerate=True)
def _prim_stack(self, x):