当前位置: 首页>>代码示例>>Python>>正文


Python html.E类代码示例

本文整理汇总了Python中etgen.html.E的典型用法代码示例。如果您正苦于以下问题:Python E类的具体用法?Python E怎么用?Python E使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了E类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_table_summary

    def get_table_summary(self, master, ar):
        # master is None when called on a master table.
        if master is None:
            sar = ar
        else:
            sar = self.request_from(ar, master_instance=master)
            
        # every element of `items` is a tuple `(state,
        # list-of-objects)`.  in ar are ordered by state. we just group
        # them 
        items = []
        ci = None
            
        for obj in sar:  # self.get_request_queryset(ar):
            btn = obj.obj2href(ar)
            if ci is not None and ci[0] is obj.state:
                ci[1].append(btn)
            else:
                ci = (obj.state, [btn])
                items.append(ci)

        # now render them as a UL containing on LI per item
        items = [E.li(str(i[0]), ' : ', *join_elems(i[1], ", "))
                 for i in items]

        return E.ul(*items)
开发者ID:khchine5,项目名称:xl,代码行数:26,代码来源:ui.py

示例2: href_button

    def href_button(self, url, text, title=None, icon_name=None, **kw):
        """Returns an etree object of a ``<a href>`` tag to the given URL
        `url`.

        `url` is what goes into the `href` part. If `url` is `None`,
        then we return just a ``<b>`` tag.

        `text` is what goes between the ``<a>`` and the ``</a>``. This
        can be either a string or a tuple (or list) of strings (or
        etree elements).

        """
        # logger.info('20121002 href_button %s', unicode(text))
        if title:
            # Remember that Python 2.6 doesn't like if title is a Promise
            kw.update(title=str(title))
            #~ return xghtml.E.a(text,href=url,title=title)
        if not isinstance(text, (tuple, list)):
            text = (text,)
        text = forcetext(text)
        if url is None:
            return E.b(*text)

        kw.update(href=url)
        if icon_name is not None:
            src = settings.SITE.build_static_url(
                'images', 'mjames', icon_name + '.png')
            img = E.img(src=src, alt=icon_name)
            return E.a(img, **kw)
        else:
            return E.a(*text, **kw)
开发者ID:lino-framework,项目名称:lino,代码行数:31,代码来源:renderer.py

示例3: value2html

 def value2html(self, ar):
     txt = dd.format_currency(self.value, False, True)
     if self.item.is_heading():
         # return E.b(txt)
         return E.div(E.b(txt), align="right")
     # return txt
     return E.div(txt, align="right")
开发者ID:lino-framework,项目名称:xl,代码行数:7,代码来源:models.py

示例4: description

    def description(cls, fld, ar):
        if ar is None:
            return ''
        elems = [fld.help_text, E.br()]
        def x(label, lst, xlst):
            if lst is None:
                return
            spec = ' '.join([i.name or i.value for i in lst])
            if xlst is not None:
                spec += ' ' + ' '.join([
                    "!"+(i.name or i.value) for i in xlst])
            spec = spec.strip()
            if spec:
                elems.extend([label, " ", spec, E.br()])

        x(_("columns"), fld.vat_columns, fld.exclude_vat_columns)
        x(_("regimes"), fld.vat_regimes, fld.exclude_vat_regimes)
        x(_("classes"), fld.vat_classes, fld.exclude_vat_classes)


        elems += [
            fld.__class__.__name__, ' ',
            DCLABELS[fld.dc], 
            "" if fld.both_dc else " only",
            E.br()]

        if fld.observed_fields:
            elems += [
                _("Sum of"), ' ',
                ' '.join([i.name for i in fld.observed_fields]),
                E.br()]

        return E.div(*forcetext(elems))
开发者ID:khchine5,项目名称:xl,代码行数:33,代码来源:choicelists.py

示例5: get_table_summary

    def get_table_summary(self, obj, ar):
        if obj is None:
            return

        visible_polls = Poll.objects.filter(state__in=(
            PollStates.active, PollStates.closed)).order_by('ref')

        qs = Response.objects.filter(partner=obj).order_by('date')
        polls_responses = {}
        for resp in qs:
            polls_responses.setdefault(resp.poll.pk, []).append(resp)

        items = []
        for poll in visible_polls:
            iar = self.insert_action.request_from(
                ar, obj, known_values=dict(poll=poll))
            elems = [str(poll), ' : ']
            responses = polls_responses.get(poll.pk, [])
            elems += join_elems(
                [ar.obj2html(r, dd.fds(r.date))
                 for r in responses], sep=', ')
            if poll.state == PollStates.active:
                elems += [' ', iar.ar2button()]
                #elems += [' ', iar.insert_button()]
            items.append(E.li(*elems))
        return E.div(E.ul(*items))
开发者ID:lino-framework,项目名称:xl,代码行数:26,代码来源:models.py

示例6: get_table_summary

    def get_table_summary(cls, obj, ar):
        """Customized :meth:`summary view
        <lino.core.actors.Actor.get_table_summary>` for this table.

        """
        sar = cls.request_from(ar, master_instance=obj)
        html = []
        # items = [ar.obj2html(o, str(o.milestone)) for o in sar]
        qs = cls.model.objects.filter(ticket=obj)
        qs = dd.plugins.tickets.milestone_model.add_param_filter(
            qs, lookup_prefix='milestone__',
            # show_active=dd.YesNo.yes
            )
        items = E.ul()
        for o in qs:
            items.append(
                E.li(o.obj2href(ar, text=getattr(o.wish_type,'text', _("Wish"))), " in ", o.milestone.obj2href(ar), " : ", o.remark)
            )
        if len(items) > 0:
            html.append(tostring(items))
        # items = [o.milestone.obj2href(ar) for o in sar]
        sar = cls.insert_action.request_from(sar)
        if sar.get_permission():
            btn = sar.ar2button()
            html.append(btn)

        return ar.html_text(ar.parse_memo(tostring(html)))
开发者ID:khchine5,项目名称:xl,代码行数:27,代码来源:desktop.py

示例7: show_state

 def show_state():
     l.append(sep)
     #~ l.append(E.b(unicode(state),style="vertical-align:middle;"))
     if state.button_text:
         l.append(E.b(u"{} {}".format(state.button_text, state)))
     else:
         l.append(E.b(str(state)))
开发者ID:lino-framework,项目名称:lino,代码行数:7,代码来源:model.py

示例8: get_table_summary

    def get_table_summary(self, mi, ar):
        if ar is None:
            return ''
        sar = self.request_from(ar, master_instance=mi)

        def fmt(obj):
            return str(obj)

        elems = []
        for obj in sar:
            # if len(elems) > 0:
            #     elems.append(', ')

            lbl = fmt(obj)
            # if obj.state.button_text:
            #     lbl = "{0}{1}".format(lbl, obj.state.button_text)
            elems.append(ar.obj2html(obj, lbl))
        elems = join_elems(elems, sep=', ')
        toolbar = []
        ar2 = self.insert_action.request_from(sar)
        if ar2.get_permission():
            btn = ar2.ar2button()
            toolbar.append(btn)

        if len(toolbar):
            toolbar = join_elems(toolbar, sep=' ')
            elems.append(E.p(*toolbar))

        return ar.html_text(E.div(*elems))
开发者ID:khchine5,项目名称:xl,代码行数:29,代码来源:models.py

示例9: get_sidebar_item

 def get_sidebar_item(self, request, other):
     kw = dict()
     add_user_language(kw, request)
     url = self.get_absolute_url(**kw)
     a = E.a(self.get_sidebar_caption(), href=url)
     if self == other:
         return E.li(a, **{'class':'active'})
     return E.li(a)
开发者ID:khchine5,项目名称:xl,代码行数:8,代码来源:models.py

示例10: what

 def what(self, obj, ar):
     chunks = []
     if obj.name:
         chunks += [E.b(str(obj)), E.br()]
     chunks += sepjoin(obj.features.all())
     #~ if obj.url:
         #~ chunks += [E.br(),E.a(_("More"),href=obj.url)]
     return E.p(*chunks)
开发者ID:lino-framework,项目名称:xl,代码行数:8,代码来源:models.py

示例11: fmt

 def fmt(obj):
     s = tostring(ar.action_button(ba, obj))
     s += fds(obj.created) + " " + obj.created.strftime(
         settings.SITE.time_format_strftime) + " "
     if obj.body:
         s += ar.parse_memo(obj.body)
     else:
         s += ar.parse_memo(obj.subject)
     e = etree.parse(StringIO(s), html_parser)
     return E.li(E.div(*e.iter()))
开发者ID:lino-framework,项目名称:lino,代码行数:10,代码来源:models.py

示例12: to_html

 def to_html(self, ar):
     self.analyze_view()
     get_rnd = rt.models.cal.EventGenerator.get_cal_entry_renderer
     if self.mode == TABLE_MODE:
         sep = ' '
         fmt = get_rnd(day_and_weekday)
     elif self.mode == UL_MODE:
         sep = ' '
         fmt = get_rnd(day_and_weekday)
     elif self.mode == PLAIN_MODE:
         sep = ', '
         fmt = get_rnd(dd.fds)
         
     def xxx(list_of_entries):
         elems = []
         for e in list_of_entries:
             if len(elems):
                 elems.append(sep)
             elems.extend(fmt(e, ar))
         return elems
     
     if self.mode == TABLE_MODE:
         rows = []
         cells = [E.th("")] + [E.th(monthname(m+1)) for m in range(12)]
         # print(''.join([tostring(c) for c in cells]))
         rows.append(E.tr(*cells))
         for y in self.years.values():
             cells = [E.td(str(y.year), width="4%")]
             for m in y.months:
                 # every m is a list of etree elems
                 cells.append(E.td(*xxx(m), width="8%", **ar.renderer.cellattrs))
             # print(str(y.year) +":" + ''.join([tostring(c) for c in cells]))
             rows.append(E.tr(*cells))
         return E.table(*rows, **ar.renderer.tableattrs)
     
     if self.mode == UL_MODE:
         items = []
         for y in self.years.values():
             for m, lst in enumerate(y.months):
                 if len(lst):
                     items.append(E.li(
                         monthname(m+1), " ", str(y.year), ": ", *xxx(lst)))
         return E.ul(*items)
     
     if self.mode == PLAIN_MODE:
         elems = []
         for y in self.years.values():
             for lst in y.months:
                 if len(lst):
                     if len(elems):
                         elems.append(sep)
                     elems.extend(xxx(lst))
         return E.p(*elems)
     
     raise Exception("20180720")
开发者ID:khchine5,项目名称:xl,代码行数:55,代码来源:ui.py

示例13: question

    def question(self, obj, ar):
        if obj.question.number:
            txt = obj.question.NUMBERED_TITLE_FORMAT % (
                obj.question.number, obj.question.title)
        else:
            txt = obj.question.title

        attrs = {}
        if obj.question.details:
            attrs.update(title=obj.question.details)
        if obj.question.is_heading:
            txt = E.b(txt, **attrs)
        return ar.html_text(E.span(txt, **attrs))
开发者ID:lino-framework,项目名称:xl,代码行数:13,代码来源:models.py

示例14: calender_header

 def calender_header(ar):
     header = "Calendar Type"
     elems = [E.h2(*header, align="center")]
     today_url = ar.renderer.js2url("""
             Lino.cal.DailyView.detail.run(null, {"record_id": 0})
             """)
     week_url = ar.renderer.js2url("""
                     Lino.cal.WeeklyView.detail.run(null, {"record_id": 0})
                     """)
     elems.append(E.p(ar.renderer.href(today_url, gettext("Day")), align="center"))
     elems.append(E.p(ar.renderer.href(week_url, gettext("Week")), align="center"))
     elems.append(E.p(ar.goto_pk(0, gettext("This month")), align="center"))
     return elems
开发者ID:lino-framework,项目名称:xl,代码行数:13,代码来源:ui.py

示例15: f

        def f(obj, ar):
            if obj is None or ar is None:
                return E.div()
            try:
                utype = UploadType.objects.get(shortcut=i)
            except UploadType.DoesNotExist:
                return E.div()
            items = []
            target = sender.modules.resolve(i.target)
            sar = ar.spawn_request(
                actor=target,
                master_instance=obj,
                known_values=dict(type=utype))
                # param_values=dict(pupload_type=et))
            n = sar.get_total_count()
            if n == 0:
                iar = target.insert_action.request_from(
                    sar, master_instance=obj)
                btn = iar.ar2button(
                    None, _("Upload"), icon_name="page_add",
                    title=_("Upload a file from your PC to the server."))
                items.append(btn)
            elif n == 1:
                after_show = ar.get_status()
                obj = sar.data_iterator[0]
                items.append(sar.renderer.href_button(
                    sender.build_media_url(obj.file.name),
                    _("show"),
                    target='_blank',
                    icon_name='page_go',
                    style="vertical-align:-30%;",
                    title=_("Open the uploaded file in a "
                            "new browser window")))
                after_show.update(record_id=obj.pk)
                items.append(sar.window_action_button(
                    sar.ah.actor.detail_action,
                    after_show,
                    _("Edit"), icon_name='application_form',
                    title=_("Edit metadata of the uploaded file.")))
            else:
                obj = sar.sliced_data_iterator[0]
                items.append(ar.obj2html(
                    obj, pgettext("uploaded file", "Last")))

                btn = sar.renderer.action_button(
                    obj, sar, sar.bound_action,
                    _("All {0} files").format(n),
                    icon_name=None)
                items.append(btn)

            return E.div(*join_elems(items, ', '))
开发者ID:lino-framework,项目名称:lino,代码行数:51,代码来源:models.py


注:本文中的etgen.html.E类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。