Пример #1
0
 def html(self, context):
     js = self.javascript(context)
     color_picker_url = self.color_picker_url
     assert color_picker_url, (
         'You must give a base URL for the color picker')
     name = context.name(self)
     color_id = context.name(self, adding='pick')
     default_color = context.default(self) or '#ffffff'
     return html.table(
         cellspacing=0, border=0,
         c=[html.tr(
         html.td(width=20, id=color_id,
                 style="background-color: %s; border: thin black solid;" % default_color,
                 c=" "),
         html.td(
         html.input(type='text', size=8,
                    onchange="document.getElementById('%s').style.backgroundColor = this.value; return true" % color_id,
                    name=name, value=context.default(self)),
         html.input(type='button', value="pick",
                    onclick="colorpick(this, '%s', '%s')" % (name, color_id))))])
Пример #2
0
 def html_line(self, line, fields, context):
     """
     Formats lines: '=text' means a literal of 'text', 'name' means
     the named field, ':name' means the named field, but without a
     label.
     """
     cells = []
     for item in line:
         if item.startswith('='):
             cells.append(html.td(item))
             continue
         if item.startswith(':'):
             field = fields[item[1:]]
             label = ''
         else:
             field = fields[item]
             label = self.format_label(field, context)
         if label:
             label = html(label, html.br)
         cells.append(html.td('\n', label, 
                              field.render(context),
                              valign="bottom"))
         cells.append('\n')
     return html.table(html.tr(cells))
Пример #3
0
 def wrap_fields(self, rendered_fields, context):
     return html.table(rendered_fields,
                       width=self.width,
                       class_=self.table_class,
                       c=rendered_fields)