本文整理汇总了Python中pyasm.widget.IconButtonWdg.add_event方法的典型用法代码示例。如果您正苦于以下问题:Python IconButtonWdg.add_event方法的具体用法?Python IconButtonWdg.add_event怎么用?Python IconButtonWdg.add_event使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyasm.widget.IconButtonWdg
的用法示例。
在下文中一共展示了IconButtonWdg.add_event方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_display
# 需要导入模块: from pyasm.widget import IconButtonWdg [as 别名]
# 或者: from pyasm.widget.IconButtonWdg import add_event [as 别名]
def get_display(my):
sobject = my.get_current_sobject()
widget_class = my.get_option("class")
if widget_class == '':
raise WidgetException("No widget class defined")
url = WebContainer.get_web().get_widget_url()
url.set_option("widget", widget_class)
url.set_option("search_key", sobject.get_search_key())
ref = url.get_url()
iframe = Container.get("iframe")
iframe.set_width(90)
action = iframe.get_on_script(ref)
info_type = my.get_option("info_type")
button = IconButtonWdg("%s info" % info_type, IconWdg.INFO)
button.add_event("onclick", "%s" % (action) )
button.add_style("margin: 3px 5px")
return button
示例2: get_display
# 需要导入模块: from pyasm.widget import IconButtonWdg [as 别名]
# 或者: from pyasm.widget.IconButtonWdg import add_event [as 别名]
def get_display(my):
widget = Widget()
thumb = super(ThumbPublishWdg, my).get_display()
widget.add(thumb)
sobject = my.get_current_sobject()
search_type = sobject.get_search_type()
search_id = sobject.get_id()
publish_link = PublishLinkWdg(search_type,search_id)
div = DivWdg(publish_link)
div.set_style('clear: left; padding-top: 6px')
widget.add(div)
# build an iframe to show publish browsing
browse_link = IconButtonWdg("Publish Browser", IconWdg.CONTENTS)
iframe = WebContainer.get_iframe()
iframe.set_width(100)
url = WebContainer.get_web().get_widget_url()
url.set_option("widget", "pyasm.prod.web.PublishBrowserWdg")
url.set_option("search_type", search_type)
url.set_option("search_id", search_id)
script = iframe.get_on_script(url.to_string())
browse_link.add_event("onclick", script)
div.add(browse_link)
div.set_style('padding-top: 6px')
return widget
示例3: get_display
# 需要导入模块: from pyasm.widget import IconButtonWdg [as 别名]
# 或者: from pyasm.widget.IconButtonWdg import add_event [as 别名]
def get_display(my):
web = WebContainer.get_web()
if not my.view:
view = web.get_form_value("filter|view")
# create popup
create_popup = PopupWdg("create_action")
create_popup.set_auto_hide(False)
create_popup.add("Enter name of view: ")
create_popup.add(TextWdg("create_view_name"))
# create_popup.add( HtmlElement.br(2) )
# create_popup.add( "Copy from template: " )
# template_select = SelectWdg("copy_from_template")
# template_select.add_empty_option("-- None --")
# template_select.set_option("values", "list|summary|task")
# create_popup.add( template_select )
create_popup.add(HtmlElement.br(2, clear="all"))
from pyasm.prod.web import ProdIconButtonWdg, ProdIconSubmitWdg
create_icon = ProdIconButtonWdg("Create")
ajax = AjaxCmd()
ajax.register_cmd("pyasm.widget.CustomCreateViewCbk")
ajax.add_element_name("create_view_name")
ajax.add_element_name("auto_create_edit")
ajax.set_option("search_type", my.search_type)
ajax.set_option("project", Project.get_project_code())
if my.view:
ajax.set_option("template_view", my.view)
create_icon.add_event(
"onclick",
"%s;%s"
% (ajax.get_on_script(), "toggle_display('create_action');setTimeout('document.form.submit()',1000)"),
)
cancel_icon = ProdIconButtonWdg("Cancel")
cancel_icon.add_event("onclick", "toggle_display('create_action')")
span = SpanWdg()
span.add(create_icon)
span.add(cancel_icon)
create_popup.add(span)
create_popup.add(HtmlElement.br())
# add the create button
create = IconButtonWdg("Create View", IconWdg.SAVE, True)
create.add_event("onclick", "%s" % create_popup.get_on_script())
# lay it all out
widget = Widget()
widget.add(create_popup)
# Browser does not have create
# widget.add(create)
return widget
示例4: init
# 需要导入模块: from pyasm.widget import IconButtonWdg [as 别名]
# 或者: from pyasm.widget.IconButtonWdg import add_event [as 别名]
def init(my):
my.layer = LayerWdg(my.xpos, my.ypos, my.display)
if not my.width:
my.shadowbox = ShadowBoxWdg(my.shad_name)
else:
my.shadowbox = ShadowBoxWdg(my.shad_name, my.width)
# do not enable it for the Login page
web = WebContainer.get_web()
if my.shad_name and not web.is_IE():
BaseAppServer.add_onload_script("Move.drag('%s','%s')" \
%(my.shadowbox.get_name(), my.iframe_name))
div = DivWdg()
from pyasm.widget import IconButtonWdg
move_button = IconWdg(name='move me', icon=IconWdg.NAV)
move_button.set_id("%s_handle" % (my.shad_name))
move_button.add_class('move')
move_button.add_style('float: left')
move_button.add_style('padding: 2px 0 0 6px')
if not web.is_IE():
div.add(move_button)
mbutton = IconButtonWdg(name='close window', icon=IconWdg.KILL)
mbutton.set_class("moduleKillBtn")
mbutton.add_event("onclick", my.layer.get_off_script() )
div.add(mbutton)
if my.nav_links:
back_link = HtmlElement.href("<<", "javascript:history.back()")
back_link.add_style("font-size", "1.4em")
for_link = HtmlElement.href(">>", "javascript:history.forward()")
for_link.add_style("font-size", "1.4em")
div.add(SpanWdg(back_link, css='med'))
div.add(SpanWdg(for_link, css='med'))
my.shadowbox.set_header(div)
# add button and title_wdg to shadow box
if my.title_wdg:
title_wdg = DivWdg()
title_wdg.set_class("moduleTitle")
title_wdg.add(my.title_wdg)
my.shadowbox.set_title_wdg(title_wdg)
my.layer.add(my.shadowbox)
my._add_widget(my.layer)
示例5: get_create_view_wdg
# 需要导入模块: from pyasm.widget import IconButtonWdg [as 别名]
# 或者: from pyasm.widget.IconButtonWdg import add_event [as 别名]
def get_create_view_wdg(my, search_type):
# create popup
create_popup = PopupWdg("create_action")
create_popup.set_auto_hide(False)
create_popup.add("Enter name of view: ")
create_popup.add(TextWdg("create_view_name"))
# create_popup.add( HtmlElement.br(2) )
# create_popup.add( "Copy from template: " )
# template_select = SelectWdg("copy_from_template")
# template_select.add_empty_option("-- None --")
# template_select.set_option("values", "list|summary|task")
# create_popup.add( template_select )
create_popup.add(HtmlElement.br(2))
create_popup.add(CheckboxWdg("auto_create_edit", label="Auto Create Edit View"))
create_popup.add(HtmlElement.br(2, clear="all"))
from pyasm.prod.web import ProdIconButtonWdg, ProdIconSubmitWdg
create_icon = ProdIconButtonWdg("Create")
ajax = AjaxCmd()
ajax.register_cmd("pyasm.widget.CustomCreateViewCbk")
ajax.add_element_name("create_view_name")
ajax.add_element_name("auto_create_edit")
ajax.set_option("search_type", search_type)
ajax.set_option("project", Project.get_project_code())
div = ajax.generate_div()
div.set_post_ajax_script("document.form.submit()")
create_icon.add_event("onclick", "%s;%s" % (ajax.get_on_script(), "toggle_display('create_action')"))
cancel_icon = ProdIconButtonWdg("Cancel")
cancel_icon.add_event("onclick", "toggle_display('create_action')")
span = SpanWdg()
span.add(create_icon)
span.add(cancel_icon)
create_popup.add(span)
create_popup.add(HtmlElement.br())
# add the create button
create = IconButtonWdg("Create View", IconWdg.SAVE, True)
create.add_event("onclick", "%s" % create_popup.get_on_script())
# lay it all out
widget = Widget()
widget.add(create_popup)
widget.add(create)
widget.add(div)
return widget
示例6: get_display
# 需要导入模块: from pyasm.widget import IconButtonWdg [as 别名]
# 或者: from pyasm.widget.IconButtonWdg import add_event [as 别名]
def get_display(my):
# add the add property button
iframe = WebContainer.get_iframe()
url = WebContainer.get_web().get_widget_url()
url.set_option("widget", "pyasm.widget.CustomAddPropertyWdg")
url.set_option("search_type", my.search_type)
url.set_option("view", my.view)
action = iframe.get_on_script(url.to_string() )
add = IconButtonWdg("Add Property", IconWdg.INSERT, True)
add.add_event("oncontextmenu", "%s;return false" % action )
add.add_event("onclick", "%s" % action )
widget = Widget()
widget.add(add)
return widget
示例7: get_display
# 需要导入模块: from pyasm.widget import IconButtonWdg [as 别名]
# 或者: from pyasm.widget.IconButtonWdg import add_event [as 别名]
def get_display(my):
sobject = my.get_current_sobject()
url = WebContainer.get_web().get_widget_url()
url.set_option("widget", my.get_annotate_wdg_class() )
url.set_option("search_type", sobject.get_search_type() )
url.set_option("search_id", sobject.get_id() )
button = IconButtonWdg("Annotate", IconWdg.DETAILS, False)
button.add_event("onclick", \
"document.location='%s'" % url.to_string() )
widget = Widget()
widget.add(button)
return widget
示例8: get_open_wdg
# 需要导入模块: from pyasm.widget import IconButtonWdg [as 别名]
# 或者: from pyasm.widget.IconButtonWdg import add_event [as 别名]
def get_open_wdg( sobject, file_type=None):
''' given a snapshot. open the sandbox in explorer '''
span = SpanWdg()
# explore button
dir = sobject.get_client_lib_dir(file_type=file_type)
open_button = IconButtonWdg( "Explore: %s" % dir, IconWdg.LOAD, False)
open_button.add_event("onclick", "Applet.open_explorer('%s')" % dir)
open_button.add_class('small')
span.add(open_button)
#dir = sobject.get_sandbox_dir()
#copy_button = IconButtonWdg( "Copy to sandbox: %s" % dir, IconWdg.DOWNLOAD, False)
#span.add(copy_button)
return span
示例9: _add_publish_link
# 需要导入模块: from pyasm.widget import IconButtonWdg [as 别名]
# 或者: from pyasm.widget.IconButtonWdg import add_event [as 别名]
def _add_publish_link(self, main_div):
publish_link = PublishLinkWdg(self.sobject.get_search_type(), self.sobject.get_id())
div = DivWdg(publish_link)
div.add_style('padding-top','5px')
main_div.add(div)
# build an iframe to show publish browsing
search_type = self.sobject.get_search_type()
search_id = self.sobject.get_id()
from pyasm.widget import IconButtonWdg, IconWdg
browse_link = IconButtonWdg("Publish Browser", IconWdg.CONTENTS)
iframe = WebContainer.get_iframe()
iframe.set_width(100)
url = WebContainer.get_web().get_widget_url()
url.set_option("widget", "pyasm.prod.web.PublishBrowserWdg")
url.set_option("search_type", search_type)
url.set_option("search_id", search_id)
script = iframe.get_on_script(url.to_string())
browse_link.add_event("onclick", script)
div.add(browse_link)
div.set_style('padding-top: 6px')
示例10: get_display
# 需要导入模块: from pyasm.widget import IconButtonWdg [as 别名]
# 或者: from pyasm.widget.IconButtonWdg import add_event [as 别名]
def get_display(my):
web = WebContainer.get_web()
naming_util = NamingUtil()
if not my.widget_name:
my.widget_name = my.get_name()
# get the sobject required by this input
sobject = my.get_current_sobject()
if not sobject:
sobject = Search.get_by_id(my.search_type, my.search_id)
if my.new_sample_name:
my.new_sample_name.replace("//", "/")
else:
my.new_sample_name = sobject.get_value(my.widget_name)
widget = DivWdg()
widget.set_id("naming")
widget.add_style("display: block")
# set the sample text
div = DivWdg()
div.add("Sample name: <i>%s</i>" % my.new_sample_name)
div.add(HtmlElement.br(2))
new_sample_wdg = ProdIconButtonWdg("Set New Sample")
new_sample_wdg.add_event("onclick", "toggle_display('generate')")
div.add(new_sample_wdg)
generate = DivWdg()
generate.add(HtmlElement.br())
generate.set_id("generate")
generate.add_style("display: none")
sample_text = TextWdg("new_sample_name")
sample_text.set_option("size", "30")
# sample_text.set_persist_on_submit()
# if my.new_sample_name:
# sample_text.set_value(my.new_sample_name)
generate.add(sample_text)
button = IconButtonWdg("Generate", IconWdg.REFRESH, long=True)
on_script = my.setup_ajax("naming")
button.add_event("onclick", on_script)
generate.add(button)
generate.add(HtmlElement.br(2))
div.add(generate)
widget.add(div)
hidden = TextWdg(my.widget_name)
value = my.naming
hidden.set_value(my.new_sample_name)
widget.add(my.widget_name)
widget.add(hidden)
# get all of the parts
# TODO: not sure if this should be dictated by the sample name
# break up the name into parts
import re
if my.new_sample_name:
tmp = my.new_sample_name.strip("/")
parts = re.split("[\\/._]", tmp)
print "parts: ", parts
else:
return widget
# if there is a naming, then populate that
if my.edit_search_type:
options = naming_util.get_options(my.edit_search_type)
else:
options = naming_util.get_options(sobject.get_value("search_type"))
table = Table()
type_values = []
padding_values = []
for idx, part in enumerate(parts):
table.add_row()
table.add_cell(part)
type_select = SelectWdg("type_%s" % idx)
type_select.add_empty_option("-- Explicit --")
type_select.set_persist_on_submit()
type_select.set_option("values", "|".join(options))
type_values.append(type_select.get_value())
td = table.add_cell(type_select)
widget.add(table)
return widget
示例11: get_display
# 需要导入模块: from pyasm.widget import IconButtonWdg [as 别名]
# 或者: from pyasm.widget.IconButtonWdg import add_event [as 别名]
def get_display(my):
web = WebContainer.get_web()
widget = DivWdg()
widget.add_class("spt_search_limit_top")
#widget.add_style("border", "solid 1px blue")
widget.add_color("background", "background")
widget.add_color("color", "color")
widget.add_style("padding: 5px")
hidden = HiddenWdg("prefix", my.prefix)
widget.add(hidden)
if not my.search and not my.sobjects:
widget.add("No search or sobjects found")
return widget
# my.count should have been set in alter_search()
# which can be called explicitly thru this instance, my.
if not my.count:
my.count = my.search.get_count(no_exception=True)
# if my.sobjects exist thru inheriting from parent widgets
# or explicitly set, (this is not mandatory though)
if my.sobjects and len(my.sobjects) < my.search_limit:
limit = len(my.sobjects)
elif my.search and my.count < my.search_limit:
# this is only true if the total result of the search is
# less than the limit and so this wdg will not display
limit = my.count
else:
limit = my.search_limit
if not limit:
limit = 50
my.search_limit = limit
if my.refresh:
prev = SpanWdg( IconButtonWdg("Prev", IconWdg.LEFT, False ) )
prev.add_style("margin-left: 8px")
prev.add_style("margin-right: 6px")
prev.add_style("margin-top: -2px")
next = IconButtonWdg("Next", IconWdg.RIGHT, False, icon_pos="right" )
next.add_style("margin-left: 6px")
prev.add_behavior( {
'type': 'click_up',
'cbjs_action': my.refresh_script
} )
next.add_behavior( {
'type': 'click_up',
'cbjs_action': my.refresh_script
} )
else: # the old code pre 2.5
prev = IconButtonWdg("Prev", IconWdg.LEFT, False )
hidden_name = my.prev_hidden_name
hidden = HiddenWdg(hidden_name,"")
prev.add(hidden)
prev.add_event('onclick'," spt.api.Utility.get_input(document,'%s').value ='Prev';%s"\
%(hidden_name, my.refresh_script))
next = IconButtonWdg("Next", IconWdg.RIGHT, False, icon_pos="right" )
hidden_name = my.next_hidden_name
hidden = HiddenWdg(hidden_name,"")
next.add(hidden)
next.add_event('onclick',"spt.api.Utility.get_input(document,'%s').value ='Next';%s" \
%(hidden_name, my.refresh_script))
showing_wdg = DivWdg()
widget.add(showing_wdg)
showing_wdg.add_style("padding: 10px")
showing_wdg.add_style("margin: 10px")
showing_wdg.add_color("background", "background", -5)
showing_wdg.add_border()
label_span = SpanWdg("Showing: ")
showing_wdg.add(label_span)
showing_wdg.add( prev )
# this min calculation is used so that if my.sobjects is not set
# above for the calculation of the limit, which will make the last
# set of range numbers too big
left_bound = my.current_offset+1
if not limit:
# prevent error in ItemsNavigatorWdg if a search encounters query error
limit = 50
my.search_limit = limit
right_bound = min(my.current_offset+limit, my.count)
if left_bound > right_bound:
left_bound = 1
current_value = "%d - %d" % (left_bound, right_bound)
if my.style == my.SIMPLE:
showing_wdg.add( current_value )
#.........这里部分代码省略.........
示例12: init
# 需要导入模块: from pyasm.widget import IconButtonWdg [as 别名]
# 或者: from pyasm.widget.IconButtonWdg import add_event [as 别名]
def init(my):
WebContainer.register_cmd("pyasm.widget.AnnotateCbk")
sobject = my.get_current_sobject()
if not sobject:
if not my.__dict__.has_key("search_type"):
web = WebContainer.get_web()
my.search_type = web.get_form_value("search_type")
my.search_id = web.get_form_value("search_id")
if not my.search_type:
my.add("No search type")
return
search = Search(my.search_type)
search.add_id_filter(my.search_id)
sobject = search.get_sobject()
snapshot = Snapshot.get_latest_by_sobject(sobject)
# TODO:
# this is a bit klunky
snapshot_xml = snapshot.get_xml_value("snapshot")
file_code = snapshot_xml.get_value("snapshot/file[@type='web']/@file_code")
file = File.get_by_code(file_code)
web_dir = snapshot.get_web_dir()
path = "%s/%s" % (web_dir, file.get_full_file_name() )
# add the annotate js object
script = HtmlElement.script("annotate = new Annotate()")
my.add(script)
# add the image
my.add("<h3>Image Annotations</h3>")
width = 600
img = HtmlElement.img(path)
img.add_style("position: absolute")
img.set_id("annotate_image")
img.add_style("left: 0px")
img.add_style("top: 0px")
img.add_style("opacity: 1.0")
img.add_style("z-index: 1")
img.add_style("width", width)
img.add_event("onmouseup", "annotate.add_new(event)")
my.add(img)
# test
version = snapshot.get_value("version")
if version != 1:
last_version = version - 1
snapshot = Snapshot.get_by_version( \
my.search_type, my.search_id, version=last_version )
snapshot_xml = snapshot.get_xml_value("snapshot")
file_code = snapshot_xml.get_value("snapshot/file[@type='web']/@file_code")
file = File.get_by_code(file_code)
web_dir = snapshot.get_web_dir()
path = "%s/%s" % (web_dir, file.get_full_file_name() )
img = HtmlElement.img(path)
img.set_id("annotate_image_alt")
img.add_style("position: absolute")
img.add_style("left: 0px")
img.add_style("top: 0px")
img.add_style("opacity: 1.0")
img.add_style("z-index: 0")
img.add_style("width", width)
img.add_event("onmouseup", "annotate.add_new(event)")
my.add(img)
#script = HtmlElement.script("align_element('%s','%s')" % \
# ("annotate_image", "annotate_image_alt") )
#my.add(script)
div = DivWdg()
div.add_style("position: absolute")
div.add_style("left: 620")
div.add_style("top: 300")
my.add(div)
button = IconButtonWdg("Switch", IconWdg.REFRESH, True)
button.add_event("onclick", "annotate.switch_alt()")
div.add(button)
button = IconButtonWdg("Opacity", IconWdg.LOAD, True)
button.add_event("onclick", "annotate.set_opacity()")
div.add(button)
#.........这里部分代码省略.........
示例13: get_preview_wdg
# 需要导入模块: from pyasm.widget import IconButtonWdg [as 别名]
# 或者: from pyasm.widget.IconButtonWdg import add_event [as 别名]
def get_preview_wdg(my):
widget = Widget()
web = WebContainer.get_web()
csv_parser = CsvParser(my.file_path)
csv_parser.parse()
csv_titles = csv_parser.get_titles()
csv_data = csv_parser.get_data()
ajax = AjaxCmd()
ajax.set_option("search_type", my.search_type)
ajax.set_option("file_path", my.file_path)
ajax.add_element_name("has_title")
event = WebContainer.get_event_container()
caller = event.get_event_caller(SiteMenuWdg.EVENT_ID)
div = ajax.generate_div()
div.set_post_ajax_script(caller)
widget.add(div)
columns = []
num_columns = len(csv_titles)
ajax.set_option("num_columns", num_columns)
for i in range(0, num_columns):
column = web.get_form_value("column_%s" % i)
if column:
column = csv_titles[i]
else:
column = web.get_form_value("column_new_%s" % i)
columns.append(column)
ajax.add_element_name("column_%s" % i)
ajax.add_element_name("new_column_%s" % i)
ajax.register_cmd("pyasm.command.csv_import_cmd.CsvImportCmd")
import_button = IconButtonWdg("Import", IconWdg.REFRESH, True)
import_button.add_event("onclick", ajax.get_on_script(show_progress=False))
import_button.add_style("float: right")
widget.add( import_button )
preview_submit = IconSubmitWdg("Preview", IconWdg.REFRESH, True)
preview_submit.add_style("float: right")
widget.add(preview_submit)
sobject_title = my.search_type_obj.get_title()
widget.add("<p>4. Import</p>")
widget.add(HtmlElement.br())
widget.add("<p>The following table will be imported into %s (Showing Max: 100)</p>" % sobject_title)
table = Table(css="table")
table.add_style("width: 100%")
table.add_row()
for i, title in enumerate(columns):
if not title:
title = "<b style='color:red'>*</b>"
table.add_header(title)
for i, row in enumerate(csv_data):
if i > 100:
break
table.add_row()
for j, cell in enumerate(row):
table.add_cell(cell)
widget.add(table)
return widget