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


Python Table.add_behavior方法代码示例

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


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

示例1: get_display

# 需要导入模块: from pyasm.web import Table [as 别名]
# 或者: from pyasm.web.Table import add_behavior [as 别名]
 def get_display(my):   
     from tactic.ui.widget import SObjectCheckinHistoryWdg
     from pyasm.web import DivWdg, HtmlElement, Table, Html, Widget
     new_number = 0
     if 'number' in my.kwargs.keys():
         new_number = int(my.kwargs.get('number'))
     table = Table()
     table.add_behavior(my.get_updater_behavior())
     table.add_style('width: 100%s;' % '%')
     table.add_row()
     mr_cell = table.add_cell('Inbox (%s)' % new_number)
     mr_cell.add_attr('class','inbox_counter')
     #mr_cell.add_behavior(my.get_updater_behavior())
     return table
开发者ID:2gDigitalPost,项目名称:custom,代码行数:16,代码来源:inbox_wdg.py

示例2: get_display

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

        top = self.top
        self.set_as_panel(top)
        top.add_class("spt_ingestion_top")
        top.add_color("background", "background", -5)

        self.data = {}

        rules_div = DivWdg()
        top.add(rules_div)
        rules_div.add_style("padding: 10px")

        rules_div.add("Rules: ")

        rules_select = SelectWdg("rule_code")
        rule_code = self.get_value('rule_code')
        if rule_code:
            rules_select.set_value(rule_code)
        rules_select.set_option("query", "config/ingest_rule|code|title")
        rules_select.add_empty_option("-- New --")
        rules_div.add(rules_select)
        rules_select.add_behavior( {
        'type': 'change',
        'cbjs_action': '''
        var top = bvr.src_el.getParent(".spt_ingestion_top");
        value = bvr.src_el.value;
        var class_name = 'tactic.ui.tools.IngestionToolWdg';
        spt.panel.load(top, class_name, {rule_code: value} );
        '''
        } )

        rules_div.add("<hr/>")

        # read from the database
        if rule_code:
            search = Search("config/ingest_rule")
            search.add_filter("code", rule_code)
            sobject = search.get_sobject()
        else:
            sobject = None
        if sobject:
            self.data = sobject.get_value("data")
            if self.data:
                self.data = jsonloads(self.data)

        session_code = self.kwargs.get("session_code")
        if session_code:
            session = Search.get_by_code("config/ingest_session", session_code)
        else:
            if sobject:
                session = sobject.get_related_sobject("config/ingest_session")
                print("sobject: ", sobject.get_code(), sobject.get_value("spt_ingest_session_code"))
                print("parent: ", session)
            else:
                session = None


        if not session:
            #session = SearchType.create("config/ingest_session")
            #session.set_value("code", "session101")
            #session.set_value("location", "local")
            ##session.set_value("base_dir", "C:")
            top.add("No session defined!!!")
            return top



        rule = ""
        filter = ""
        ignore = ""


        # get the base path
        if sobject:
            base_dir = sobject.get_value("base_dir")
        else:
            base_dir = ''

        #else:
        #    base_dir = self.get_value("base_dir")
        #if not base_dir:
        #    base_dir = ''

        if sobject:
            title = sobject.get_value("title")
        else:
            title = ''

        if sobject:
            code = sobject.get_value("code")
        else:
            code = ''


        file_list = self.get_value("file_list")
        scan_type = self.get_value("scan_type")
        action_type = self.get_value("action_type")
        rule = self.get_value("rule")
        if not rule:
#.........这里部分代码省略.........
开发者ID:mincau,项目名称:TACTIC,代码行数:103,代码来源:ingestion_wdg.py

示例3: get_example_display

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

        div = DivWdg()

        # Smart Menu data ...
        dog_menus = [ my.get_sm_dog_main_menu_details(),
                      my.get_sm_dog_submenu_one_details(),
                      my.get_sm_dog_submenu_two_details()
                    ]

        cat_menus = [ my.get_sm_cat_main_menu_details() ]

        SmartMenu.attach_smart_context_menu( div, { 'DOG': dog_menus, 'CAT': cat_menus }, False )



        table = Table(css="maq_view_table")
        table.set_id( "main_body_table" )
        table.add_class("spt_table")

        table.add_behavior( { "type": "smart_drag",
                              "bvr_match_class": "SPT_DO_RESIZE",
                              "cbjs_setup": 'spt.dg_table.resize_column_setup( evt, bvr, mouse_411 );',
                              "cbjs_motion": 'spt.dg_table.resize_column_motion( evt, bvr, mouse_411 );'
                             } )

        table.add_behavior( { "type": "smart_drag",
                              "bvr_match_class": "SPT_DO_DRAG",
                              "use_copy": 'true',
                              "use_delta": 'true', 'dx': 10, 'dy': 10,
                              "drop_code": 'TableExampleSwitchContents',
                              "cbjs_action": "spt.ui_play.drag_cell_drop_action( evt, bvr );",
                              "copy_styles": 'background: blue; opacity: .5; border: 1px solid black; text-align: left;'
                             } )

        row = table.add_row()
        for c in range(10):
            th = table.add_header()
            th.set_attr('col_idx', str(c))
            th.add_class("cell_left")
            th.add_styles("width: 150px; cursor: default;")

            # @@@
            th.add_behavior( {
                "type": "move",
                "cbjs_action": '''
                    // log.debug( "(x,y) = (" + mouse_411.curr_x + "," + mouse_411.curr_y + ")" );
                    spt.ui_play.header_half_move_cbk( evt, bvr, mouse_411 );
                ''',
                "cbjs_action_on": '''
                    // log.debug( "START MY MOVE!" );
                ''',
                "cbjs_action_off": '''
                    // log.debug( "DONE MY MOVE!" );
                    spt.ui_play.header_half_move_off_cbk( evt, bvr, mouse_411 );
                '''
            } )

            if (c%2):
                th.add("H%s (Cat)" % c)
            else:
                th.add("H%s (Dog)" % c)
            th_resize = table.add_cell()
            th_resize.set_attr('col_idx', str(c+1))
            th_resize.add_class("SPT_DO_RESIZE cell_right")
            th_resize.add_styles("width: 4px; cursor: col-resize;")

        for r in range(19):
            row = table.add_row()
            for c in range(10):
                col = table.add_cell()
                col.set_attr('col_idx', str(c))
                col.set_attr('SPT_ACCEPT_DROP', 'TableExampleSwitchContents')
                col.add_class("SPT_DO_DRAG cell_left")
                col.add_styles("cursor: pointer;")
                col.add("(%s,%s)" % (r,c))
                if (c % 2) == 0:
                    SmartMenu.assign_as_local_activator( col, "DOG" )
                else:
                    SmartMenu.assign_as_local_activator( col, "CAT" )
                resize = table.add_cell()
                resize.set_attr('col_idx', str(c+1))
                resize.add_class("SPT_DO_RESIZE cell_right")
                resize.add_styles("width: 6px; cursor: col-resize;")

        div.add( table )
        return div
开发者ID:0-T-0,项目名称:TACTIC,代码行数:89,代码来源:efficient_table_example_wdg.py

示例4: get_display

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

        my.sobject = my.get_sobject()

        top = DivWdg()
        top.add_class("spt_detail_top")
        top.add_color("background", "background")
        top.add_color("color", "color")

        if not my.sobject:
            top.add("No SObject defined for this widget")
            return top

        if my.parent:
            my.search_type = my.parent.get_base_search_type()
            my.search_key = SearchKey.get_by_sobject(my.parent)
            top.add_attr("spt_parent_key", my.search_key) 
            my.pipeline_code = my.parent.get_value("pipeline_code", no_exception=True)
            my.full_search_type = my.parent.get_search_type()
        else:
            my.pipeline_code = my.sobject.get_value("pipeline_code", no_exception=True)
            my.search_type = my.sobject.get_base_search_type()
            my.search_key = SearchKey.get_by_sobject(my.sobject)
            my.full_search_type = my.sobject.get_search_type()

        if not my.pipeline_code:
            my.pipeline_code = 'default'


        top.add_style("text-align: left")
        my.set_as_panel(top)

        table = Table()
        #from tactic.ui.container import ResizableTableWdg
        #table = ResizableTableWdg()
        table.add_color("background", "background")
        table.add_color("color", "color")
        top.add(table)
        table.set_max_width()

        # add the title
        tr, td = table.add_row_cell()

        title_wdg = my.get_title_wdg()
        td.add(title_wdg)


        table.add_row()

        # left
        td = table.add_cell()
        td.add_style("width: 300px")
        td.add_style("min-width: 300px")
        td.add_style("vertical-align: top")


        div = DivWdg()
        td.add(div)
        div.add_class("spt_sobject_detail_top")

        thumb_table = Table()
        div.add(thumb_table)
        thumb_table.add_row()

        from tactic.ui.panel import ThumbWdg2
        thumb = ThumbWdg2()
        # use a larger version for clearer display
        #thumb.set_icon_type('web')

        if my.parent:
            thumb.set_sobject(my.parent)
            search_key = my.parent.get_search_key()
        else:
            thumb.set_sobject(my.sobject)
            search_key = my.sobject.get_search_key()

        gallery_div = DivWdg()
        div.add( gallery_div )
        gallery_div.add_class("spt_tile_gallery")
 
        thumb_table.add_behavior( {
            'type': 'click_up',
            'search_key': search_key,
            'cbjs_action': '''
                var top = bvr.src_el.getParent(".spt_sobject_detail_top");
                var gallery_el = top.getElement(".spt_tile_gallery");

                var class_name = 'tactic.ui.widget.gallery_wdg.GalleryWdg';
                var kwargs = {
                    search_key: bvr.search_key,
                    search_keys: [bvr.search_key],
                };
                spt.panel.load(gallery_el, class_name, kwargs);
            ''' } )
 

        # prefer to see the original image, then web
        #thumb.set_option('image_link_order', 'main|web|icon')
        #thumb.set_option("detail", "false")
        #thumb.set_option("icon_size", "100%")
#.........这里部分代码省略.........
开发者ID:southpawtech,项目名称:TACTIC-DEV,代码行数:103,代码来源:sobject_wdg.py

示例5: ResizableTableWdg

# 需要导入模块: from pyasm.web import Table [as 别名]
# 或者: from pyasm.web.Table import add_behavior [as 别名]
class ResizableTableWdg(BaseRefreshWdg):
    def __init__(self, **kwargs):
        self.table = Table()
        self.table.add_style("border-collapse: collapse")
        self.table.add_style("padding: 0px")
        self.table.set_attr("cellpadding", "0px")
        self.table.set_attr("cellspacing", "0px")
        self.is_first_row = True
        self.hilight = self.table.get_color("background", -40)
        super(ResizableTableWdg, self).__init__(**kwargs)


    def set_style(self, name, value=None):
        self.table.set_style(name, value)

    def set_max_width(self):
        self.table.set_max_width()

    def add_class(self, name):
        self.table.add_class(name)

    def get_display(self):
        top = self.top

        self.table.add_class("spt_resizable_table_top")


        self.table.add_behavior( {
        'type': 'load',
        'cbjs_action': self.get_onload_js()
        } )


        self.table.add_behavior( {
        'type': 'load',
        'cbjs_action': '''
        var resizable_cells = bvr.src_el.getElements(".spt_resizable_cell");
        for (var i = 0; i < resizable_cells.length; i++) {
            var resizable_el = resizable_cells[i].getElement(".spt_resizable");
            if (!resizable_el) {
                continue;
            }

            var size = resizable_cells[i].getSize();

            resizable_el.setStyle("width", size.x);
            resizable_el.setAttribute("width", size.x);
        }
        '''
        } )


        top.add(self.table)

        return top


    def set_keep_table_size(self):
        self.table.add_class("spt_resizable_keep_size")


    def add_color(self, color, modifier=0):
        self.table.add_color(color, modifier)

    def add_border(self, modifier=0):
        self.table.add_border(modifier=modifier)

    def add_style(self, name, value=None):
        self.table.add_style(name, value=value)




    def add_row(self, resize=True):

        # add resize row
        if not self.is_first_row and resize == True:
            tr, td = self.table.add_row_cell()
            td.add_style("height: 3px")
            td.add_style("min-height: 3px")
            td.add_style("cursor: n-resize")

            tr.add_behavior( {
            'type': 'drag',
            'cb_set_prefix': 'spt.resizable_table.row_drag'
            } )

            tr.add_behavior( {
            'type': 'hover',
            'hilight': self.hilight,
            'cbjs_action_over': '''
            var color = bvr.src_el.getStyle("background-color");
            bvr.src_el.setStyle("background-color", bvr.hilight);
            bvr.src_el.setAttribute("spt_last_background", color);
            ''',
            'cbjs_action_out': '''
            var color = bvr.src_el.getAttribute("spt_last_background");
            bvr.src_el.setStyle("background-color", color);
            '''
            } )
#.........这里部分代码省略.........
开发者ID:mincau,项目名称:TACTIC,代码行数:103,代码来源:resizable_table_wdg.py

示例6: get_display

# 需要导入模块: from pyasm.web import Table [as 别名]
# 或者: from pyasm.web.Table import add_behavior [as 别名]
    def get_display(my):
        # specially made for "load" view
        if not my.view.endswith("load"):
            return DivWdg()



        widget = Widget()
        # first use
        filter_top = DivWdg(css="maq_search_bar")
        filter_top.add_color("background", "background2", -15)

        # so dg_table.search_cbk will obtain values from this widget
        filter_top.add_class('spt_table_search')
        filter_top.add_style("padding: 3px")

        # this is used by get_process() in LoaderWdg
        filter_top.add(HiddenWdg('prefix', 'view_action_option'))

        for name, value in my.kwargs.items():
            filter_top.set_attr("spt_%s" % name, value)


        from tactic.ui.cgapp import SObjectLoadWdg, LoaderButtonWdg, LoaderElementWdg, IntrospectWdg

        # this contains the process filter and load options
        sobject_load = SObjectLoadWdg(search_type=my.search_type, load_options_class = my.load_options_class)
        filter_top.add(sobject_load)

       

        # set the process
        #class foo:
        #    def get_value(my):
        #        return "texture"
        #Container.put("process_filter", foo())

        filter_top.add( HtmlElement.br() )

        table = Table()
        table.add_class('spt_action_wdg')

        table.set_max_width()
        td = table.add_cell()       
     
        # create the loader button
        button = LoaderButtonWdg()


        # -------------
        # test an event mechanism
        event_name = '%s|load_snapshot' % my.search_type
        #event_name = 'load_snapshot'

        # get triggers with this event
        from pyasm.search import Search
        search = Search("config/client_trigger")
        search.add_filter("event", event_name)
        triggers = search.get_sobjects()

        if triggers:
            for trigger in triggers:
                #callback = trigger.get_value("custom_script_code")
                callback = trigger.get_value("callback")

                event_script = '''
                spt.app_busy.show("Loading ...", "Loading selected [%s] in to session");
                var script = spt.CustomProject.get_script_by_path("%s");
                bvr['script'] = script;
                spt.CustomProject.exec_custom_script(evt, bvr);
                spt.app_busy.hide();
                ''' % (my.search_type, callback)

                loader_script = '''spt.named_events.fire_event('%s', {})''' % event_name
                table.add_behavior( {
                    'type': 'listen',
                    'event_name': event_name,
                    'cbjs_action': event_script
                } )

        # test a passed in script path
        elif my.load_script_path:

            # an event is called
            event_name = 'load_snapshot'
            event_script = '''var script = spt.CustomProject.get_script_by_path("%s");spt.CustomProject.exec_script(script)''' % my.load+script_path

            loader_script = '''spt.named_events.fire_event('%s', {})''' % event_name
            table.add_behavior( {
                'type': 'listen',
                'event_name': event_name,
                'cbjs_action': event_script
            } )

        # end test
        # ---------------



        elif my.load_script:
#.........这里部分代码省略.........
开发者ID:0-T-0,项目名称:TACTIC,代码行数:103,代码来源:loader_wdg.py

示例7: get_display

# 需要导入模块: from pyasm.web import Table [as 别名]
# 或者: from pyasm.web.Table import add_behavior [as 别名]

#.........这里部分代码省略.........
                 else:
                     expected_adder = expected_duration
                     actual_adder = actual_duration
                    
                 title_hours[title_code]['eq'][name]['actual']['hrs'] = title_hours[title_code]['eq'][name]['actual']['hrs'] + actual_adder
                 title_hours[title_code]['eq'][name]['actual']['cost'] = actual_cost + title_hours[title_code]['eq'][name]['actual']['cost']
                 order_hours['eq'][name]['actual']['hrs'] = order_hours['eq'][name]['actual']['hrs'] + actual_adder
                 order_hours['eq'][name]['actual']['cost'] = actual_cost + order_hours['eq'][name]['actual']['cost']
                 title_hours[title_code]['eq'][name]['estimated']['hrs'] = title_hours[title_code]['eq'][name]['estimated']['hrs'] + expected_adder
                 title_hours[title_code]['eq'][name]['estimated']['cost'] = expected_cost + title_hours[title_code]['eq'][name]['estimated']['cost']
                 order_hours['eq'][name]['estimated']['hrs'] = order_hours['eq'][name]['estimated']['hrs'] + expected_adder
                 order_hours['eq'][name]['estimated']['cost'] = expected_cost + order_hours['eq'][name]['estimated']['cost']
             eq['units'] = units
             eq['actual_duration'] = actual_duration 
             eq['actual_quantity'] = actual_quantity 
             eq['actual_cost'] = actual_cost
             eq['expected_duration'] = expected_duration 
             eq['expected_quantity'] = expected_quantity 
             eq['expected_cost'] = expected_cost
             title_hours[title_code]['eq'][name]['details'].append(eq)
             order_hours['eq'][name]['details'].append(eq)
     widget = DivWdg()
     table = Table()
     otbl = Table()
     otbl.add_attr('cellspacing','3')
     otbl.add_attr('cellpadding','3')
     #otbl.add_attr('bgcolor','#d9edf7')
     otbl.add_style('background-color: #d9edf7;')
     otbl.add_style('border-bottom-right-radius', '10px')
     otbl.add_style('border-bottom-left-radius', '10px')
     otbl.add_style('border-top-right-radius', '10px')
     otbl.add_style('border-top-left-radius', '10px')
     hide_unhide_bvr = my.get_hide_unhide(order.get('code'))
     otbl.add_behavior(hide_unhide_bvr)
     botbl = Table()
     botbl.add_attr('cellspacing','3')
     botbl.add_attr('cellpadding','3')
     botbl.add_row()
     bo1 = botbl.add_cell("<b>Name:</b> %s " % order.get('name'))
     bo1.add_attr('nowrap','nowrap')
     bo2 = botbl.add_cell('<b>Scheduler:</b> %s ' % order.get('login'))
     bo2.add_attr('nowrap','nowrap')
     botbl.add_cell('<b>Sales Rep:</b> %s ' % order.get('sales_rep'))
     bo2.add_attr('nowrap','nowrap')
     botbl.add_row()
     bo3 = botbl.add_cell('<b>Code:</b> %s ' % my.code)
     bo3.add_attr('nowrap','nowrap')
     bo4 = botbl.add_cell('<b>PO#:</b> %s ' % order.get('po_number'))
     bo4.add_attr('nowrap','nowrap')
     bo5 = botbl.add_cell('<b>Classification:</b> %s ' % order.get('classification'))
     bo5.add_attr('nowrap','nowrap')
     botbl.add_row()
     uploader = CustomHTML5UploadButtonWdg(sk=order.get('__search_key__'))
     liltbl = Table()
     liltbl.add_row()
     liltbl.add_cell(uploader)
     ob_button = OrderBuilderLauncherWdg(code=my.code)
     liltbl.add_cell(ob_button)
     bo6 = botbl.add_cell(liltbl)
     bo7 = botbl.add_cell('<b>Client:</b> %s ' % order.get('client_name'))
     bo7.add_attr('nowrap','nowrap')
     
     client_rep = order.get('client_rep')
     cr = my.server.eval("@SOBJECT(twog/person['code','%s'])" % client_rep)
     if cr:
         cr = cr[0]
开发者ID:2gDigitalPost,项目名称:custom,代码行数:70,代码来源:billing_wdg.py


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