本文整理汇总了Python中pyasm.widget.SelectWdg.add_event方法的典型用法代码示例。如果您正苦于以下问题:Python SelectWdg.add_event方法的具体用法?Python SelectWdg.add_event怎么用?Python SelectWdg.add_event使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyasm.widget.SelectWdg
的用法示例。
在下文中一共展示了SelectWdg.add_event方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_action_wdg
# 需要导入模块: from pyasm.widget import SelectWdg [as 别名]
# 或者: from pyasm.widget.SelectWdg import add_event [as 别名]
def get_action_wdg(my):
filter_div = DivWdg()
select = SelectWdg("filter_action")
select.add_empty_option("-- search action --")
select.add_style("text-align: right")
select.set_option("labels", "Retrieve Search|Save Search")
select.set_option("values", "retrieve|save")
select.add_event("onchange", "spt.dg_table.search_action_cbk(this)")
filter_div.add(select)
return filter_div
示例2: get_display
# 需要导入模块: from pyasm.widget import SelectWdg [as 别名]
# 或者: from pyasm.widget.SelectWdg import add_event [as 别名]
def get_display(self):
# add a view action
view_div = DivWdg()
view_select = SelectWdg("action|view_action")
view_select.add_style("text-align: right")
view_select.add_empty_option("-- view --")
view_select.set_option("values", "copy_url|add_my_view|edit|save|rename|delete|custom_property|custom_script")
view_select.set_option("labels", "X Copy URL to this View|Add to My Views|Edit as Draft|Save Project View As|X Rename View|X Delete View|Add Custom Property|Add Custom Script")
view_div.add_style("float: right")
view_div.add(view_select)
view_select.add_event("onchange", "spt.dg_table.view_action_cbk(this,'%s')" % self.table_id)
return view_div
示例3: get_display
# 需要导入模块: from pyasm.widget import SelectWdg [as 别名]
# 或者: from pyasm.widget.SelectWdg import add_event [as 别名]
def get_display(my):
widget = Widget()
div = DivWdg(css="filter_box")
show_span = SpanWdg(css="med")
show_span.add("Show All Types: ")
checkbox = FilterCheckboxWdg("show_all_types")
checkbox.set_persistence()
show_span.add(checkbox)
show_all_types = checkbox.get_value()
div.add(show_span)
span = SpanWdg(css="med")
span.add("Search Type: ")
select = SelectWdg("filter|search_type")
select.add_empty_option("-- Select --")
project = Project.get()
project_type = project.get_base_type()
search = Search("sthpw/search_object")
if show_all_types:
search.add_where(
"""
namespace = '%s' or namespace = '%s' or search_type in ('sthpw/task')
"""
% (project_type, project.get_code())
)
else:
# show only the custom ones
search.add_filter("namespace", project.get_code())
search.add_order_by("title")
sobjects = search.get_sobjects()
select.set_sobjects_for_options(sobjects, "search_type", "title")
# select.set_option("query", "sthpw/search_object|search_type|title")
select.set_persistence()
select.add_event("onchange", "document.form.submit()")
search_type = select.get_value()
span.add(select)
div.add(span)
# make sure the current selection exists
try:
SearchType.get(search_type)
except SearchException, e:
return div
示例4: handle_simple_mode
# 需要导入模块: from pyasm.widget import SelectWdg [as 别名]
# 或者: from pyasm.widget.SelectWdg import add_event [as 别名]
def handle_simple_mode(my, custom_table, mode):
tbody = custom_table.add_tbody()
tbody.add_class("spt_custom_simple")
if mode != 'simple':
tbody.add_style('display: none')
name_text = TextWdg("custom_name")
name_text.add_class("spt_input")
tr = custom_table.add_row()
tr.add_color("background", "background", -7)
td = custom_table.add_cell("Name: ")
td.add_style("min-width: 150px")
custom_table.add_cell(name_text)
# add title
custom_table.add_row()
title_wdg = TextWdg("custom_title")
title_wdg.add_attr("size", "50")
custom_table.add_cell( "Title: " )
custom_table.add_cell( title_wdg )
# add description
tr = custom_table.add_row()
tr.add_color("background", "background", -7)
description_wdg = TextAreaWdg("custom_description")
custom_table.add_cell( "Description: " )
custom_table.add_cell( description_wdg )
type_select = SelectWdg("custom_type")
type_select.add_class("spt_input")
#type_select.add_empty_option("-- Select --")
type_select.set_option("values", "string|text|integer|float|boolean|currency|date|foreign_key|list|button|empty")
type_select.set_option("labels", "String(db)|Text(db)|Integer(db)|Float(db)|Boolean(db)|Currency(db)|Date(db)|Foreign Key(db)|List(db)|Button|Empty")
#type_select.set_option("labels", "String|Integer|Boolean|Currency|Timestamp|Link|Foreign Key|List|Checkbox|Text|Number|Date|Date Range")
tr = custom_table.add_row()
custom_table.add_cell("Property Type: ")
td = custom_table.add_cell(type_select)
type_select.add_event("onchange", "spt.custom_property_adder.property_type_select_cbk(this)")
# extra info for foreign key
custom_table.add_row()
div = DivWdg()
div.add_class("foreign_key_options")
div.add_style("display: none")
div.add_style("margin-top: 10px")
div.add("Options")
div.add(HtmlElement.br())
# TODO: this class should not be in prod!!
from pyasm.prod.web import SearchTypeSelectWdg
div.add("Relate to: ")
search_type_select = SearchTypeSelectWdg("foreign_key_search_select", mode=SearchTypeSelectWdg.CURRENT_PROJECT)
div.add(search_type_select)
td.add(div)
# extra info for list
custom_table.add_row()
div = DivWdg()
div.add_class("list_options")
div.add_style("display: none")
div.add_style("margin-top: 10px")
div.add("Options")
div.add(HtmlElement.br())
# TODO: this class should not be in prod!!
from pyasm.prod.web import SearchTypeSelectWdg
div.add("Values: ")
search_type_text = TextWdg("list_values")
div.add(search_type_text)
td.add(div)
# extra info for button
custom_table.add_row()
div = DivWdg()
div.add_class("button_options")
div.add_style("display: none")
div.add_style("margin-top: 10px")
class_path = "tactic.ui.table.ButtonElementWdg"
button = Common.create_from_class_path(class_path)
args_keys = button.get_args_keys()
div.add("Options")
div.add(HtmlElement.br())
for key in args_keys.keys():
div.add("Name: ")
option_name_text = TextWdg("option_name")
option_name_text.add_attr("readonly", "true")
option_name_text.set_value(key)
#.........这里部分代码省略.........
示例5: get_display
# 需要导入模块: from pyasm.widget import SelectWdg [as 别名]
# 或者: from pyasm.widget.SelectWdg import add_event [as 别名]
def get_display(self):
top_wdg = DivWdg()
top_wdg.add_style("color: black")
top_wdg.add_style("width: 350px")
top_wdg.add_style("margin-top: 10px")
top_wdg.add_style("padding: 10px")
top_wdg.add_border()
title = DivWdg()
title.add_style("color: black")
title.add_style("margin-top: -22px")
top_wdg.add(title)
#if not self.name_string:
# title.add('No database column')
# return top_wdg
title.add("Widget Definition")
widget_types = {
'foreign_key': 'tactic.ui.table.ForeignKeyElementWdg',
'button': 'tactic.ui.table.ButtonElementWdg',
'expression': 'tactic.ui.table.ExpressionElementWdg'
}
web = WebContainer.get_web()
config_string = web.get_form_value("config_xml")
if not config_string:
config_string = '<config/>'
xml = Xml()
xml.read_string(config_string)
#print "config_string: ", config_string
# get values from the config file
element_name = xml.get_value('element/@name')
config = WidgetConfig.get(view='element',xml='<config><element>%s</element></config>' % config_string)
display_options = config.get_display_options(element_name)
title = xml.get_value('element/@title')
display_handler = xml.get_value('element/display/@class')
if not display_handler:
display_handler = 'tactic.ui.panel.TypeTableElementWdg'
widget_name = xml.get_value('element/display/@widget')
if not widget_name:
widget_name = 'custom'
custom_table = Table()
custom_table.add_style("color: black")
top_wdg.add(custom_table)
name_text = DivWdg()
name_text.add_style("color: black")
name_text.add(element_name)
custom_table.add_row()
custom_table.add_cell("Name: ")
custom_table.add_cell(name_text)
# add title
custom_table.add_row()
title_wdg = TextWdg("custom_title")
title_wdg.set_value(title)
title_wdg.add_attr("size", "50")
custom_table.add_cell( "Title: " )
custom_table.add_cell( title_wdg )
# add description
#custom_table.add_row()
#description_wdg = TextAreaWdg("custom_description")
#td = custom_table.add_cell( "Description: " )
#td.add_style("vertical-align: top")
#custom_table.add_cell( description_wdg )
type_select = SelectWdg("custom_type")
#type_select.add_empty_option("-- Select --")
type_select.set_option("values", "string|integer|float|boolean|currency|date|foreign_key|link|list|button|custom")
type_select.set_option("labels", "String(db)|Integer(db)|Float(db)|Boolean(db)|Currency(db)|Date(db)|Foreign Key|Link|List|Button|Custom")
type_select.set_value(widget_name)
#type_select.set_option("values", "string|integer|float|boolean|currency|date|link|list|foreign_key|button|empty")
#type_select.set_option("labels", "String|Integer|Float|Boolean|Currency|Date|Link|List|Foreign Key|Button|Empty")
custom_table.add_row()
td = custom_table.add_cell("Widget Type: ")
td.add_style("vertical-align: top")
td = custom_table.add_cell(type_select)
type_select.add_event("onchange", "spt.CustomProject.property_type_select_cbk(this)")
td.add(HtmlElement.br())
display_handler_text = TextWdg("display_handler")
display_handler_text.add_attr("size", "50")
#.........这里部分代码省略.........
示例6: get_new_custom_widget
# 需要导入模块: from pyasm.widget import SelectWdg [as 别名]
# 或者: from pyasm.widget.SelectWdg import add_event [as 别名]
def get_new_custom_widget(my, view):
custom_table = Table(css="table")
name_text = TextWdg("new_custom_name")
custom_table.add_row()
custom_table.add_cell("Name: ")
custom_table.add_cell(name_text)
type_select = SelectWdg("new_custom_type")
#type_select.add_empty_option("-- Select --")
type_select.set_option("values", "Name/Code|Foreign Key|List|Checkbox|Text|Number|Date|Date Range")
custom_table.add_row()
custom_table.add_cell("Predefined Type: ")
td = custom_table.add_cell(type_select)
td.add( HtmlElement.script('''
function property_type_select(el) {
if (el.value == "Foreign Key") {
set_display_on('foreign_key_options')
}
else if (el.value == "List") {
set_display_on('list_options')
}
else {
set_display_off('foreign_key_options')
set_display_off('list_options')
}
}
''') )
type_select.add_event("onchange", "property_type_select(this)")
# extra info for foreign key
custom_table.add_row()
div = DivWdg()
div.set_id("foreign_key_options")
div.add_style("display: none")
div.add_style("margin-top: 10px")
div.add("Options")
div.add(HtmlElement.br())
# TODO: this class should not be in prod!!
from pyasm.prod.web import SearchTypeSelectWdg
div.add("Relate to: ")
search_type_select = SearchTypeSelectWdg("foreign_key_search_select", mode=SearchTypeSelectWdg.CURRENT_PROJECT)
div.add(search_type_select)
td.add(div)
# extra info for foreign key
custom_table.add_row()
div = DivWdg()
div.set_id("list_options")
div.add_style("display: none")
div.add_style("margin-top: 10px")
div.add("Options")
div.add(HtmlElement.br())
# TODO: this class should not be in prod!!
from pyasm.prod.web import SearchTypeSelectWdg
div.add("Values: ")
search_type_text = TextWdg("list_values")
div.add(search_type_text)
td.add(div)
custom_table.add_row()
description_wdg = TextAreaWdg("new_description")
custom_table.add_cell( "Description: " )
custom_table.add_cell( description_wdg )
# add to current view
if view not in ['edit', 'insert']:
custom_table.add_row()
current_view_wdg = CheckboxWdg("add_to_current_view")
current_view_wdg.set_checked()
custom_table.add_cell("Add To Current View: ")
td = custom_table.add_cell(current_view_wdg)
custom_table.add_row()
edit_view_wdg = CheckboxWdg("add_to_edit_view")
edit_view_wdg.set_checked()
custom_table.add_cell("Add To Edit View: ")
custom_table.add_cell(edit_view_wdg)
# add to edit view
custom_table.add_row()
custom_table.add_blank_cell()
custom_table.add_cell(SpanWdg('If you check this for a search type already in the system, it will create an edit view that overrides the built-in edit view. This may affect its editability. You can always delete the edit view in the Configure Widgets tab afterwards.', css='warning smaller'))
custom_table.add_row()
from pyasm.prod.web import ProdIconSubmitWdg, ProdIconButtonWdg
submit = ProdIconSubmitWdg("Insert/Next")
tr, td = custom_table.add_row_cell(submit)
td.add_style("text-align: center")
submit = ProdIconSubmitWdg("Insert/Exit")
td.add(submit)
#.........这里部分代码省略.........
示例7: init
# 需要导入模块: from pyasm.widget import SelectWdg [as 别名]
# 或者: from pyasm.widget.SelectWdg import add_event [as 别名]
def init(my):
search = Search("sthpw/queue")
search.add_order_by("priority desc")
search.add_order_by("timestamp desc")
widget = Widget()
div = DivWdg(css="filter_box")
span = SpanWdg(css="med")
from pyasm.prod.web import SearchFilterWdg
search_filter = SearchFilterWdg(columns=Queue.get_search_columns())
search_filter.alter_search(search)
span.add(search_filter)
div.add(span)
span = SpanWdg(css="med")
priority_wdg = TextWdg("priority_search")
priority_wdg.set_persistence()
priority = priority_wdg.get_value()
if priority:
search.add_filter("priority", priority)
span.add("Priority: ")
span.add(priority_wdg)
div.add(span)
select = SelectWdg("queue_state")
select.set_option("values", "|pending|locked|error|done")
select.set_option("labels", "All|pending|locked|error|done")
select.add_event("onchange", "document.form.submit()")
select.set_persistence()
span = SpanWdg(css="med")
span.add("State: ")
span.add(select)
div.add(span)
queue_state = select.get_value()
if queue_state != "":
search.add_filter("state", queue_state)
user_select = SelectWdg("user_select")
user_select.add_empty_option()
user_search = Search("sthpw/login")
user_select.set_search_for_options(user_search, "login", "login")
user_select.add_event("onchange", "document.form.submit()")
user_select.set_persistence()
div.add("User: ")
div.add(user_select)
queue_user = user_select.get_value()
if queue_user != "":
search.add_filter("login", queue_user)
search_limit = SearchLimitWdg()
search_limit.set_limit(10)
div.add(search_limit)
search_limit.alter_search(search)
widget.add(div)
sobjects = search.get_sobjects()
table = TableWdg("sthpw/queue")
table.set_sobjects(sobjects)
widget.add(table)
my.add(widget)
示例8: get_display
# 需要导入模块: from pyasm.widget import SelectWdg [as 别名]
# 或者: from pyasm.widget.SelectWdg import add_event [as 别名]
def get_display(my):
div = DivWdg()
div.add_style("padding: 10px 0px 10px 0px")
behavior = {"type": "keyboard", "kbd_handler_name": "DgTableMultiLineTextEdit"}
div.add_behavior(behavior)
project_code = None
sobject = my.get_current_sobject()
if sobject:
project_code = sobject.get_project_code()
project_filter = Project.get_project_filter(project_code)
query_filter = my.get_option("query_filter")
if not query_filter:
# try getting it from the search_type
web = WebContainer.get_web()
search_type = web.get_form_value("search_type")
if search_type:
search_type_obj = SearchType.get(search_type)
base_search_type = search_type_obj.get_base_search_type()
query_filter = "search_type = '%s'" % base_search_type
# add the project filter
if query_filter:
query_filter = "%s and %s" % (query_filter, project_filter)
else:
query_filter = project_filter
my.set_option("query_filter", query_filter)
select = SelectWdg()
select.add_empty_option("-- Select --")
select.copy(my)
select.add_event("onchange", "alert('cow')")
div.add(select)
span = SpanWdg(css="med")
span.add("Add Initial Tasks: ")
checkbox = CheckboxWdg("add_initial_tasks")
checkbox.set_persistence()
if checkbox.is_checked(False):
checkbox.set_checked()
span.add(checkbox)
div.add(span)
# list all of the processes with checkboxes
pipeline_code = select.get_value()
if pipeline_code:
pipeline = Pipeline.get_by_code(pipeline_code)
if not pipeline:
print "WARNING: pipeline '%s' does not exist" % pipeline_code
return
process_names = pipeline.get_process_names(recurse=True)
process_div = DivWdg()
for process in process_names:
checkbox = CheckboxWdg("add_initial_tasks")
process_div.add(checkbox)
process_div.add(" ")
process_div.add(process)
process_div.add(HtmlElement.br())
div.add(process_div)
return div
示例9: SelectWdg
# 需要导入模块: from pyasm.widget import SelectWdg [as 别名]
# 或者: from pyasm.widget.SelectWdg import add_event [as 别名]
search_type = select.get_value()
span.add(select)
div.add(span)
# make sure the current selection exists
try:
SearchType.get(search_type)
except SearchException, e:
return div
except SqlException, e:
return div
# add the view selector
view_select = SelectWdg("view")
view_select.add_empty_option("-- View --")
view_select.add_event("onchange", "document.form.submit()")
view_select.set_persist_on_submit()
# view_select.set_persistence()
span = SpanWdg(css="med")
span.add("Defined Views: ")
span.add(view_select)
div.add(span)
div.add(my.get_create_view_wdg(search_type))
div.add(HtmlElement.br(2))
div.add(my.get_new_tab_wdg())
widget.add(div)
示例10: get_first_row_wdg
# 需要导入模块: from pyasm.widget import SelectWdg [as 别名]
# 或者: from pyasm.widget.SelectWdg import add_event [as 别名]
#.........这里部分代码省略.........
data_row = data_row_text.get_value()
if not data_row:
data_row = 0
else:
try:
data_row = int(data_row)
except ValueError:
data_row = 0
if data_row >= len(csv_data):
data_row = len(csv_data)-1
data_row_text.set_value(data_row)
table = Table()
table.set_attr("cellpadding", "10")
table.add_row()
table.add_header("CSV Column Value")
table.add_header("TACTIC Column")
table.add_header("Create New Column")
columns = my.search_type_obj.get_columns()
search_type = my.search_type_obj.get_base_search_type()
sobj = SObjectFactory.create(search_type)
required_columns = sobj.get_required_columns()
row = csv_data[data_row]
labels = []
for column in columns:
if column in required_columns:
label = '%s**'%column
else:
label = column
labels.append(label)
for j, cell in enumerate(row):
table.add_row()
table.add_cell(cell)
column_select = SelectWdg("column_%s" % j)
column_select.add_event("onchange", "if (this.value!='') {set_display_off('new_column_div_%s')} else {set_display_on('new_column_div_%s')}" % (j,j))
column_select.add_empty_option("-- Select --")
column_select.set_option("values", columns)
column_select.set_option("labels", labels)
# only set the value if it is actually in there
if csv_titles[j] in columns:
column_select.set_option("default", csv_titles[j])
column_select.set_persist_on_submit()
column_select_value = column_select.get_value()
display = column_select.get_buffer_display()
td = table.add_cell( display )
if csv_titles[j] not in columns:
td.add(" <b style='color: red'>*</b>")
# new property
new_column_div = DivWdg()
if column_select_value:
new_column_div.add_style("display", "none")
else:
new_column_div.add_style("display", "block")
new_column_div.set_id("new_column_div_%s" % j)
td = table.add_cell( new_column_div )
text = TextWdg("new_column_%s" % j)
text.set_persist_on_submit()
if my.has_title:
text.set_value(csv_titles[j])
new_column_div.add( " ... or ..." )
new_column_div.add( text )
my.num_columns = len(row)
hidden = HiddenWdg("num_columns", my.num_columns)
# need to somehow specify defaults for columns
div.add(table)
div.add("<br/><br/>")
div.add(my.get_preview_wdg())
return div
示例11: get_display
# 需要导入模块: from pyasm.widget import SelectWdg [as 别名]
# 或者: from pyasm.widget.SelectWdg import add_event [as 别名]
def get_display(self):
widget = Widget()
div = DivWdg(css="filter_box")
show_span = SpanWdg(css='med')
show_span.add('Show All Types: ')
checkbox = FilterCheckboxWdg('show_all_types')
checkbox.set_persistence()
show_span.add(checkbox)
show_all_types = checkbox.get_value()
div.add(show_span)
span = SpanWdg(css="med")
span.add("Search Type: ")
select = SelectWdg("filter|search_type")
select.add_empty_option("-- Select --")
project = Project.get()
project_type = project.get_base_type()
search = Search("sthpw/search_object")
if show_all_types:
search.add_where('''
namespace = '%s' or namespace = '%s' or search_type in ('sthpw/task')
''' % (project_type, project.get_code()) )
else:
# show only the custom ones
search.add_filter('namespace', project.get_code() )
search.add_order_by("title")
sobjects = search.get_sobjects()
select.set_sobjects_for_options(sobjects,"search_type", "title")
#select.set_option("query", "sthpw/search_object|search_type|title")
select.set_persistence()
select.add_event("onchange", "document.form.submit()")
search_type = select.get_value()
span.add(select)
div.add(span)
# make sure the current selection exists
try:
SearchType.get(search_type)
except SearchException as e:
return div
except SqlException as e:
return div
# add the view selector
view_select = SelectWdg("view")
view_select.add_empty_option("-- View --")
view_select.add_event("onchange", "document.form.submit()")
view_select.set_persist_on_submit()
#view_select.set_persistence()
span = SpanWdg(css="med")
span.add("Defined Views: ")
span.add(view_select)
div.add(span)
div.add( self.get_create_view_wdg(search_type))
div.add( HtmlElement.br(2) )
div.add( self.get_new_tab_wdg() )
widget.add(div)
search = Search("sthpw/widget_config")
#search.add_user_filter()
search.add_filter("search_type", search_type)
search.add_where("view != 'definition' and view != 'custom'")
#search.add_column("view")
widget_configs = search.get_sobjects()
if widget_configs:
view_select.set_sobjects_for_options(widget_configs,"view","view")
view = view_select.get_value()
if not view:
view = "custom"
#return widget
# get the selected widget config
for widget_config in widget_configs:
if widget_config.get_value("view") == view:
break
else:
return widget
# get the handler: a little HACKY.
config_xml = widget_config.get_xml_value("config")
handler = config_xml.get_value("config/%s/@handler" % view)
if not search_type:
return widget
#.........这里部分代码省略.........