本文整理汇总了Python中pyasm.common.Date.add_style方法的典型用法代码示例。如果您正苦于以下问题:Python Date.add_style方法的具体用法?Python Date.add_style怎么用?Python Date.add_style使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyasm.common.Date
的用法示例。
在下文中一共展示了Date.add_style方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_display
# 需要导入模块: from pyasm.common import Date [as 别名]
# 或者: from pyasm.common.Date import add_style [as 别名]
def get_display(my):
value = my.get_value()
name = my.get_name()
type = my.get_option("type")
if not type:
type = my.get_type()
# FIXME: this needs to be handled outside of this class to centralize
# the type of an element!!!
if type in ["timestamp"]:
# make a guess here
if name.endswith('time'):
type = 'time'
elif name.endswith('date'):
type = 'date'
if type == "text":
wiki = WikiUtil()
display = wiki.convert(value)
elif type in ["time"]:
if value:
display = Date(value).get_display_time()
else:
display = ''
elif type in ["datetime"]:
if value:
display = Date(value).get_display_datetime()
else:
display = ''
elif type in ["timestamp", 'date']:
if value == '{now}':
display = Date()
elif value:
display = Date(value).get_display_date()
else:
display = ''
elif type == "timecode":
display = "00:00:00:00"
elif type == "currency":
display = "$%s" % value
elif type == "color":
display = DivWdg()
color = DivWdg(" ")
color.add_style("height: 15px")
color.add_style("width: 15px")
color.add_style("float: left")
color.add_style("margin: 0 5px 0 5px")
color.add_style("background: %s" % value)
display.add(color)
display.add(value)
display.add_style("width: 100%")
display.add_style("height: 100%")
elif type == "boolean":
display = DivWdg()
display.add_style("text-align: center")
display.add_style("width: 100%")
display.add_style("height: 100%")
if value == True:
from pyasm.widget import IconWdg
icon = IconWdg("True", IconWdg.CHECK)
display.add(icon)
elif value == False:
from pyasm.widget import IconWdg
icon = IconWdg("False", IconWdg.INVALID)
display.add(icon)
else:
display.add(" ")
else:
if not isinstance(value, basestring):
display = DivWdg()
display.add_style("float: right")
display.add_style("padding-right: 3px")
display.add(str(value))
else:
display = value
return display