本文整理汇总了Python中pyasm.widget.WidgetConfigView.get_display_widget方法的典型用法代码示例。如果您正苦于以下问题:Python WidgetConfigView.get_display_widget方法的具体用法?Python WidgetConfigView.get_display_widget怎么用?Python WidgetConfigView.get_display_widget使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyasm.widget.WidgetConfigView
的用法示例。
在下文中一共展示了WidgetConfigView.get_display_widget方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_element_wdg
# 需要导入模块: from pyasm.widget import WidgetConfigView [as 别名]
# 或者: from pyasm.widget.WidgetConfigView import get_display_widget [as 别名]
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)
#.........这里部分代码省略.........
示例2: get_element_wdg
# 需要导入模块: from pyasm.widget import WidgetConfigView [as 别名]
# 或者: from pyasm.widget.WidgetConfigView import get_display_widget [as 别名]
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")
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")
# look at the attributes
class_name = attrs.get("display_class")
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.
# TODO: 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)
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)
# add the content
try:
view_node = xml.get_node("config/tmp/element/display/view")
if view_node is not None:
view = xml.get_node_value(view_node)
if view.startswith("."):
if my.view_folder:
xml.set_node_value(view_node, "%s%s" %(my.view_folder,view))
tmp_config = WidgetConfig.get('tmp', xml=xml)
configs = []
configs.append(tmp_config)
# add the def_config if it exists
if def_config:
configs.append(def_config)
config = WidgetConfigView('CustomLayoutWdg', 'tmp', configs, state=my.state)
# NOTE: this doesn't work too well when we go to an abasolute
# view.
parent_view = my.kwargs.get("parent_view")
if parent_view:
parent_view = parent_view.replace(".", "/")
parent_view = "%s/%s" % (parent_view, my.view)
else:
parent_view = my.view
# TODO: need some protection code for infinite loops
includes = my.kwargs.get("include")
element_wdg = config.get_display_widget(element_name, extra_options={"include":includes, "parent_view":parent_view})
element_top = element_wdg.get_top()
#.........这里部分代码省略.........