|
@@ -80,7 +80,7 @@ def _is_sequence(seq, length=None,
|
|
|
if length == len(seq):
|
|
if length == len(seq):
|
|
|
return True
|
|
return True
|
|
|
elif error_message:
|
|
elif error_message:
|
|
|
- raise TypeError('%s is %s; must be %s of length %d' %
|
|
|
|
|
|
|
+ raise TypeError('sequence %s is not a sequence but %s; must be %s of length %d' %
|
|
|
(str(seq), type(seq),
|
|
(str(seq), type(seq),
|
|
|
', '.join([str(t) for t in legal_types]),
|
|
', '.join([str(t) for t in legal_types]),
|
|
|
len(seq)))
|
|
len(seq)))
|
|
@@ -89,7 +89,7 @@ def _is_sequence(seq, length=None,
|
|
|
else:
|
|
else:
|
|
|
return True
|
|
return True
|
|
|
elif error_message:
|
|
elif error_message:
|
|
|
- raise TypeError('%s is %s, %s; must be %s' %
|
|
|
|
|
|
|
+ raise TypeError('sequence %s is not a sequence but %s, %s; must be %s' %
|
|
|
(str(seq), seq.__class__.__name__, type(seq),
|
|
(str(seq), seq.__class__.__name__, type(seq),
|
|
|
','.join([str(t)[5:-1] for t in legal_types])))
|
|
','.join([str(t)[5:-1] for t in legal_types])))
|
|
|
else:
|
|
else:
|
|
@@ -1303,19 +1303,29 @@ class Text(Point):
|
|
|
'center'; if 'left', the text starts at `position`, and if
|
|
'center'; if 'left', the text starts at `position`, and if
|
|
|
'right', the right and of the text is located at `position`.
|
|
'right', the right and of the text is located at `position`.
|
|
|
"""
|
|
"""
|
|
|
- def __init__(self, text, position, alignment='center', fontsize=0):
|
|
|
|
|
|
|
+ def __init__(self, text, position, alignment='center', fontsize=0,
|
|
|
|
|
+ bgcolor=None, fgcolor=None, fontfamily=None):
|
|
|
|
|
+ """
|
|
|
|
|
+ fontfamily can be (e.g.) 'serif' or 'monospace' (for code!).
|
|
|
|
|
+ """
|
|
|
is_sequence(position)
|
|
is_sequence(position)
|
|
|
is_sequence(position, length=2, can_be_None=True)
|
|
is_sequence(position, length=2, can_be_None=True)
|
|
|
self.text = text
|
|
self.text = text
|
|
|
self.position = position
|
|
self.position = position
|
|
|
self.alignment = alignment
|
|
self.alignment = alignment
|
|
|
self.fontsize = fontsize
|
|
self.fontsize = fontsize
|
|
|
|
|
+ self.bgcolor = bgcolor
|
|
|
|
|
+ self.fgcolor = fgcolor
|
|
|
|
|
+ self.fontfamily = fontfamily
|
|
|
Point.__init__(self, position[0], position[1])
|
|
Point.__init__(self, position[0], position[1])
|
|
|
#no need for self.shapes here
|
|
#no need for self.shapes here
|
|
|
|
|
|
|
|
def draw(self):
|
|
def draw(self):
|
|
|
- drawing_tool.text(self.text, (self.x, self.y),
|
|
|
|
|
- self.alignment, self.fontsize)
|
|
|
|
|
|
|
+ drawing_tool.text(
|
|
|
|
|
+ self.text, (self.x, self.y),
|
|
|
|
|
+ self.alignment, self.fontsize,
|
|
|
|
|
+ arrow_tip=None, bgcolor=self.bgcolor, fgcolor=self.fgcolor,
|
|
|
|
|
+ fontfamily=self.fontfamily)
|
|
|
|
|
|
|
|
def __str__(self):
|
|
def __str__(self):
|
|
|
return 'text "%s" at (%g,%g)' % (self.text, self.x, self.y)
|
|
return 'text "%s" at (%g,%g)' % (self.text, self.x, self.y)
|
|
@@ -1337,9 +1347,13 @@ class Text_wArrow(Text):
|
|
|
Text.__init__(self, text, position, alignment, fontsize)
|
|
Text.__init__(self, text, position, alignment, fontsize)
|
|
|
|
|
|
|
|
def draw(self):
|
|
def draw(self):
|
|
|
- drawing_tool.text(self.text, self.position,
|
|
|
|
|
- self.alignment, self.fontsize,
|
|
|
|
|
- self.arrow_tip)
|
|
|
|
|
|
|
+ drawing_tool.text(
|
|
|
|
|
+ self.text, self.position,
|
|
|
|
|
+ self.alignment, self.fontsize,
|
|
|
|
|
+ arrow_tip=self.arrow_tip,
|
|
|
|
|
+ bgcolor=self.bgcolor, fgcolor=self.fgcolor,
|
|
|
|
|
+ fontfamily=self.fontfamily)
|
|
|
|
|
+
|
|
|
def __str__(self):
|
|
def __str__(self):
|
|
|
return 'annotation "%s" at (%g,%g) with arrow to (%g,%g)' % \
|
|
return 'annotation "%s" at (%g,%g) with arrow to (%g,%g)' % \
|
|
|
(self.text, self.x, self.y,
|
|
(self.text, self.x, self.y,
|