本文整理汇总了Python中pyasm.widget.IconButtonWdg类的典型用法代码示例。如果您正苦于以下问题:Python IconButtonWdg类的具体用法?Python IconButtonWdg怎么用?Python IconButtonWdg使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了IconButtonWdg类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_display
def get_display(my):
div = DivWdg()
sobject = my.get_current_sobject()
search_key = SearchKey.get_by_sobject(sobject)
if sobject.is_admin():
return "ADMIN"
icon = IconButtonWdg("Global Permissions", IconWdg.EDIT)
icon.add_behavior( {
"type": "click_up",
"cbjs_action": "spt.popup.get_widget(evt, bvr)",
"options": {
"class_name": "tactic.ui.panel.SecurityManagerWdg",
"title": "Permisssion Manager",
"popup_id": "Permission Manager"
},
"args": {
"search_key": search_key
}
} )
div.add(icon)
return div
示例2: get_display
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
示例3: get_display
def get_display(my):
my.view = my.kwargs.get('view')
if not my.view:
my.view = 'publish'
widget = Widget()
sobject = my.get_current_sobject()
search_type = sobject.get_search_type()
search_id = sobject.get_id()
if my.get_option('preview') != 'false':
my.thumb.set_current_index(my.get_current_index())
widget.add(my.thumb)
publish_link = PublishLinkWdg(search_type,search_id, config_base=my.view)
div = DivWdg(publish_link)
div.set_style('clear: left; padding-top: 6px')
widget.add(div)
# build a popup link to show publish browsing
browse_link = IconButtonWdg("Publish Browser", IconWdg.CONTENTS)
browse_link.add_behavior({'type': 'click_up',
'cbjs_action': 'spt.popup.get_widget(evt, bvr)',
'options': {'popup_id' : 'publish_browser',
'class_name' : 'pyasm.prod.web.PublishBrowserWdg' ,
'title': 'Publish Browser'},
'args' : { 'search_type': search_type,
'search_id' : search_id }
})
div.add(browse_link)
div.set_style('padding-top: 6px')
return widget
示例4: get_display
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
示例5: get_display
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
示例6: init
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)
示例7: get_create_view_wdg
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
示例8: get_display
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
示例9: get_display
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
示例10: get_open_wdg
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
示例11: get_values_script
def get_values_script(self):
save_button = IconButtonWdg("Save Settings", IconWdg.SAVE)
save_button.add_behavior( {
'type': 'click_up',
'cbjs_action': '''
get_values = function() {
var top = bvr.src_el.getParent(".spt_list_top");
var elements = bvr.src_el.getElements(".spt_list_items");
var data = [];
for (var i=0; i<elements.length; i++) {
var values = spt.api.get_input_values(elements[i]);
data.push(values)
}
return data;
}
'''
} )
content_div.add(save_button)
示例12: _add_publish_link
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')
示例13: get_display
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
示例14: get_display
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 )
#.........这里部分代码省略.........
示例15: get_display
def get_display(my):
my.set_option('icon', "CONTENTS")
sobject = my.get_current_sobject()
search_type = sobject.get_search_type()
context = my.get_option("context")
if not context:
context = "publish"
process = my.get_option("process")
if not process:
process = "publish"
if sobject.get_base_search_type() == "sthpw/snapshot":
snapshot = sobject
sobject = snapshot.get_parent()
if sobject:
search_type = sobject.get_search_type()
else:
top = DivWdg()
return top
else:
if process:
snapshot = Snapshot.get_latest_by_sobject(sobject, process=process)
else:
snapshot = Snapshot.get_latest_by_sobject(sobject, context=context)
if not snapshot:
top = DivWdg()
return top
top = DivWdg()
icon = IconButtonWdg( "Show Metadata", eval( "IconWdg.%s" % my.get_option('icon') ) )
top.add(icon)
top.add_style("text-align: center")
lib_path = snapshot.get_lib_path_by_type("main")
basename = os.path.basename(lib_path)
dirname = os.path.dirname(lib_path)
my.behavior['basename'] = basename
my.behavior['dirname'] = dirname
my.behavior['search_type'] = search_type
cbjs_action = '''
var class_name = 'tactic.ui.tools.repo_browser_wdg.RepoBrowserContentWdg';
var kwargs = {
basename: '%(basename)s',
dirname: '%(dirname)s',
search_type: '%(search_type)s'
};
//spt.tab.set_main_body_tab();
//spt.tab.add_new("Detail", "Detail", class_name, kwargs);
spt.panel.load_popup("Detail", class_name, kwargs);
''' % (my.behavior)
my.behavior['type'] = 'click_up'
my.behavior['cbjs_action'] = cbjs_action
icon.add_behavior(my.behavior)
return top