From: W. Trevor King <wking@drexel.edu> Date: Sun, 28 Mar 2010 01:08:44 +0000 (-0400) Subject: Add titles to regions (Firefox, and possibly others) use them for tooltips. X-Git-Tag: 0.1~8 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=f953c513e2de8b828e8bd5d7830e9595fc3d2b40;p=pyrisk.git Add titles to regions (Firefox, and possibly others) use them for tooltips. Use world.name as template.name and SVG <title>. --- diff --git a/pyrisk/graphics.py b/pyrisk/graphics.py index df63232..6e47f2a 100644 --- a/pyrisk/graphics.py +++ b/pyrisk/graphics.py @@ -48,7 +48,7 @@ class TemplateLibrary (object): region_pointlists,route_pointlists,continent_colors,line_colors = \ self._get_data(name) regions = self._generate_regions(region_pointlists, route_pointlists) - return Template('template', regions, continent_colors, line_colors) + return Template(name, regions, continent_colors, line_colors) def _get_data(self, name): dirname = os.path.join(self.template_dir, name.lower()) try: @@ -370,8 +370,9 @@ class WorldRenderer (object): % (float(width)/self.dpcm, float(height)/self.dpcm, width, height), ' xmlns="http://www.w3.org/2000/svg" version="1.1">', - '<desc>PyRisk world: %s</desc>' % template, - ] + '<title>%s</title>' % template, + '<desc>A PyRisk world snapshot</desc>', + ] drawn_rts = {} for r in template.regions: t = self._matching_territory(world, r) @@ -382,8 +383,9 @@ class WorldRenderer (object): b_col_attr = 'stroke="%s" stroke-width="%d"' \ % (template.line_colors['border'], self.line_width) lines.extend([ - '<!-- %s -->' % r, - '<polygon fill="%s" %s' % (c_col, b_col_attr), + '<polygon title="%s / %s / %s"' + % (t, t.player, t.armies), + ' fill="%s" %s' % (c_col, b_col_attr), ' points="%s" />' % ' '.join(['%d,%d' % ((region_pos[id(r)]+p) *(1,-1) # svg y value increases down