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


Python HtmlElement.add_styles方法代码示例

本文整理汇总了Python中pyasm.web.HtmlElement.add_styles方法的典型用法代码示例。如果您正苦于以下问题:Python HtmlElement.add_styles方法的具体用法?Python HtmlElement.add_styles怎么用?Python HtmlElement.add_styles使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyasm.web.HtmlElement的用法示例。


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

示例1: get_display

# 需要导入模块: from pyasm.web import HtmlElement [as 别名]
# 或者: from pyasm.web.HtmlElement import add_styles [as 别名]
    def get_display(my):
        
        # my.sobjects is preferred, otherwise use
        # search_key.
        search_key = my.kwargs.get('search_key')
        if not my.sobjects and search_key:
            message = Search.get_by_search_key(search_key)
        elif my.sobjects:
            message = my.sobjects[0]
        
        if message.get_search_type() == 'sthpw/message':
            message_code = message.get_value("code")
        else:
            message_code = message.get_value("message_code")

        category = message.get_value("category")
        table = Table()
        table.add_row()
        td = table.add_cell()

        subscription = my.kwargs.get('subscription')
        show_preview = my.kwargs.get('show_preview')
        if show_preview in ['',None]:
            show_preview = True
        show_preview_category_list = ['sobject','chat']

        if (category in show_preview_category_list and show_preview not in ['False','false',False]) or show_preview in ["True" ,"true",True]:  
            td.add( my.get_preview_wdg(subscription, category=category, message_code=message_code ))
    
        message_value = message.get_value("message")
        message_login = message.get_value("login")

        #TODO: implement short_format even for closing html tags properly while truncating 
        short_format = my.kwargs.get('short_format') in  ['true', True]
        if message_value.startswith('{') and message_value.endswith('}'):

            #message_value = message_value.replace(r"\\", "\\");
            message_value = jsonloads(message_value)
            # that doesn't support delete
            
            if category == "sobject":
                update_data = message_value.get("update_data")
                sobject_data = message_value.get("sobject")
                sobject_code = sobject_data.get('code')
                search_type = message_value.get("search_type")
                if search_type == "sthpw/note":
                    description = "<b>Note added:</b><br/>%s" % update_data.get("note")
                elif search_type == "sthpw/task":
                    description = "<b>Task modified:</b><br/>%s" % update_data.get("process")
                elif search_type == "sthpw/snapshot":
                    sobject = message_value.get("sobject")
                    description = "<b>Files checked in:</b><br/>%s" % sobject.get("process")
                else:
                    display = []
                    if update_data:
                        for key, val in update_data.items():
                            display.append('%s &ndash; %s'%(key, val))
                    else:
                        if message_value.get('mode') == 'retire':
                            display.append('Retired')

                    base_search_type = Project.extract_base_search_type(search_type)
                    
                    description = DivWdg()
                    title = DivWdg("<b>%s</b> - %s modified by %s:"%(base_search_type, sobject_code, message_login))
                    title.add_style('margin-bottom: 6px')
                    content = DivWdg()
                    content.add_style('padding-left: 2px')
                    content.add('<br>'.join(display))
                    description.add(title)
                    description.add(content)

            elif category == 'progress':
                description = DivWdg()
                message = message_value.get('message')
                message_div = DivWdg()
                message_div.add(message)
                description.add(message_div)

                percent = message_value.get('progress')
                if not percent:
                    percent = 0.0
                progress = HtmlElement('progress')
                progress.add_attr('value', percent)
                progress.add_attr('max', '100')
                progress.add_styles('''width: 280px; border-radius: 8px; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.75) inset''')
                
                progress_size = my.kwargs.get("progress_size")
                if progress_size == "large":
                    progress.add_styles("height: 16px; margin-top: 9px;")
                else:
                    progress.add_styles("height: 5px; margin-top: 4px;")

                description.add(progress)


            else:
                message = message_value.get('message')
                if message:
                    description = message
#.........这里部分代码省略.........
开发者ID:0-T-0,项目名称:TACTIC,代码行数:103,代码来源:message_wdg.py


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