def do_hr(self, attrs):
     if attrs.has_key('src') and self.app.load_images:
         align = extract_keyword('align', attrs, default='center',
                 conv=lambda s,gu=grailutil: gu.conv_enumeration(
                     gu.conv_normstring(s), ['left', 'center', 'right']))
         self.implied_end_p()
         self.formatter.push_alignment(align)
         self.do_img({'border': '0', 'src': attrs['src']})
         self.formatter.pop_alignment()
         self.formatter.add_line_break()
         return
     HTMLParser.do_hr(self, attrs)
     color = extract_keyword('color', attrs)
     rule = self.viewer.rules[-1]
     if attrs.has_key('noshade') and self.viewer.rules:
         if color:
             if not self.configcolor('background', color, widget=rule):
                 self.configcolor('background',
                                  self.viewer.text['foreground'],
                                  widget=rule)
         else:
             # this color is known to work already
             rule.config(background=self.viewer.text['foreground'])
         rule.config(relief=FLAT)
         size = extract_keyword('size', attrs, 2,
                                conv=grailutil.conv_integer)
         if size == 1:
             # could not actually set it to 1 unless it was flat; do it now:
             width = string.atoi(rule.cget('width'))
             rule.config(borderwidth=0, height=1, width=width+2)
     elif color:
         self.configcolor('background', color, widget=rule)
Exemple #2
0
 def do_hr(self, attrs):
     if attrs.has_key('src') and self.app.load_images:
         align = extract_keyword('align', attrs, default='center',
                 conv=lambda s,gu=grailutil: gu.conv_enumeration(
                     gu.conv_normstring(s), ['left', 'center', 'right']))
         self.implied_end_p()
         self.formatter.push_alignment(align)
         self.do_img({'border': '0', 'src': attrs['src']})
         self.formatter.pop_alignment()
         self.formatter.add_line_break()
         return
     HTMLParser.do_hr(self, attrs)
     color = extract_keyword('color', attrs)
     rule = self.viewer.rules[-1]
     if attrs.has_key('noshade') and self.viewer.rules:
         if color:
             if not self.configcolor('background', color, widget=rule):
                 self.configcolor('background',
                                  self.viewer.text['foreground'],
                                  widget=rule)
         else:
             # this color is known to work already
             rule.config(background=self.viewer.text['foreground'])
         rule.config(relief=FLAT)
         size = extract_keyword('size', attrs, 2,
                                conv=grailutil.conv_integer)
         if size == 1:
             # could not actually set it to 1 unless it was flat; do it now:
             width = string.atoi(rule.cget('width'))
             rule.config(borderwidth=0, height=1, width=width+2)
     elif color:
         self.configcolor('background', color, widget=rule)