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


Python IconButtonWdg.add_class方法代码示例

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


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

示例1: get_display

# 需要导入模块: from tactic.ui.widget import IconButtonWdg [as 别名]
# 或者: from tactic.ui.widget.IconButtonWdg import add_class [as 别名]
    def get_display(my):

        top = my.top
        top.add_class("spt_switcher_top")
        
        '''
        This supports supports two menu definitions:
        menu - specifies a view for SideBarWdg which will be ingected as menu 
        config_xml - specifies menu entries. For example:

        <display class="tactic.ui.widget.LayoutSwitcherWdg">
          <!-- config_xml -->
          <config>
            <!-- Menu item 1 -->
            <element name="my_tasks_default" title="My Tasks">
              <display class="tactic.ui.panel.ViewPanelWdg">
                <search_type>sthpw/task</search_type>
                <show_shelf>false</show_shelf>
                <view>my_tasks_default</view>
                <target>spt_my_tasks_table_top</target>
              </display>
            </element>
            <!-- Menu item 2 -->
            <element ... >
              <display ... >
                <target ... />
              </display>
            </element>
          </config>
        </display>

        target - specifies target div to load views when using "menu" kwarg
        use_href - updates address bar hash (this is TODO)
        '''
        
        menu = my.kwargs.get("menu")
        config_xml = my.kwargs.get("config_xml")
        target = my.kwargs.get("target")
        # TODO: use_href to go to specific layout switcher view
        # use_href = my.kwrags.get("use_href")
        
        # Layout switcher button displays menu and assumes right hand position of screen
        activator = IconButtonWdg( name="Layout Switcher", icon="BS_TH_LIST")
        top.add(activator)
        activator.add_class("spt_switcher_activator")
        activator.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
            var activator = bvr.src_el;
            var top = activator.getParent(".spt_switcher_top");
            var menu = top.getElement(".spt_switcher_menu");
            
            if (top.hasClass("spt_selected")) {
                top.removeClass("spt_selected");
                menu.setStyle("display", "none");    
            } else {
                top.addClass("spt_selected");
                menu.setStyle("display", "");
                var pos = activator.getPosition();
                var button_size = activator.getSize();
                var menu_size = menu.getSize();
                var offset = {
                    x: button_size.x - menu_size.x,
                    y: button_size.y
                }
                menu.position({position: 'upperleft', relativeTo: activator, offset: offset});

                var pointer = menu.getElement(".spt_popup_pointer");
                pointer.setStyle("margin-left", menu_size.x - button_size.x);
            } 
            '''
        } )
            
        # menu_wdg 
        menu_wdg = DivWdg()
        top.add(menu_wdg)
        menu_wdg.add_class("spt_switcher_menu")
        menu_wdg.add_style("display: none")
        menu_wdg.add_style("margin-top", "15px")
        menu_wdg.add_style("position", "absolute")
        menu_wdg.add_style("z-index", "10")
        menu_wdg.add_behavior( {
            'type': 'mouseleave',
            'cbjs_action': '''
            var menu = bvr.src_el;
            var top = menu.getParent(".spt_switcher_top");
            top.removeClass("spt_selected");
            menu.setStyle("display", "none")
            '''
        } )
        
        # Pointer under activator
        pointer_wdg = DivWdg()
        menu_wdg.add(pointer_wdg)
        pointer_wdg.add('''
            <div class="spt_first_arrow_div"> </div>
            <div class="spt_second_arrow_div"> </div>
        ''')
        pointer_wdg.add_class("spt_popup_pointer")

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


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