本文整理汇总了Python中pyasm.widget.WidgetConfig.create_widget方法的典型用法代码示例。如果您正苦于以下问题:Python WidgetConfig.create_widget方法的具体用法?Python WidgetConfig.create_widget怎么用?Python WidgetConfig.create_widget使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyasm.widget.WidgetConfig
的用法示例。
在下文中一共展示了WidgetConfig.create_widget方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: execute
# 需要导入模块: from pyasm.widget import WidgetConfig [as 别名]
# 或者: from pyasm.widget.WidgetConfig import create_widget [as 别名]
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()
示例2: init
# 需要导入模块: from pyasm.widget import WidgetConfig [as 别名]
# 或者: from pyasm.widget.WidgetConfig import create_widget [as 别名]
def init(my):
# create all of the display elements
if not my.config:
# it shouldn't use the my.search_type_obj here as it would absorb the project info
my.config = WidgetConfigView.get_by_search_type(my.search_type, my.config_base)
my.element_names = my.config.get_element_names()
my.element_titles = my.config.get_element_titles()
# TODO: should probably be all the attrs
my.element_widths = my.config.get_element_widths()
simple_view = my.kwargs.get("show_simple_view")
if simple_view == "true":
simple_view = True
else:
simple_view = False
# go through each element name and construct the handlers
for idx, element_name in enumerate(my.element_names):
# check to see if these are removed for this production
#if element_name in invisible_elements:
# continue
simple_element = None
display_handler = my.config.get_display_handler(element_name)
new_display_handler = my.remap_display_handler(display_handler)
if new_display_handler:
display_handler = new_display_handler
if not display_handler:
# else get it from default of this type
display_handler = my.get_default_display_handler(element_name)
# get the display options
display_options = my.config.get_display_options(element_name)
try:
if not display_handler:
element = my.config.get_display_widget(element_name)
else:
element = WidgetConfig.create_widget( display_handler, display_options=display_options )
except Exception, e:
from tactic.ui.common import WidgetTableElementWdg
element = WidgetTableElementWdg()
# FIXME: not sure why this doesn't work
#from pyasm.widget import ExceptionWdg
#log = ExceptionWdg(e)
#element.add(log)
# FIXME: not sure why this doesn't work
from pyasm.widget import IconWdg
icon = IconWdg("Error", IconWdg.ERROR)
element.add(icon)
element.add(e)
# skip the empty elements like ThumbWdg
if simple_element and not element.is_simple_viewable():
continue
# make simple_element the element if it exists
if simple_element:
element = simple_element
# if the element failed to create, then continue
if element == None:
continue
element.set_name(element_name)
title = my.element_titles[idx]
element.set_title(title)
# FIXME: this causes a circular reference which means the
# Garbage collector can't clean it up
# make sure the element knows about its layout engine
element.set_layout_wdg(my)
# TODO: should convert this to ATTRS or someting like that. Not
# just width
if idx >= len(my.element_widths):
element.width = 150
else:
element.width = my.element_widths[idx]
if my.input_prefix:
element.set_input_prefix(my.input_prefix)
# get the display options
#display_options = my.config.get_display_options(element_name)
#for key in display_options.keys():
element.set_options(display_options)
my.add_widget(element,element_name)
# layout widgets also categorize their widgets based on type
if element_name == "Filter":
section_name = 'filter'
#.........这里部分代码省略.........
示例3: init
# 需要导入模块: from pyasm.widget import WidgetConfig [as 别名]
# 或者: from pyasm.widget.WidgetConfig import create_widget [as 别名]
def init(self):
# create all of the display elements
if not self.config:
# it shouldn't use the self.search_type_obj here as it would absorb the project info
self.config = WidgetConfigView.get_by_search_type(self.search_type, self.config_base)
self.element_names = self.config.get_element_names()
self.element_titles = self.config.get_element_titles()
# TODO: should probably be all the attrs
self.element_widths = self.config.get_element_widths()
simple_view = self.kwargs.get("show_simple_view")
if simple_view == "true":
simple_view = True
else:
simple_view = False
self.extra_data = self.kwargs.get("extra_data")
if self.extra_data and isinstance(self.extra_data, basestring):
try:
self.extra_data = jsonloads(self.extra_data)
except:
self.extra_data = self.extra_data.replace("'", '"')
self.extra_data = jsonloads(self.extra_data)
# go through each element name and construct the handlers
for idx, element_name in enumerate(self.element_names):
# check to see if these are removed for this production
#if element_name in invisible_elements:
# continue
simple_element = None
display_handler = self.config.get_display_handler(element_name)
new_display_handler = self.remap_display_handler(display_handler)
if new_display_handler:
display_handler = new_display_handler
if not display_handler:
# else get it from default of this type
display_handler = self.get_default_display_handler(element_name)
# get the display options
display_options = self.config.get_display_options(element_name)
# add in extra_data
if self.extra_data:
for key, value in self.extra_data.items():
display_options[key] = value
try:
if not display_handler:
element = self.config.get_display_widget(element_name)
else:
display_options['element_name'] = element_name
element = WidgetConfig.create_widget( display_handler, display_options=display_options )
except Exception as e:
from tactic.ui.common import WidgetTableElementWdg
element = WidgetTableElementWdg()
# FIXME: not sure why this doesn't work
#from pyasm.widget import ExceptionWdg
#log = ExceptionWdg(e)
#element.add(log)
# FIXME: not sure why this doesn't work
from pyasm.widget import IconWdg
icon = IconWdg("Error", IconWdg.ERROR)
element.add(icon)
element.add(e)
# skip the empty elements like ThumbWdg
if simple_element and not element.is_simple_viewable():
continue
# make simple_element the element if it exists
if simple_element:
element = simple_element
# if the element failed to create, then continue
if element == None:
continue
element.set_name(element_name)
title = self.element_titles[idx]
element.set_title(title)
# FIXME: this causes a circular reference which means the
# Garbage collector can't clean it up
# make sure the element knows about its layout engine
element.set_layout_wdg(self)
# TODO: should convert this to ATTRS or someting like that. Not
# just width
if idx >= len(self.element_widths):
element.width = 150
#.........这里部分代码省略.........