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


Python tags.img函数代码示例

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


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

示例1: visit_cmsimage_node

    def visit_cmsimage_node(self, node):
        maxwidth=node.attributes['maxwidth']
        maxheight=node.attributes['maxheight']
            
        if maxwidth is None or maxheight is None:
            tag = T.img(src=self.systemURL.child('assets').child( node.attributes['id'] ))
        else:
            tag = T.img(src=self.systemURL.child('assets').child( node.attributes['id'] ).add('size','%sx%s'%(maxwidth,maxheight)))
        
        if node.attributes['alt']:
            tag = tag(alt=node.attributes['alt'])
        if node.attributes['title']:
            tag = tag(title=node.attributes['title'])
        if node.attributes['cssclass']:
            tag = tag(class_=node.attributes['cssclass'])
        if node.attributes['href']:
            tag = T.a(href=node.attributes['href'])[ tag ]
            
        if node.attributes['caption']:
            tag = T.div(class_='cmsimage')[tag,T.p[node.attributes['caption']]]
        else:
            tag = T.div(class_='cmsimage')[tag]
        html = flat.flatten(tag)

        self.body.append(html)
开发者ID:timparkin,项目名称:into-the-light,代码行数:25,代码来源:restsupport.py

示例2: render_adminswapper

 def render_adminswapper(self,ctx,data):
     if isAdminOn(ctx) == True:
         if ctx.arg('q'):
             return T.a(href="?admin=False&q=%s"%ctx.arg('q'),class_="adminswapper")[ T.img(src="/skin/images/swapadmin.gif") ]
         else:
             return T.a(href="?admin=False",class_="adminswapper")[ T.img(src="/skin/images/swapadmin.gif") ]
     else:
         if ctx.arg('q'):
             return T.a(href="?admin=True&q=%s"%ctx.arg('q'),class_="adminswapper")[ T.img(src="/skin/images/swapadmin.gif") ]
         else:
             return T.a(href="?admin=True",class_="adminswapper")[ T.img(src="/skin/images/swapadmin.gif") ]
开发者ID:timparkin,项目名称:into-the-light,代码行数:11,代码来源:common.py

示例3: render_backgroundswapper

 def render_backgroundswapper(self,ctx,data):
     if isInverted(ctx) == True:
         if ctx.arg('q'):
             return T.a(href="?invert=False&q=%s"%ctx.arg('q'),class_="backgroundswapper")[ T.img(src="/skin/images/swapbackground-invert.gif") ]
         else:
             return T.a(href="?invert=False",class_="backgroundswapper")[ T.img(src="/skin/images/swapbackground-invert.gif") ]
     else:
         if ctx.arg('q'):
             return T.a(href="?invert=True&q=%s"%ctx.arg('q'),class_="backgroundswapper")[ T.img(src="/skin/images/swapbackground.gif") ]
         else:
             return T.a(href="?invert=True",class_="backgroundswapper")[ T.img(src="/skin/images/swapbackground.gif") ]
开发者ID:timparkin,项目名称:into-the-light,代码行数:11,代码来源:common.py

示例4: render

    def render(self, ctx, key, args, errors):
        """
            Render the data.

            This either renders a link to the original file, if specified, and
            no new file has been uploaded. Or a link to the uploaded file.

            The request to get the data should be routed to the getResouce
            method.
        """
        form = iformal.IForm( ctx )

        namer = self._namer( key )
        resourceIdName = namer( 'resource_id' )
        originalIdName = namer( 'original_id' )

        # get the resource id first from the resource manager
        # then try the request
        resourceId = form.resourceManager.getResourceId( key )
        if resourceId is None:
            resourceId = self._getFromArgs( args, resourceIdName )
        resourceId = self._blankField( resourceId )

        # Get the original key from a hidden field in the request,
        # then try the request file.data initial data.
        originalKey = self._getFromArgs( args, originalIdName )
        if not errors and not originalKey:
            originalKey = args.get( key )
        originalKey = self._blankField( originalKey )

        if resourceId:
            # Have an uploaded file, so render a URL to the uploaded file
            tmpURL = widgetResourceURL(form.name).child(key).child( self.FROM_RESOURCE_MANAGER ).child(resourceId)
            yield T.p[T.img(src=tmpURL)]
        elif originalKey:
            # The is no uploaded file, but there is an original, so render a
            # URL to it
            if self.originalKeyIsURL:
                tmpURL = originalKey
            else:
                tmpURL = widgetResourceURL(form.name).child(key).child( self.FROM_CONVERTIBLE ).child( originalKey )
            yield T.p[T.img(src=tmpURL)]
        else:
            # No uploaded file, no original
            yield T.p[T.strong['Nothing uploaded']]

        yield T.input(name=key, id=render_cssid(key),type='file')

        # Id of uploaded file in the resource manager
        yield T.input(name=resourceIdName,value=resourceId,type='hidden')
        if originalKey:
            # key of the original that can be used to get a file later
            yield T.input(name=originalIdName,value=originalKey,type='hidden')
开发者ID:nakedible,项目名称:vpnease-l2tp,代码行数:53,代码来源:widget.py

示例5: gotProducts

 def gotProducts(products):
     htmlblock = []
     for n,product in enumerate(products):
         column = divmod(n,3)[1]+1
         name = product.code
         title = product.title
         shortDescription = product.summary
         imgsrc='/system/ecommerce/%s/mainImage?size=190x300&sharpen=1.0x0.5%%2b0.8%%2b0.1'%product.id
         
         html = T.div(class_='category c%s'%column)[
             T.a(href=url.here.child(name))[
                 T.img(src=imgsrc,width=190),T.span(class_='mbf-item')['#gallery %s'%product.code]
                 ],
             T.h4[
                 T.a(href=url.here.child(name))[
                     title
                     ]
                 ],
             T.p[
                 T.a(href=url.here.child(name))[
                     shortDescription
                 ]
             ]
         ]
         htmlblock.append(html)
         # Group the output into threes
         if column == 3:
             out = htmlblock
             htmlblock = []
             yield T.div(class_="threecolumnleft clearfix")[ out ]
     # and then yield anything left over if the last item wasn't at the end of a row
     if column != 3:
         yield T.div(class_="threecolumnleft clearfix")[ htmlblock ]
开发者ID:timparkin,项目名称:into-the-light,代码行数:33,代码来源:gallery.py

示例6: renderImmutable

    def renderImmutable(self, ctx, key, args, errors):
        form = iformal.IForm(ctx)

        namer = self._namer(key)
        originalIdName = namer('original_id')

        # Get the original key from a hidden field in the request,
        # then try the request form.data initial data.
        originalKey = self._getFromArgs( args, originalIdName )
        if not errors and not originalKey:
            originalKey = args.get( key )
        originalKey = self._blankField( originalKey )

        if originalKey:
            # The is no uploaded file, but there is an original, so render a
            # URL to it
            if self.originalKeyIsURL:
                tmpURL = originalKey
            else:
                tmpURL = widgetResourceURL(form.name).child(key).child(self.FROM_CONVERTIBLE).child(originalKey)
            yield T.p[T.img(src=tmpURL)]
        else:
            # No uploaded file, no original
            yield T.p[T.strong['Nothing uploaded']]

        if originalKey:
            # key of the original that can be used to get a file later
            yield T.input(name=originalIdName,value=originalKey,type='hidden')
开发者ID:nakedible,项目名称:vpnease-l2tp,代码行数:28,代码来源:widget.py

示例7: stanFromValue

    def stanFromValue(self, idx, item, value):
        # Value will generally be 'None' in this case...
        tag = tags.div()
        for action in self.actions:
            actionable = action.actionable(item)
            if actionable:
                iconURL = action.iconURL
            else:
                iconURL = action.disabledIconURL

            stan = tags.img(src=iconURL, **{'class' : 'tdb-action'})

            if actionable:
                linkstan = action.toLinkStan(idx, item)
                if linkstan is None:
                    handler = 'Mantissa.TDB.Controller.get(this).performAction(%r, %r); return false'
                    handler %= (action.actionID, idx)
                    stan = tags.a(href='#', onclick=handler)[stan]
                else:
                    stan = linkstan

            tag[stan]

        # at some point give the javascript the description to show
        # or something
        return tag
开发者ID:fusionapp,项目名称:mantissa,代码行数:26,代码来源:tdbview.py

示例8: _timing_chart

    def _timing_chart(self):
        started = self.update_status.get_started()
        total = self.update_status.timings.get("total")
        per_server = self.update_status.timings.get("per_server")
        base = "http://chart.apis.google.com/chart?"
        pieces = ["cht=bhs"]
        pieces.append("chco=ffffff,4d89f9,c6d9fd")  # colors
        data0 = []
        data1 = []
        data2 = []
        nb_nodes = 0
        graph_botom_margin = 21
        graph_top_margin = 5
        peerids_s = []
        top_abs = started
        # we sort the queries by the time at which we sent the first request
        sorttable = [(times[0][1], peerid) for peerid, times in per_server.items()]
        sorttable.sort()
        peerids = [t[1] for t in sorttable]

        for peerid in peerids:
            nb_nodes += 1
            times = per_server[peerid]
            peerid_s = idlib.shortnodeid_b2a(peerid)
            peerids_s.append(peerid_s)
            # for servermap updates, there are either one or two queries per
            # peer. The second (if present) is to get the privkey.
            op, q_started, q_elapsed = times[0]
            data0.append("%.3f" % (q_started - started))
            data1.append("%.3f" % q_elapsed)
            top_abs = max(top_abs, q_started + q_elapsed)
            if len(times) > 1:
                op, p_started, p_elapsed = times[0]
                data2.append("%.3f" % p_elapsed)
                top_abs = max(top_abs, p_started + p_elapsed)
            else:
                data2.append("0.0")
        finished = self.update_status.get_finished()
        if finished:
            top_abs = max(top_abs, finished)
        top_rel = top_abs - started
        chs = "chs=400x%d" % ((nb_nodes * 28) + graph_top_margin + graph_botom_margin)
        chd = "chd=t:" + "|".join([",".join(data0), ",".join(data1), ",".join(data2)])
        pieces.append(chd)
        pieces.append(chs)
        chds = "chds=0,%0.3f" % top_rel
        pieces.append(chds)
        pieces.append("chxt=x,y")
        pieces.append("chxr=0,0.0,%0.3f" % top_rel)
        pieces.append("chxl=1:|" + "|".join(reversed(peerids_s)))
        # use up to 10 grid lines, at decimal multiples.
        # mathutil.next_power_of_k doesn't handle numbers smaller than one,
        # unfortunately.
        # pieces.append("chg="

        if total is not None:
            finished_f = 1.0 * total / top_rel
            pieces.append("chm=r,FF0000,0,%0.3f,%0.3f" % (finished_f, finished_f + 0.01))
        url = base + "&".join(pieces)
        return T.img(src=url, border="1", align="right", float="right")
开发者ID:GunioRobot,项目名称:tahoe-lafs,代码行数:60,代码来源:status.py

示例9: render_random

 def render_random(self, ctx, data):
     
     for randRow in randomSet(self.graph, 3):
         print 'randRow', randRow
         current = randRow['uri']
         bindings = {"pic" : current}
         tags = [[T.a(href=['/set?tag=', row['tag']])[row['tag']], ' ']
                 for row in self.graph.queryd(
                     """SELECT DISTINCT ?tag WHERE {
                          ?pic scot:hasTag [
                            rdfs:label ?tag ]
                        }""", initBindings=bindings)]
         depicts = [[T.a(href=localSite(row['uri']))[row['label']], ' ']
                    for row in self.graph.queryd("""
                      SELECT DISTINCT ?uri ?label WHERE {
                        ?pic foaf:depicts ?uri .
                        ?uri rdfs:label ?label .
                      }""", initBindings=bindings)]
         # todo: description and tags would be good too, and some
         # other service should be rendering this whole section
         yield T.div(class_="randPick")[
             T.a(href=['/set?',
                       urllib.urlencode(dict(date=randRow['date'],
                                             current=current))])[
                 T.img(src=[localSite(current), '?size=medium']),
                 ],
             T.div[tags],
             T.div[depicts],
             T.div[randRow['filename'].replace('/my/pic/','')],
             ]
开发者ID:drewp,项目名称:photo,代码行数:30,代码来源:search.py

示例10: render_pics

    def render_pics(self, ctx, data):
        rows = []
        d = URIRef(ctx.arg('dir'))
        for i, (pic, filename) in enumerate(sorted(picsInDirectory(self.graph, d))[:]):
            img = T.img(src=[localSite(pic), '?size=thumb'],
                        # look these up in the graph
                        width=75, height=56,
                        onclick='javascript:photo.showLarge("%s")' %
                        (localSite(pic) + "?size=large"))


            tableRow = T.table(class_="picRow")[T.tr[
                T.td[T.a(href=localSite(pic))[filename]],
                T.td[img],
                T.td[
                T.div["Depicts: ", T.input(type="text", class_="tags")],
                T.div["Comment: ", T.input(type="text")],
                ],
                ]]

            toCopy = "protoSectionSplitter"
            if i ==0:
                toCopy = "protoSectionBreak"
                

            rows.append([T.raw('<script type="text/javascript">document.write(document.getElementById("%s").innerHTML);</script>' % toCopy),
                         tableRow])
            
        return rows
开发者ID:drewp,项目名称:photo,代码行数:29,代码来源:edit.py

示例11: gotSize

        def gotSize(size):
            quality = ctx.arg('quality')
            large = ctx.arg('large',None)
            if large is not None:            
                size = 'size=968x1200&'
                quality='100'
            else:
                size = 'size=600x632&'
            if quality is None:
                quality = '&quality=60'
                linkhref='?quality=93'
                enhance=T.p(class_='enhance')['click to enhance']
            else:
                quality = '&quality=100'
                linkhref='?large=True'
                enhance = T.p(class_='enhance')['click to see larger']

            if large is not None:
                enhance = T.p(class_='enhance')['click to return to small view']
                linkhref='?quality=93'
                
                
            if common.isInverted(ctx) is True:
                invert='&amp;invert=inverted'
            else:
                invert=''
            imgsrc='/system/ecommerce/%s/mainImage?%ssharpen=1.0x0.5%%2b0.8%%2b0.1%s%s'%(self.photo.id,size,quality,invert)
            html = T.a(class_='photo',href=linkhref)[ enhance,T.img(src=imgsrc) ]
            return html
开发者ID:timparkin,项目名称:into-the-light,代码行数:29,代码来源:gallery.py

示例12: gotAll

        def gotAll(items,categories,products):
            categoryCMSItems = {}
            for item in items:
                i = item.getProtectedObject()
                categoryCMSItems[i.name] = i

            categoryCMSItemMainImage = {}
            categoryCMSItemCode = {}
            for categoryCMSItem in categoryCMSItems.values():
                category = categoryCMSItem.name
                for product in products:
                    if u'gallery.%s'%category in product.categories: 
                        match = product
                        categoryCMSItemMainImage[categoryCMSItem.name] = match.id
                        categoryCMSItemCode[categoryCMSItem.name] = match.code
                        break

            htmlblock = []
            for n, category in enumerate(categories.children):
                name = category.textid
                categoryCMSItem = categoryCMSItems.get(name,None)
                column = divmod(n,3)[1]+1
                try: 
                    title = categoryCMSItem.title
                    shortDescription = categoryCMSItem.shortDescription
                except AttributeError:
                    title = category.label
                    shortDescription = ''
                
                try:
                    imgsrc='/system/ecommerce/%s/mainImage?size=190x300&sharpen=1.0x0.5%%2b0.7%%2b0.1'%categoryCMSItemMainImage[name]
                except KeyError:
                    imgsrc='/skin/images/spacer.gif'
                
                html = T.div(class_='category c%s'%column)[
                    T.a(href=url.here.child(name))[
                        T.img(src=imgsrc,width=190),T.span(class_='mbf-item')['#gallery %s'%categoryCMSItemCode[name]]
                        ],
                    T.h4[
                        T.a(href=url.here.child(name))[
                            title
                            ]
                        ],
                    T.p[
                        T.a(href=url.here.child(name))[
                            shortDescription
                        ]
                    ]
                ]
                htmlblock.append(html)
                # Group the output into threes
                if column == 3:
                    out = htmlblock
                    htmlblock = []
                    yield T.div(class_="threecolumnleft clearfix")[ out ]
            # and then yield anything left over if the last item wasn't at the end of a row
            if column != 3:
                yield T.div(class_="threecolumnleft clearfix")[ htmlblock ]
开发者ID:timparkin,项目名称:into-the-light,代码行数:58,代码来源:gallery.py

示例13: render_roster

    def render_roster(self, ctx, data):
        request = inevow.IRequest(ctx)
        username = request.getUser()

        ret = tags.table(border=0, cellspacing=5, cellpadding=2)
        row = tags.tr(height=25)[
            tags.th["UIN/Screen Name"],
            tags.th["Nickname"],
            tags.th["Network"],
            tags.th["Avatar"],
            tags.th["Status"]
        ]
        ret[row]
        roster = self.pytrans.xdb.getList("roster", username)
        if not roster:
            return ret
        for item in roster:
            if item[0][0].isdigit():
                network = "ICQ"
            else:
                network = "AIM"
            avatar = "-"
            if not config.disableAvatars and item[1].has_key("shahash"):
                avatar = tags.a(href=("/avatars/%s" % item[1]["shahash"]))[
                    tags.img(
                        border=0, height=25, src=("/avatars/%s" % item[1]["shahash"]))
                ]
            nickname = "-"
            if "nickname" in item[1]:
                nickname = item[1]["nickname"]
            else:
                if username in self.pytrans.sessions and \
                        self.pytrans.sessions[username].ready:
                    c = self.pytrans.sessions[username].contactList.getContact(
                        "%[email protected]%s" % (item[0], config.jid))
                    if c.nickname and c.nickname != "":
                        nickname = c.nickname
            status = "-"
            if username in self.pytrans.sessions and \
                    self.pytrans.sessions[username].ready:
                c = self.pytrans.sessions[username].contactList.getContact(
                    "%[email protected]%s" % (item[0], config.jid))
                status = c.ptype
                if not status:
                    status = c.show
                    if not status:
                        status = "available"
            row = tags.tr(height=25)[
                tags.td(height=25, align="middle")[item[0]],
                tags.td(height=25, align="middle")[nickname],
                tags.td(height=25, align="middle")[network],
                tags.td(height=25, align="middle")[avatar],
                tags.td(height=25, align="middle")[status]
            ]
            ret[row]
        return ret
开发者ID:2mf,项目名称:pyicqt,代码行数:56,代码来源:handler.py

示例14: genheaders

    def genheaders():
        for i, head in enumerate(headers):
            badge, description = head
            if currentView == description:
                klas = 'tab-selected'
            else:
                klas = 'tab'

            yield T.a(href=here.add('currentView', description))[
                T.span(_class="%s" % klas)[
                    T.img(src="/images/%s.png" % badge, style="margin-right: 5px;"), description]]
开发者ID:braams,项目名称:shtoom,代码行数:11,代码来源:prefs.py

示例15: agentCommonInfo

 def agentCommonInfo(self, ctx):
     agentInfo = self.agentInfo
     clientInfo = self.clientInfo
     
     if clientInfo is None:
         clientStateImg = T.img(src = '/images/cl-status/dead.png')
         clientState = 'disconnected'
         
         clientId = 'N/A'
         clientUuid = 'N/A'
         clientEndpoint = 'N/A'
     else:
         clientStateImg = T.img(src = '/images/cl-status/established.png')
         clientState = 'established'
         
         clientId = clientInfo.id
         clientUuid = clientInfo.uuid
         clientEndpoint = clientInfo.endpoint
     
     for slot, data in [('hostname', agentInfo.hostname),
                         ('domainname', agentInfo.domainname),
                         ('osname', agentInfo.osname),
                         ('release', agentInfo.release),
                         ('arch', agentInfo.machineArch),
                         ('numCPUs', agentInfo.numCPUs),
                         ('numCores', agentInfo.numCores),
                         ('memTotal', agentInfo.memTotal),
                         ('agentId', agentInfo.agentId),
                         ('lastOnline', agentInfo.lastOnline),
                         ('clientStateImg', clientStateImg),
                         ('clientState', clientState),
                         ('clientId', clientId),
                         ('clientUuid', clientUuid),
                         ('clientEndpoint', clientEndpoint)]:
             ctx.fillSlots(slot, data)
         
     return loaders.xmlfile(webappPath('agent/loadinfoagent.html'))
开发者ID:myaut,项目名称:tsload,代码行数:37,代码来源:agent.py


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