本文整理汇总了Python中gluon.html.TAG属性的典型用法代码示例。如果您正苦于以下问题:Python html.TAG属性的具体用法?Python html.TAG怎么用?Python html.TAG使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类gluon.html
的用法示例。
在下文中一共展示了html.TAG属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: widget
# 需要导入模块: from gluon import html [as 别名]
# 或者: from gluon.html import TAG [as 别名]
def widget(cls, field, value, **attributes):
_id = '%s_%s' % (field.tablename, field.name)
_name = field.name
if field.type == 'list:integer':
_class = 'integer'
else:
_class = 'string'
requires = field.requires if isinstance(
field.requires, (IS_NOT_EMPTY, IS_LIST_OF)) else None
if isinstance(value, str): value = [value]
nvalue = value or ['']
items = [LI(INPUT(_id=_id, _class=_class, _name=_name,
value=v, hideerror=k < len(nvalue) - 1,
requires=requires),
**attributes) for (k, v) in enumerate(nvalue)]
attributes['_id'] = _id + '_grow_input'
attributes['_style'] = 'list-style:none'
attributes['_class'] = 'w2p_list'
return TAG[''](UL(*items, **attributes))
示例2: latex_from_html
# 需要导入模块: from gluon import html [as 别名]
# 或者: from gluon.html import TAG [as 别名]
def latex_from_html(html):
markmin = TAG(html).element('body').flatten(markmin_serializer)
return XML(markmin2latex(markmin))
示例3: pdflatex_from_html
# 需要导入模块: from gluon import html [as 别名]
# 或者: from gluon.html import TAG [as 别名]
def pdflatex_from_html(html):
if os.system('which pdflatex > /dev/null') == 0:
markmin = TAG(html).element('body').flatten(markmin_serializer)
out, warnings, errors = markmin2pdf(markmin)
if errors:
current.response.headers['Content-Type'] = 'text/html'
raise HTTP(405, HTML(BODY(H1('errors'),
UL(*errors),
H1('warnings'),
UL(*warnings))).xml())
else:
return XML(out)
示例4: __call__
# 需要导入模块: from gluon import html [as 别名]
# 或者: from gluon.html import TAG [as 别名]
def __call__(self, field, value, **attributes):
default = dict(
_type='text',
value=(not value is None and str(value)) or '',
)
attr = StringWidget._attributes(field, default, **attributes)
div_id = self.keyword + '_div'
attr['_autocomplete'] = 'off'
if self.is_reference:
key2 = self.keyword + '_aux'
key3 = self.keyword + '_auto'
attr['_class'] = 'string'
name = attr['_name']
if 'requires' in attr:
del attr['requires']
attr['_name'] = key2
value = attr['value']
record = self.db(
self.fields[1] == value).select(self.fields[0]).first()
attr['value'] = record and record[self.fields[0].name]
attr['_onblur'] = "jQuery('#%(div_id)s').delay(1000).fadeOut('slow');" % \
dict(div_id=div_id, u='F' + self.keyword)
attr['_onkeyup'] = "jQuery('#%(key3)s').val('');var e=event.which?event.which:event.keyCode; function %(u)s(){jQuery('#%(id)s').val(jQuery('#%(key)s :selected').text());jQuery('#%(key3)s').val(jQuery('#%(key)s').val())}; if(e==39) %(u)s(); else if(e==40) {if(jQuery('#%(key)s option:selected').next().length)jQuery('#%(key)s option:selected').attr('selected',null).next().attr('selected','selected'); %(u)s();} else if(e==38) {if(jQuery('#%(key)s option:selected').prev().length)jQuery('#%(key)s option:selected').attr('selected',null).prev().attr('selected','selected'); %(u)s();} else if(jQuery('#%(id)s').val().length>=%(min_length)s) jQuery.get('%(url)s?%(key)s='+encodeURIComponent(jQuery('#%(id)s').val()),function(data){if(data=='')jQuery('#%(key3)s').val('');else{jQuery('#%(id)s').next('.error').hide();jQuery('#%(div_id)s').html(data).show().focus();jQuery('#%(div_id)s select').css('width',jQuery('#%(id)s').css('width'));jQuery('#%(key3)s').val(jQuery('#%(key)s').val());jQuery('#%(key)s').change(%(u)s);jQuery('#%(key)s').click(%(u)s);};}); else jQuery('#%(div_id)s').fadeOut('slow');" % \
dict(url=self.url, min_length=self.min_length,
key=self.keyword, id=attr['_id'], key2=key2, key3=key3,
name=name, div_id=div_id, u='F' + self.keyword)
if self.min_length == 0:
attr['_onfocus'] = attr['_onkeyup']
return TAG[''](INPUT(**attr), INPUT(_type='hidden', _id=key3, _value=value,
_name=name, requires=field.requires),
DIV(_id=div_id, _style='position:absolute;'))
else:
attr['_name'] = field.name
attr['_onblur'] = "jQuery('#%(div_id)s').delay(1000).fadeOut('slow');" % \
dict(div_id=div_id, u='F' + self.keyword)
attr['_onkeyup'] = "var e=event.which?event.which:event.keyCode; function %(u)s(){jQuery('#%(id)s').val(jQuery('#%(key)s').val())}; if(e==39) %(u)s(); else if(e==40) {if(jQuery('#%(key)s option:selected').next().length)jQuery('#%(key)s option:selected').attr('selected',null).next().attr('selected','selected'); %(u)s();} else if(e==38) {if(jQuery('#%(key)s option:selected').prev().length)jQuery('#%(key)s option:selected').attr('selected',null).prev().attr('selected','selected'); %(u)s();} else if(jQuery('#%(id)s').val().length>=%(min_length)s) jQuery.get('%(url)s?%(key)s='+encodeURIComponent(jQuery('#%(id)s').val()),function(data){jQuery('#%(id)s').next('.error').hide();jQuery('#%(div_id)s').html(data).show().focus();jQuery('#%(div_id)s select').css('width',jQuery('#%(id)s').css('width'));jQuery('#%(key)s').change(%(u)s);jQuery('#%(key)s').click(%(u)s);}); else jQuery('#%(div_id)s').fadeOut('slow');" % \
dict(url=self.url, min_length=self.min_length,
key=self.keyword, id=attr['_id'], div_id=div_id, u='F' + self.keyword)
if self.min_length == 0:
attr['_onfocus'] = attr['_onkeyup']
return TAG[''](INPUT(**attr), DIV(_id=div_id, _style='position:absolute;'))