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


Python Table.add_col方法代码示例

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


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

示例1: _get_target_span

# 需要导入模块: from pyasm.web import Table [as 别名]
# 或者: from pyasm.web.Table import add_col [as 别名]
 def _get_target_span(my):
     # get the target span
     search = Search(my.container_cls)
     my._order_search(search)
     groups = search.get_sobjects()
     if groups:
         my.container_sobj = groups[0]
     
     target_span = SpanWdg(css='med')
     group_table = Table(my.GROUP_TABLE_NAME, css='table')
     group_table.add_style('width','30em')
     group_table.add_col(css='small')
     group_table.add_col(css='small')    
     group_table.add_col()    
         
     target_span.add(group_table)
     group_table.add_row_cell(search.get_search_type_obj()\
         .get_description(), "heading")
     checkbox = CheckboxWdg()
     checkbox.set_option("onclick", \
         "a=new Elements('container_ids');a.toggle_all(this);")
     group_table.add_row()
     group_table.add_cell(checkbox)
     col_name = group_table.get_next_col_name() 
     
     toggle_control = HiddenRowToggleWdg(col_name=col_name, is_control=True, auto_index=True)
   
     group_table.add_cell(toggle_control)
     group_table.add_cell('MASTER CONTROL')
     
     remove_cmd = HiddenWdg(SObjectGroupCmd.REMOVE_CMD)
     my.add(remove_cmd)
     for group in groups:
         group_table.add_row()
         checkbox = CheckboxWdg("container_ids")
         checkbox.set_option("value", group.get_primary_key_value() )
         
         toggle = HiddenRowToggleWdg(col_name, auto_index=True)
         toggle.store_event()
      
         group_details = ItemInContainerWdg( group, my.item_sobj, my.item_cls, my.grouping_cls )
        
         # set the target content of the toggle
         toggle.set_static_content(group_details)
        
         group_table.add_cell( checkbox )
         group_table.add_cell( toggle, add_hidden_wdg=True )
         group_table.add_cell( group.get_description())
         num_items = group_details.get_num_items()
         if num_items:
             td = group_table.add_cell( "( %s )" % num_items, 'no_wrap')
             td.add_color(color)
         else:
             group_table.add_blank_cell()
    
     
     return target_span
开发者ID:0-T-0,项目名称:TACTIC,代码行数:59,代码来源:sobject_group_wdg.py

示例2: init

# 需要导入模块: from pyasm.web import Table [as 别名]
# 或者: from pyasm.web.Table import add_col [as 别名]
    def init(my):
        
 
        my.item_cls = my.kwargs.get('left_search_type')
        my.container_cls = my.kwargs.get('right_search_type')
        my.grouping_cls  = my.kwargs.get('search_type')

        my.item_sobj = my.container_sobj = None 
        
        # List the items
        search = Search(my.item_cls)
        my._order_search(search)    
        
        items = search.get_sobjects()
        if items:
            my.item_sobj = items[0]
        #select = MultiSelectWdg("item_ids")
        #select.set_search_for_options(search,"login", "get_full_name()")

        user_span = SpanWdg(css='med')
        
        user_table = Table(css='table')
        user_table.add_style("margin-left: 6px")
        user_table.set_max_width()
        user_table.add_col(css='small')
        user_table.add_col()
        
        user_table.add_style("min-width: 14em")
        user_table.add_row_cell(search.get_search_type_obj()\
            .get_description(), "heading")

        for item in items:
            user_table.add_row()
            checkbox = CheckboxWdg("item_ids")
            checkbox.set_option("value", item.get_primary_key_value() )
            user_table.add_cell( checkbox )

            project_code = item.get_value("project_code", no_exception=True)
            if project_code:
                user_table.add_cell( "[ %s ]" % project_code )
            else:
                user_table.add_cell( "[ * ]" )

            user_table.add_cell( item.get_description() )
        user_span.add(user_table)

        # control widget in the middle
        control_div = DivWdg()
        control_div.add_style('padding: 100px 10px 0 10px')

        button = IconSubmitWdg(my.ADD_LABEL, "stock_insert-slide.png", True)
        button.add_style('padding: 2px 30px 4px 30px')
        control_div.add(button)
        
        
        main_table = Table(css='collapse')
        main_table.set_max_width()
        main_table.add_row(css='plain_bg')
        main_table.add_cell(user_span, 'valign_top')
        td = main_table.add_cell(control_div, 'valign_top')
        td.add_style('width','12em')
        main_table.add_cell(my._get_target_span(), 'valign_top')

        my.add(main_table)
    
        # register command here
        if my.item_sobj and my.container_sobj:
            marshaller = WebContainer.register_cmd("pyasm.widget.SObjectGroupCmd")
            marshaller.set_option("grouping_search_type", my.grouping_cls)
            marshaller.set_option("item_foreign_key", my.item_sobj.get_foreign_key())
            marshaller.set_option("container_foreign_key", my.container_sobj.get_foreign_key())
开发者ID:0-T-0,项目名称:TACTIC,代码行数:73,代码来源:sobject_group_wdg.py

示例3: get_display

# 需要导入模块: from pyasm.web import Table [as 别名]
# 或者: from pyasm.web.Table import add_col [as 别名]
    def get_display(my): 

        top = my.top
        top.add_color("background", "background")
        top.add_color("color", "color")
        top.add_style("padding: 10px")
        top.add_style("min-width: 400px")

        from tactic.ui.app import HelpButtonWdg
        help_wdg = HelpButtonWdg(alias="exporting-csv-data")
        top.add(help_wdg)
        help_wdg.add_style("float: right")
        help_wdg.add_style("margin-top: -3px")
        
        if not my.check(): 
            top.add(DivWdg('Error: %s' %my.error_msg))
            top.add(HtmlElement.br(2))
            return super(CsvExportWdg, my).get_display()

        if my.search_type_list and my.search_type_list[0] != my.search_type:
            st = SearchType.get(my.search_type_list[0])
            title_div =DivWdg('Exporting related items [%s]' % st.get_title())
            top.add(title_div)
            top.add(HtmlElement.br())
            my.search_type = my.search_type_list[0]
            my.view = my.related_view

        if my.mode != 'export_all':
            num = len(my.selected_search_keys)
        else:
            search = Search(my.search_type)
            num = search.get_count()
        msg_div = DivWdg('Total: %s items to export'% num)
        msg_div.add_style("font-size: 12px")
        msg_div.add_style("font-weight: bold")
        msg_div.add_style('margin-left: 4px')
        top.add(msg_div)
        if num > 300:
            msg_div.add_behavior({'type':'load',
            'cbjs_action': "spt.alert('%s items are about to be exported. It may take a while.')" %num})
                
        top.add(HtmlElement.br())

        div  = DivWdg(css='spt_csv_export', id='csv_export_action')
        div.add_color("background", "background", -10)
        div.add_style("padding: 10px")
        div.add_style("margin: 5px")
        
        div.add_styles('max-height: 350px; overflow: auto')
        table = Table( css='minimal')
        table.add_color("color", "color")
        div.add(table)
        table.set_id('csv_export_table')
        table.center()
        
        
        cb_name = 'csv_column_name'
        master_cb = CheckboxWdg('master_control')
        master_cb.set_checked()
        master_cb.add_behavior({'type': 'click_up',
            'propagate_evt': True,
            'cbjs_action': '''
                var inputs = spt.api.Utility.get_inputs(bvr.src_el.getParent('.spt_csv_export'),'%s');
                for (var i = 0; i < inputs.length; i++)
                    inputs[i].checked = !inputs[i].checked;
                    ''' %cb_name})


        span = SpanWdg('Select Columns To Export')
        span.add_style('font-weight','600')
        table.add_row_cell(span)
        table.add_row_cell(HtmlElement.br())

        tr = table.add_row()
        tr.add_style('border-bottom: 1px groove #777')
        td = table.add_cell(master_cb)
        label = HtmlElement.i('toggle all')
        label.add_style('color: #888')
        table.add_cell(label)


        col1 = table.add_col()
        col1.add_style('width: 35px')
        col2 = table.add_col()
        
        if not my.search_type or not my.view:
            return table

        
        # use overriding element names and derived titles if available
        config = WidgetConfigView.get_by_search_type(my.search_type, my.view)
        if my.element_names and config:
            filtered_columns = my.element_names
            titles = []
            for name in my.element_names:
                title = config.get_element_title(name)
                titles.append(title)

        else:
            
#.........这里部分代码省略.........
开发者ID:davidsouthpaw,项目名称:TACTIC,代码行数:103,代码来源:data_export_wdg.py

示例4: get_upload_wdg

# 需要导入模块: from pyasm.web import Table [as 别名]
# 或者: from pyasm.web.Table import add_col [as 别名]
    def get_upload_wdg(my):
        '''get search type select and upload wdg'''
        widget = DivWdg(css='spt_import_csv')
        widget.add_color('color','color')
        widget.add_color('background','background')
        widget.add_style('width: 600px')

        # get the search type
        title = DivWdg("<b>Select sType to import data into:</b>&nbsp;&nbsp;")
        widget.add( title )
        title.add_style("float: left")

        # handle new search_types
        new_search_type = CheckboxWdg("new_search_type_checkbox")
        new_search_type.add_event("onclick", "toggle_display('new_search_type_div')")
        #span = SpanWdg(css="med")
        #span.add(new_search_type)
        #span.add("Create new type")
        #span.add(" ... or ... ")
        #widget.add(span)

        new_search_type_div = DivWdg()
        new_search_type_div.set_id("new_search_type_div")

        name_input = TextWdg("asset_name")
        title = TextWdg("asset_title")
        description = TextAreaWdg("asset_description")

        
 
        key='csv_import'
        table = Table()
        table.set_id('csv_main_body')
        table.add_style("margin: 10px 10px")
        table.add_col().set_attr('width','140')
        table.add_col().set_attr('width','400')
        
        table.add_row()
        table.add_header("Search Type: ").set_attr('align','left')
        table.add_cell(name_input)
        table.add_row()
        table.add_header("Title: ").set_attr('align','left')
        table.add_cell(title)
        table.add_row()
        table.add_header("Description: ").set_attr('align','left')
        table.add_cell(description)
        new_search_type_div.add(table)
        new_search_type_div.add_style("display: none")
        #widget.add(new_search_type_div)

        div = DivWdg()

       
        search_type_select = SearchTypeSelectWdg("search_type_filter", mode=SearchTypeSelectWdg.ALL)
        search_type_select.add_empty_option("-- Select --")
        if not search_type_select.get_value():
            search_type_select.set_value(my.search_type)
        search_type_select.set_persist_on_submit()
       

        div.add(search_type_select)

        widget.add(div)

        search_type_select.add_behavior( {'type': 'change', \
                                  'cbjs_action': "spt.panel.load('csv_import_main','%s', {}, {\
                                    'search_type_filter': bvr.src_el.value});" %(Common.get_full_class_name(my)) } )

        if my.search_type:
            sobj = None
            try:
                sobj = SObjectFactory.create(my.search_type)
            except ImportError:
                widget.add(HtmlElement.br())
                widget.add(SpanWdg('WARNING: Import Error encountered. Please choose another search type.', css='warning')) 
                return widget

            required_columns = sobj.get_required_columns()
           
            if required_columns:
                widget.add(HtmlElement.br())
                req_span = SpanWdg("Required Columns: ", css='med')
                req_span.add_color('color','color')
                widget.add(req_span)
                #required_columns = ['n/a']
                req_span.add(', '.join(required_columns))

            widget.add( HtmlElement.br() )



            if my.file_path:
                hidden = HiddenWdg("file_path", my.file_path)
                widget.add(hidden)
                
                if my.web_url:
                    file_span = FloatDivWdg('URL: <i>%s</i>&nbsp;&nbsp;&nbsp;' %my.web_url, css='med')
                else:
                    file_span = FloatDivWdg('File uploaded: <i>%s</i>&nbsp;&nbsp;&nbsp;' %os.path.basename(my.file_path), css='med')
                file_span.add_color('color','color')
#.........这里部分代码省略.........
开发者ID:davidsouthpaw,项目名称:TACTIC,代码行数:103,代码来源:data_export_wdg.py

示例5: get_display

# 需要导入模块: from pyasm.web import Table [as 别名]
# 或者: from pyasm.web.Table import add_col [as 别名]
    def get_display(my):
        div = DivWdg()

        sobject = my.get_sobject_from_kwargs()
        if not sobject:
            div.add("SObject not found")
            return div

        search_type_obj = sobject.get_search_type_obj()
        title = search_type_obj.get_title()
        title_wdg = DivWdg()
        title_wdg.add_style("font-size: 1.8em")
        title_wdg.add("%s: %s" % (title, sobject.get_code() ) )

        div.add(title_wdg)
        div.add(HtmlElement.hr())


        table = Table()
        table.set_max_width()

        col1 = table.add_col()
        col1.add_style('width: 200px')
        col2 = table.add_col()
        col2.add_style('width: 320px')
        col3 = table.add_col()
        col3.add_style('width: 400px')
        table.add_row()

        from pyasm.widget import ThumbWdg, DiscussionWdg, SObjectTaskTableElement

        td = table.add_cell()
        td.add_style("vertical-align: top")
        td.add_style("border-right: solid 1px")
        title = DivWdg()
        title.add_class("maq_search_bar")
        #x = DivWdg("[?] [x]")
        #x.add_style("float: right")
        #title.add(x)
        title.add("Info")
        td.add(title)
        thumb = ThumbWdg()
        thumb.set_sobject(sobject)
        thumb.set_option("detail", "false")
        td.add(thumb)
        from pyasm.prod.web import AssetInfoWdg
        info = AssetInfoWdg()
        info.thumb = thumb
        info.set_sobject(sobject)
        td.add(info)

        # tasks
        td = table.add_cell()
        td.add_style("vertical-align: top")
        td.add_style("padding-left: 5px")
        td.add_style("border-right: solid 1px")
        title = DivWdg()
        title.add_class("maq_search_bar")
        #x = DivWdg("[x]")
        #x.add_style("float: right")
        #title.add(x)
        title.add("Tasks")
        td.add(title)
        task_wdg = SObjectTaskTableElement()
        task_wdg.set_sobject(sobject)
        td.add(task_wdg)
        td.add_style('cell-padding','10')


        # discussion
        td = table.add_cell()
        #td.add_style("min-width: 300px")
        #td.add_style("width: 600px")
        td.add_style("vertical-align: top")
        td.add_style("padding-left: 5px")
        td.add_style("border-right: solid 1px")
       
        title = DivWdg()
        title.add_class("maq_search_bar")
        #x = DivWdg("[x]")
        #x.add_style("float: right")
        #title.add(x)
        title.add("Notes")
        td.add(title)
        discussion_wdg = DiscussionWdg()
        discussion_wdg.preprocess()
        discussion_wdg.set_sobject(sobject)
        td.add(discussion_wdg)
        note_panel = discussion_wdg.get_note_menu()
        td.add(note_panel)

        div.add(table)
       

        div.add(HtmlElement.hr())
        div.add(HtmlElement.br(clear="all"))

        title_wdg = DivWdg()
        title_wdg.add_class("maq_search_bar")
        #x = DivWdg("[x]")
#.........这里部分代码省略.........
开发者ID:0-T-0,项目名称:TACTIC,代码行数:103,代码来源:sobject_panel_wdg.py

示例6: get_upload_wdg

# 需要导入模块: from pyasm.web import Table [as 别名]
# 或者: from pyasm.web.Table import add_col [as 别名]
    def get_upload_wdg(my):
        widget = Widget()

        # get the search type
        widget.add( "1. Select type of asset: ")

        # handle new search_types
        new_search_type = CheckboxWdg("new_search_type_checkbox")
        new_search_type.add_event("onclick", "toggle_display('new_search_type_div')")
        #span = SpanWdg(css="med")
        #span.add(new_search_type)
        #span.add("Create new type")
        #span.add(" ... or ... ")
        #widget.add(span)

        new_search_type_div = DivWdg()
        new_search_type_div.set_id("new_search_type_div")

        name_input = TextWdg("asset_name")
        title = TextWdg("asset_title")
        description = TextAreaWdg("asset_description")

        table = Table()
        table.add_style("margin: 10px 20px")
        table.add_col().set_attr('width','140')
        table.add_col().set_attr('width','400')
        
        table.add_row()
        table.add_header("Search Type: ").set_attr('align','left')
        table.add_cell(name_input)
        table.add_row()
        table.add_header("Title: ").set_attr('align','left')
        table.add_cell(title)
        table.add_row()
        table.add_header("Description: ").set_attr('align','left')
        table.add_cell(description)
        new_search_type_div.add(table)
        new_search_type_div.add_style("display: none")
        #widget.add(new_search_type_div)


        # or use a pre-existing one
        search_type_select = SearchTypeSelectWdg("filter|search_type")
        search_type_select.add_empty_option("-- Select --")
        search_type_select.set_persist_on_submit()
        search_type_select.set_submit_onchange()
        widget.add(search_type_select)
        

        my.search_type = search_type_select.get_value()
        if my.search_type:
            sobj = SObjectFactory.create(my.search_type)
            required_columns = sobj.get_required_columns()
            
            widget.add(SpanWdg("Required Columns: ", css='med'))
            if not required_columns:
                required_columns = ['n/a']
            widget.add(SpanWdg(', '.join(required_columns), css='med'))

        widget.add( HtmlElement.br(2) )
        widget.add( "2. Upload a csv file: ")
        upload_wdg = HtmlElement.upload("uploaded_file")
        widget.add(upload_wdg)
        submit = IconSubmitWdg("Upload", IconWdg.UPLOAD, True)
        widget.add(submit)

        web = WebContainer.get_web()
        field_storage = web.get_form_value("uploaded_file")
        if field_storage != "":
            upload = FileUpload()
            upload.set_field_storage(field_storage)
            upload.set_create_icon(False)
            upload.execute()

            files = upload.get_files()
            if files:
                my.file_path = files[0]
            else:
                my.file_path = web.get_form_value("file_path")


        if my.file_path:
            hidden = HiddenWdg("file_path", my.file_path)
            widget.add(hidden)

        return widget
开发者ID:0-T-0,项目名称:TACTIC,代码行数:88,代码来源:csv_import_wdg.py


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