• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python widget.WidgetConfigView类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pyasm.widget.WidgetConfigView的典型用法代码示例。如果您正苦于以下问题:Python WidgetConfigView类的具体用法?Python WidgetConfigView怎么用?Python WidgetConfigView使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: get_config

    def get_config(cls, search_type, view, default=None, personal=False):
        # personal doesn't mean much here since this is only for Project view definition
        """
        if view == "__column__":
            xml == '''
            <config>
                <element name="tttt" type="__database__"/>
                <element name="uuuu" type="__database__"/>
                <element name="vvvv" type="__database__"/>
            </config>
            '''
        """
        widget_config = None
        config_view = None
        widget_config_list = []

        # get all the configs relevant to this search_type
        configs = []

        from pyasm.widget import WidgetConfigView

        if view == "definition":
            if default:
                try:
                    default_config_view = WidgetConfigView.get_by_search_type(
                        search_type, view, use_cache=False, local_search=True
                    )

                    user_config_view = WidgetConfigView.get_by_search_type(search_type, view)

                    # merge the user config view from db into the default config view in xml file
                    default_config = default_config_view.get_definition_config()
                    user_config = user_config_view.get_definition_config()
                    if user_config:
                        user_element_names = user_config.get_element_names()
                        # make sure it's unique, there is a new validate function for
                        # WidgetDbConfig to ensure that also
                        user_element_names = Common.get_unique_list(user_element_names)
                        for elem in user_element_names:
                            user_node = user_config.get_element_node(elem)
                            default_config.append_xml_element(elem, node=user_node)
                except SqlException, e:
                    print "Search ERROR: ", e.__str__()
                    default_config = None

                if default_config:
                    default_config.get_xml().clear_xpath_cache()
                    widget_config_list = [default_config]

            else:
                config_view = WidgetConfigView.get_by_search_type(search_type, view, use_cache=True)
开发者ID:pombredanne,项目名称:TACTIC,代码行数:51,代码来源:search_type_manager_wdg.py


示例2: execute

    def execute(my):

        search_keys = my.kwargs.get("search_keys")
        if not search_keys:
            return

        element_name = my.kwargs.get("element_name")

        # get all of the sobjects
        sobjects = Search.get_by_search_keys(search_keys)
        if not sobjects:
            return

        from pyasm.widget import WidgetConfigView

        search_type = sobjects[0].get_base_search_type()
        view = "definition"

        config = WidgetConfigView.get_by_search_type(search_type, view)

        # TEST
        widget = config.get_display_widget(element_name)
        for sobject in sobjects:
            widget.set_sobject(sobject)
            value = widget.get_text_value()
            sobject.set_value(element_name, value)
            sobject.commit()
开发者ID:raidios,项目名称:TACTIC,代码行数:27,代码来源:expression_element_wdg.py


示例3: execute

    def execute(my):

        my.search_type = my.kwargs.get('search_type')
        my.element_name = my.kwargs.get('element_name')
        #print "Calculating aggregate: ", my.search_type, my.element_name

        my.view = my.kwargs.get('view')
        if not my.view:
            my.view = 'definition'

        config = WidgetConfigView.get_by_search_type(search_type=my.search_type, view=my.view)
        widget = config.get_display_widget(my.element_name)

        # calculate all of the values
        search = Search(my.search_type)
        sobjects = search.get_sobjects()
        widget.set_sobjects(sobjects)
        widget.kwargs['use_cache'] = "false"

        for i, sobject in enumerate(sobjects):
            widget.set_current_index(i)
            value = widget.get_text_value()

            print sobject.get_code(), "value [%s]: " %value

            # all cache columns need are named with a c_ preceeding it
            # s_status
            # c_element_name
            #
            # this_month -> c_this_month
            #column = "c_%s" % my.element_name
            #sobject.set_value(column, value)
            sobject.set_value(my.element_name, value)
            sobject.commit()
开发者ID:0-T-0,项目名称:TACTIC,代码行数:34,代码来源:aggregate_wdg.py


示例4: append

    def append(cls, search_type, view, name, class_name=None, display_options={}, element_attrs={}, config_xml=None, login=None):
        '''append an element with display class and options to the specified widget config'''
        assert view
        config_search_type = "config/widget_config"

        search = Search(config_search_type)
        search.add_filter("search_type", search_type)
        search.add_filter("view", view)
        search.add_filter("login", login)
        db_config = search.get_sobject()
        config_exists = True
        view_node = None
        if not db_config:
            db_config = SearchType.create(config_search_type)
            db_config.set_value("search_type", search_type )
            db_config.set_value("view", view )
            if login:
                db_config.set_value("login", login)

            config_exists = False

        # maintain the config variable here to mean WidgetConfig
        from pyasm.widget import WidgetConfigView
        if not config_exists and search_type not in ["SideBarWdg"]:
            config_view = WidgetConfigView.get_by_search_type(search_type, view)            
            #xml = config.get_xml()
            configs = config_view.get_configs()
            if configs:
                config = configs[0]
                view_node = config.get_view_node()
                config_exists = True
        
        if not config_exists:
            xml = db_config.get_xml_value("config", "config")
            db_config._init()
            root = xml.get_root_node()
            # build a new config
            view_node = xml.create_element(view)
            #root.appendChild(view_node)
            xml.append_child(root, view_node)
        else:   
            xml = db_config.get_xml_value("config", "config")
            root = xml.get_root_node()
            # it could be passed in thru a widget_config already
            if view_node is None:
                view_node = db_config.get_view_node()
            #root.appendChild(view_node)
            xml.append_child(root, view_node)

            db_config._init()

        if config_xml:
            db_config.append_xml_element( name, config_xml)
        else:
            db_config.append_display_element(name, class_name, options=display_options, element_attrs=element_attrs)
        db_config.commit_config()

        return db_config
开发者ID:mincau,项目名称:TACTIC,代码行数:58,代码来源:widget_db_config.py


示例5: get_config

    def get_config(my):
        # TEST
        config_xml = '''
        <config>
        <custom_filter>
          <element name='asset_library'>
            <display class='SelectWdg'>
                <query>prod/asset_library|code|code</query>
                <empty>true</empty>
            </display>
          </element>
          <element name='pipeline_code'>
            <display class='SelectWdg'>
                <query>sthpw/pipeline|code|code</query>
                <empty>true</empty>
            </display>
          </element>
        </custom_filter>
        </config>
        '''

        my.view = my.kwargs.get("search_view")
        if not my.view:
            my.view = 'custom_filter'
        #view = "custom_filter"
        project_code = Project.extract_project_code(my.search_type)
        search = Search("config/widget_config", project_code=project_code )
        search.add_filter("view", my.view)
        
       
        search.add_filter("search_type", my.base_search_type)
        config_sobj = search.get_sobject()
        if config_sobj:
            config_xml = config_sobj.get_value("config")
        
        else:
            config_xml = '''
            <config>
            <custom_filter>
            </custom_filter>
            </config>
            '''
            # use the one defined in the default config file
            file_configs = WidgetConfigView.get_configs_from_file(my.base_search_type, my.view)
            if file_configs:
                config = file_configs[0]
                xml_node = config.get_view_node()
                if xml_node is not None:
                    xml = Xml(config.get_xml().to_string())
                    config_xml = '<config>%s</config>' %xml.to_string(node=xml_node)

            


        from pyasm.widget import WidgetConfig
        config = WidgetConfig.get(view=my.view, xml=config_xml)

        return config
开发者ID:funic,项目名称:TACTIC,代码行数:58,代码来源:simple_search_wdg.py


示例6: get_config

    def get_config(self):


        self.view = self.kwargs.get("search_view")
        config = self.kwargs.get("search_config")

        if not self.view:
            self.view = 'custom_filter'
        #view = "custom_filter"

        project_code = Project.extract_project_code(self.search_type)

        search = Search("config/widget_config", project_code=project_code )
        search.add_filter("view", self.view)
        search.add_filter("search_type", self.base_search_type)
        config_sobjs = search.get_sobjects()

        from pyasm.search import WidgetDbConfig
        config_sobj = WidgetDbConfig.merge_configs(config_sobjs)

        if config_sobj:
            #config_xml = config_sobj.get("config")
            config_xml = config_sobj.get_xml().to_string()
            config_xml = config_xml.replace("&lt;", "<")
            config_xml = config_xml.replace("&gt;", ">")
            config_xml = Common.run_mako(config_xml)

        elif config:
            config_xml = '''
            <config>
            <custom_filter>%s
            </custom_filter>
            </config>
            ''' % config
        else:
            config_xml = '''
            <config>
            <custom_filter>
            </custom_filter>
            </config>
            '''
            # use the one defined in the default config file
            file_configs = WidgetConfigView.get_configs_from_file(self.base_search_type, self.view)
            if file_configs:
                config = file_configs[0]
                xml_node = config.get_view_node()
                if xml_node is not None:
                    xml = Xml(config.get_xml().to_string())
                    config_xml = '<config>%s</config>' %xml.to_string(node=xml_node)

            
        from pyasm.widget import WidgetConfig
        config = WidgetConfig.get(view=self.view, xml=config_xml)

        return config
开发者ID:mincau,项目名称:TACTIC,代码行数:55,代码来源:simple_search_wdg.py


示例7: get_info_wdg

    def get_info_wdg(my, sobject):

        div = DivWdg()
        div.add_style("margin: 10px 20px 20px 20px")
        div.add_style("padding: 20px")
        div.add_color("background", "background", -3)
        div.add_border()
        div.add_color("color", "color3")
        div.set_round_corners(5)

        div.add_style("height", "100%")
        div.add_style("position: relative")

        element_names = my.kwargs.get("element_names")
        if not element_names:
            element_names = ["code","name","description",]
        else:
            element_names = element_names.split(",")


        view = "table"

        from pyasm.widget import WidgetConfigView
        search_type = sobject.get_search_type()
        config = WidgetConfigView.get_by_search_type(search_type, view)


        table = Table()
        table.add_style("height", "100%")
        div.add(table)
        for element_name in element_names:
            table.add_row()
            title = Common.get_display_title(element_name)
            td = table.add_cell("%s: " % title)
            td.add_style("width: 200px")
            td.add_style("padding: 5px")


            element = config.get_display_widget(element_name)
            element.set_sobject(sobject)
            element.preprocess()
            td = table.add_cell(element)
            td.add_style("padding: 5px")
            #value = sobject.get_value(element_name, no_exception=True) or "N/A"
            #table.add_cell(value)

        div.add("<br/>")
        from tactic.ui.widget import DiscussionWdg
        search_key = sobject.get_search_key()
        notes_wdg = DiscussionWdg(search_key=search_key)
        notes_wdg.set_sobject(sobject)
        div.add(notes_wdg)

        return div
开发者ID:nuxping,项目名称:TACTIC,代码行数:54,代码来源:tool_layout_wdg.py


示例8: init_color_map

    def init_color_map(my):
        ''' initialize the color map for bg color and text color'''
        search_type = my.kwargs.get('search_type')
        
        if not search_type:
            search_type = 'sthpw/task'

        # get the color map
        from pyasm.widget import WidgetConfigView
        color_config = WidgetConfigView.get_by_search_type(search_type, "color")
        color_xml = color_config.configs[0].xml
        my.color_map = {}
        name = 'status'
        xpath = "config/color/element[@name='%s']/colors" % name
        text_xpath = "config/color/element[@name='%s']/text_colors" % name
        bg_color_node = color_xml.get_node(xpath)
        bg_color_map = color_xml.get_node_values_of_children(bg_color_node)

        text_color_node = color_xml.get_node(text_xpath)
        text_color_map = color_xml.get_node_values_of_children(text_color_node)
        
        # use old weird query language
        query = bg_color_map.get("query")
        query2 = bg_color_map.get("query2")
        if query:
            bg_color_map = {}

            search_type, match_col, color_col = query.split("|")
            search = Search(search_type)
            sobjects = search.get_sobjects()

            # match to a second table
            if query2:
                search_type2, match_col2, color_col2 = query2.split("|")
                search2 = Search(search_type2)
                sobjects2 = search2.get_sobjects()
            else:
                sobjects2 = []

            for sobject in sobjects:
                match = sobject.get_value(match_col)
                color_id = sobject.get_value(color_col)

                for sobject2 in sobjects2:
                    if sobject2.get_value(match_col2) == color_id:
                        color = sobject2.get_value(color_col2)
                        break
                else:
                    color = color_id


                bg_color_map[match] = color

        my.color_map[name] = bg_color_map, text_color_map
开发者ID:0-T-0,项目名称:TACTIC,代码行数:54,代码来源:sobject_calendar_wdg.py


示例9: preprocess

 def preprocess(my):
     sobject = my.get_current_sobject() 
     if not sobject:
         my.columns = []
         return 
     search_type = sobject.get_search_type_obj()
     config = WidgetConfigView.get_by_search_type(search_type, "custom")
     if not config:
         my.columns = []
     else:
         my.columns = config.get_element_names()
开发者ID:0-T-0,项目名称:TACTIC,代码行数:11,代码来源:custom_info_wdg.py


示例10: get_hint_text

 def get_hint_text(cls, search_type, simple_search_view=''):
     '''Get the hint text for keyword search col defined from widget_config'''
     if simple_search_view:
         from pyasm.widget import WidgetConfigView
         config = WidgetConfigView.get_by_search_type(search_type, simple_search_view)
         # assume the keyword filter is named "keyword"
         options = config.get_display_options('keyword')
         hint_text = options.get('hint_text')
         if hint_text:
             return hint_text
     
     return ""
开发者ID:mincau,项目名称:TACTIC,代码行数:12,代码来源:simple_search_wdg.py


示例11: get_config

    def get_config(my):
        # look in the db first
        configs = []
        config = WidgetDbConfig.get_by_search_type(my.search_type, my.view)
        get_edit_def = False
        if config:
            configs.append(config)
            get_edit_def = True
            config = WidgetDbConfig.get_by_search_type(my.search_type, "edit_definition")
            if config:
                configs.append(config)

        #if my.mode == 'insert':
        #    config = WidgetDbConfig.get_by_search_type(my.search_type, "insert")
        #    if config:
        #        configs.append(config)
        # look for a definition
        #config = WidgetDbConfig.get_by_search_type(my.search_type, "edit")
        #if config:
        #    configs.append(config)

        file_configs = WidgetConfigView.get_configs_from_file(my.search_type, my.view)
        configs.extend(file_configs)

        file_configs = WidgetConfigView.get_configs_from_file(my.search_type, "edit")
        configs.extend(file_configs)

        #TODO: add edit_definition    
        #file_configs = WidgetConfigView.get_configs_from_file(my.search_type, "edit_definition")
        #configs.extend(file_configs)
        if not get_edit_def:
            config = WidgetDbConfig.get_by_search_type(my.search_type, "edit_definition")
            if config:
                configs.append(config)
    
        config = WidgetConfigView(my.search_type, my.view, configs)
        return config
开发者ID:funic,项目名称:TACTIC,代码行数:37,代码来源:edit_wdg.py


示例12: get_search_col

    def get_search_col(cls, search_type, simple_search_view=''):
        '''Get the appropriate keyword search col based on column existence in this sType'''
        if simple_search_view:
            from pyasm.widget import WidgetConfigView
            config = WidgetConfigView.get_by_search_type(search_type, simple_search_view)
            # assume the keyword filter is named "keyword"
            options = config.get_display_options('keyword')
            column = options.get('column')
           
            if column:
                return column

        for col in cls.SEARCH_COLS:
            if SearchType.column_exists(search_type, col):
                return col

        return cls.SEARCH_COLS[-1]
开发者ID:makeittotop,项目名称:python-scripts,代码行数:17,代码来源:simple_search_wdg.py


示例13: preprocess

    def preprocess(my):
        my.elements = my.kwargs.get("elements")
        if my.elements:
            my.elements = my.elements.split('|')
        else:
            my.elements = []

        # get the definition
        sobjects = my.sobjects
        if sobjects:
            sobject = sobjects[0]
            search_type = sobject.get_search_type()
            view = 'definition'

            from pyasm.widget import WidgetConfigView
            my.config = WidgetConfigView.get_by_search_type(search_type, view)
        else:
            my.config = None
开发者ID:0-T-0,项目名称:TACTIC,代码行数:18,代码来源:task_status_report_wdg.py


示例14: get_definitions

    def get_definitions(my, element_name):
        '''get all the definitions for this element'''
        search_type = my.kwargs.get("search_type")
        view = my.kwargs.get("view")
        config_view = WidgetConfigView.get_by_search_type(search_type, view)

        display_class = config_view.get_display_handler(element_name)
        element_attr = config_view.get_element_attributes(element_name)

        for config in config_view.get_configs():
            #print config
            view = config.get_view()
            file_path = config.get_file_path()
            if not file_path:
                file_path = "from Database"
            #print view, file_path

            xml = config.get_element_xml(element_name)
开发者ID:0-T-0,项目名称:TACTIC,代码行数:18,代码来源:element_definition_wdg.py


示例15: check

    def check(my):
        my.web = WebContainer.get_web()
        search_type = my.sobject.get_search_type_obj()
        
        config = WidgetConfigView.get_by_search_type(search_type, "insert", local_search=True)
        columns = config.get_element_names()

        if len(columns) != 3:
            raise TacticException('The command is expecting 3 fields only.')
      
        my.date = my.web.get_form_value('edit|%s' % columns[0])
        my.desc =  my.web.get_form_value('edit|%s'% columns[1])
        date = Date(db_date=my.date)
        my.year = date.get_year()
        my.week = date.get_week()
        my.project_code =  my.web.get_form_value('edit|%s'% columns[2])
         
        if not my.desc or not my.date or not my.project_code:
            raise UserException('One or more fields are empty.')
        Project.set_project(my.project_code)
        return True
开发者ID:0-T-0,项目名称:TACTIC,代码行数:21,代码来源:timecard_wdg.py


示例16: get_display

    def get_display(my):
        web = WebContainer.get_web()

        if web.get_form_value("Insert/Exit"):
            widget = Widget()
            iframe = WebContainer.get_iframe()
            widget.add( HtmlElement.script(iframe.get_off_script()) )
            widget.add( HtmlElement.script("window.parent.document.form.submit()") )
            return widget


        database = Project.get_project_code()
        search_type = web.get_form_value("search_type")
        assert search_type

        view = web.get_form_value("view")
        if not view:
            view = get_template_view()
        
        widget = DivWdg()

        WebContainer.register_cmd("pyasm.widget.CustomAddElementCbk")

        # remember some parameters
        widget.add( HiddenWdg("search_type", search_type) )
        widget.add( HiddenWdg("view", view) )

        # Get the definition widget and list all of the custom elements
        config = WidgetConfigView.get_by_search_type(search_type,DEFAULT_VIEW)
        element_names = config.get_element_names()

        # show current custom
        widget.add("<h3>Add Element for [%s]</h3>" % search_type)

        widget.add( my.get_new_custom_widget(view) )

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


示例17: execute

    def execute(my):
        sobject = my.sobject


        search_type = sobject.get_search_type_obj()
        config = WidgetConfigView.get_by_search_type(search_type, "custom")
        if not config:
            return

        my.element_names = config.get_element_names()

        # create all of the handlers
        action_handlers = []

        for element_name in (my.element_names):
            action_handler_class = \
                config.get_action_handler(element_name)

            if action_handler_class == "":
                action_handler_class = "DatabaseAction"
        

            action_handler = WidgetConfig.create_widget( action_handler_class )
            action_handler.set_name(element_name)
            action_handler.set_input_prefix("edit")

            action_options = config.get_action_options(element_name)
            for key, value in action_options.items():
                action_handler.set_option(key, value)
            action_handlers.append(action_handler)

        # set the sobject for each action handler
        for action_handler in action_handlers:
            action_handler.set_sobject(sobject)
            if action_handler.check():
                action_handler.execute()
开发者ID:CeltonMcGrath,项目名称:TACTIC,代码行数:36,代码来源:custom_info_wdg.py


示例18: get_display

    def get_display(my):
        my.preprocess()

        sobject = my.get_current_sobject()

        view = my.get_option("view")
        if not view:
            view = "custom_view"

        search_type = sobject.get_search_type_obj()
        config = WidgetConfigView.get_by_search_type(search_type, view)
        widget_config_view = WidgetConfigView(search_type, view, [config])
        if not config:
            span = SpanWdg("None")
            span.add_style("color: #ccc")
            return span
        try:
            base = CustomConfigWdg(search_type, view, \
                config=widget_config_view, input_prefix="edit")
            
        except TacticException, e:
            span = SpanWdg("None")
            span.add_style("color: #ccc")
            return span
开发者ID:CeltonMcGrath,项目名称:TACTIC,代码行数:24,代码来源:custom_info_wdg.py


示例19: ManageSearchTypeDetailWdg

class ManageSearchTypeDetailWdg(ManageSideBarDetailWdg):

    ADD_COLUMN = "Commit New Column"
    MODIFY_COLUMN = "Modify Column"
    REMOVE_COLUMN = "Remove Column"

    def get_config(self, search_type, view,  default=False, personal=False):
        config = ManageSearchTypeMenuWdg.get_config(search_type, view, default=default)
        return config


    def init(self):
        '''initialize the widget_config, and from there retrieve the schema_config'''
        web = WebContainer.get_web()
        self.search_type = self.kwargs.get('search_type')
        
        element_name = self.kwargs.get('element_name')
        self.view = self.kwargs.get('view')
        
        # FIXME: comment out the assert for now to avoid error screen
        if not self.view:
            self.view = 'table'
        #assert self.view

        self.config_xml = self.kwargs.get('config_xml')
        if not self.config_xml:
            self.config_xml = web.get_form_value('config_xml')
        
        self.default = self.kwargs.get('default') == 'True'

        cbk = ManageSearchTypeDetailCbk(search_type=self.search_type, view=self.view, \
                element_name=element_name)
        Command.execute_cmd(cbk)

        self.config_string = ""
        self.data_type_string = ""
        self.name_string = ""
        self.title_string = ""
        self.nullable_string = ""
        self.has_column = True


       
        if element_name:
            if self.config_xml:
                self.config_string = self.config_xml
                whole_config_string = "<config><%s>%s</%s></config>"%(self.view, self.config_xml, self.view)
                config = WidgetConfig.get(xml=whole_config_string, view=self.view)
                self.config = WidgetConfigView(self.search_type, self.view, [config])
            else:
                # don't pass in default here
                self.config = self.get_config(self.search_type, self.view)
                node = self.config.get_element_node(element_name)
                if node is not None:
                    config_xml = self.config.get_xml()
                    

                    self.config_string = config_xml.to_string(node)
                    self.title_string = config_xml.get_attribute(node, 'title')
            schema_config = SearchType.get_schema_config(self.search_type)
            
            attributes = schema_config.get_element_attributes(element_name)
            self.data_type_string = attributes.get("data_type")
            
            # double_precision is float
            if self.data_type_string == 'double precision':
                self.data_type_string = 'float'

            self.name_string = attributes.get("name")
            self.nullable_string = attributes.get("nullable")
            self.is_new_column = attributes.get("new") == 'True'

            # a database columnless widget
            if not self.name_string:
                self.has_column = False
                                
    def get_display(self):

        # add the detail widget
        detail_wdg = DivWdg(css='spt_detail_panel')
        if not self.name_string and not self.config_string:
            detail_wdg.add("<br/>"*3)
            detail_wdg.add('<- Click on an item on the left for modification.')
            detail_wdg.add_style("padding: 10px")
            detail_wdg.add_color("background", "background", -5)
            detail_wdg.add_style("width: 350px")
            detail_wdg.add_style("height: 400px")
            detail_wdg.add_border()

            return detail_wdg

        if self.kwargs.get("mode") == "empty":
            overlay = DivWdg()
            detail_wdg.add(overlay)

        detail_wdg.add_border()
        detail_wdg.add_color("color", "black")
        detail_wdg.add_style("padding: 10px")
        detail_wdg.add_color("background", "background", -5)

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


示例20: get_element_wdg

    def get_element_wdg(my, xml, def_config):

        element_node = xml.get_node("config/tmp/element")
        attrs = Xml.get_attributes(element_node)
        element_name = attrs.get("name")

        widget = my.get_widget(element_name)
        if widget:
            return widget


        if not element_name:
            import random
            num = random.randint(0, 100000)
            element_name = "element%s" % num
            xml.set_attribute(element_node, "name", element_name)


        # enable an ability to have a widget only loaded once in a request
        if attrs.get('load_once') in ['true', True]:
            widgets = Container.get("CustomLayoutWdg:widgets")
            if widgets == None:
                widgets = {}
                Container.put("CustomLayoutWdg:widgets", widgets)
            else:
                if widgets[element_name] == True:
                    return None

                widgets[element_name] = True


        # provide the ability to have shorthand format 
        # ie: <element display_class="tactic.ui..." />
        display_node = xml.get_node("config/tmp/element/display")
        if display_node is None:
            view = attrs.get("view")
            type = attrs.get("type")

            if type == "reference":
                search_type = attrs.get("search_type")
                my.config = WidgetConfigView.get_by_search_type(search_type, view)
                # check if definition has no name.  Don't use element_name
                if not attrs.get("name"):
                    return

                element_wdg = my.config.get_display_widget(element_name, extra_options=attrs)
                container = DivWdg()
                container.add(element_wdg)
                return container


            class_name = attrs.get("display_class")

            # if no class name is defined and not view is defined look
            # at predefined elements
            if not view and not class_name:
                element_wdg = my.config.get_display_widget(element_name, extra_options=attrs)
                container = DivWdg()
                container.add(element_wdg)
                return container


            # look at the attributes
            if not class_name:
                class_name = "tactic.ui.panel.CustomLayoutWdg"
            display_node = xml.create_element("display")
            xml.set_attribute(display_node, "class", class_name)
            xml.append_child(element_node, display_node)

            for name, value in attrs.items():
                # replace the spt_ in the name.
                # NOTE: should this be restricted to only spt_ attributes?
                name = name.replace("spt_", "")
                attr_node = xml.create_element(name)
                xml.set_node_value(attr_node, value)
                xml.append_child(display_node, attr_node)


        load = attrs.get("load")
        if load in ["async", "sequence"]:
            return my.get_async_element_wdg(xml, element_name, load)




        use_container = attrs.get('use_container') == 'true'
        if use_container:
            # DEPRECATED
            container = my.get_container(xml)
        else:
            container = DivWdg()

        # add in attribute from the element definition
        # DEPRECATED: does this make any sense to have this here?
        for name, value in attrs.items():
            if name == 'name':
                continue
            container.add_style(name, value)


#.........这里部分代码省略.........
开发者ID:southpawtech,项目名称:TACTIC-DEV,代码行数:101,代码来源:custom_layout_wdg.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python decoder.decode函数代码示例发布时间:2022-05-25
下一篇:
Python widget.WidgetConfig类代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap