本文整理汇总了Python中pyasm.web.DivWdg.set_unique_id方法的典型用法代码示例。如果您正苦于以下问题:Python DivWdg.set_unique_id方法的具体用法?Python DivWdg.set_unique_id怎么用?Python DivWdg.set_unique_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyasm.web.DivWdg
的用法示例。
在下文中一共展示了DivWdg.set_unique_id方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_async_element_wdg
# 需要导入模块: from pyasm.web import DivWdg [as 别名]
# 或者: from pyasm.web.DivWdg import set_unique_id [as 别名]
def get_async_element_wdg(my, xml, element_name, load):
tmp_config = WidgetConfig.get('tmp', xml=xml)
display_handler = tmp_config.get_display_handler(element_name)
display_options = tmp_config.get_display_options(element_name)
div = DivWdg()
unique_id = div.set_unique_id()
if load == "sequence":
my.sequence_data.append( {
'class_name': display_handler,
'kwargs': display_options,
'unique_id': unique_id
} )
else:
div.add_behavior( {
'type': 'load',
'class_name': display_handler,
'kwargs': display_options,
'cbjs_action': '''
spt.panel.async_load(bvr.src_el, bvr.class_name, bvr.kwargs);
'''
} )
loading_div = DivWdg()
loading_div.add_style("margin: auto auto")
loading_div.add_style("width: 150px")
loading_div.add_style("text-align: center")
loading_div.add_style("padding: 20px")
div.add(loading_div)
loading_div.add('''<img src="/context/icons/common/indicator_snake.gif" border="0"/> <b>Loading ...</b>''')
return div
示例2: get_async_element_wdg
# 需要导入模块: from pyasm.web import DivWdg [as 别名]
# 或者: from pyasm.web.DivWdg import set_unique_id [as 别名]
def get_async_element_wdg(my, xml, element_name, load):
tmp_config = WidgetConfig.get("tmp", xml=xml)
display_handler = tmp_config.get_display_handler(element_name)
display_options = tmp_config.get_display_options(element_name)
div = DivWdg()
unique_id = div.set_unique_id()
if load == "sequence":
my.sequence_data.append({"class_name": display_handler, "kwargs": display_options, "unique_id": unique_id})
else:
div.add_behavior(
{
"type": "load",
"class_name": display_handler,
"kwargs": display_options,
"cbjs_action": """
spt.panel.async_load(bvr.src_el, bvr.class_name, bvr.kwargs);
""",
}
)
loading_div = DivWdg()
loading_div.add_style("margin: auto auto")
loading_div.add_style("width: 150px")
loading_div.add_style("text-align: center")
loading_div.add_style("padding: 20px")
div.add(loading_div)
loading_div.add("""<img src="/context/icons/common/indicator_snake.gif" border="0"/> <b>Loading ...</b>""")
return div
示例3: ProgressWdg
# 需要导入模块: from pyasm.web import DivWdg [as 别名]
# 或者: from pyasm.web.DivWdg import set_unique_id [as 别名]
class ProgressWdg(BaseRefreshWdg):
'''A simple widget which displays the progress and an upload'''
def init(self):
self.progress_div = DivWdg()
self.progress_id = self.progress_div.set_unique_id()
def get_progress_id(self):
return self.progress_id
def get_display(self):
top = self.top
top.add_class("spt_progress_top")
top.add_style("height: 10px")
top.add_style("width: 200px")
top.add_style("overflow: hidden")
top.add_border()
top.add(self.progress_div)
self.progress_div.add_style("width: 0%")
self.progress_div.add_gradient("background", "background2", 20)
self.progress_div.add_style("height: 100%")
self.progress_div.add(" ")
self.progress_div.add('<img height="10px" src="/context/icons/common/indicator_snake.gif" border="0"/>')
return top
示例4: get_display
# 需要导入模块: from pyasm.web import DivWdg [as 别名]
# 或者: from pyasm.web.DivWdg import set_unique_id [as 别名]
def get_display(my):
top = my.top
unity_wdg = DivWdg()
top.add(unity_wdg)
unique_id = unity_wdg.set_unique_id("unity")
unity_wdg.add("Unity content can't be played. Make sure you are using compatible browser with JavaScript enabled.")
#<input id="versionButton" type="button" value="Version" disabled="disabled" onclick="versionButtonClick();" />
# TEST TEST TEST: dynamic loading of js
env = Environment.get()
install_dir = env.get_install_dir()
js_path = "%s/src/context/spt_js/UnityObject.js" % install_dir
f = open(js_path)
init_js = f.read()
f.close()
top.add_behavior( {
'type': 'load',
'cbjs_action': '''
%s;
%s;
''' % (init_js, my.get_load_js(unique_id) )
} )
return top
示例5: get_display
# 需要导入模块: from pyasm.web import DivWdg [as 别名]
# 或者: from pyasm.web.DivWdg import set_unique_id [as 别名]
def get_display(self):
top = self.top
top.add_color("background", "background")
top.add_style("padding: 5px")
top.add_border()
SwapDisplayWdg.handle_top(top)
top.add_relay_behavior( {
'type': 'click',
'bvr_match_class': 'spt_swap_top',
'cbjs_action': '''var top = bvr.src_el;
if (['on', null].contains(top.getAttribute("spt_state")))
spt.alert('clicked open')
'''
} )
for title in ['First', 'Second', 'Third', 'Fourth', 'Fifth', 'Sixth', 'Seventh']:
swap = SwapDisplayWdg(title=title, icon='FILM')
top.add(swap)
swap.set_behavior_top(top)
# handle hover behavior
hover = top.get_color("background", -10)
behavior = {
'type': 'hover',
'bvr_match_class': 'spt_swap_top',
'hover': hover,
'cbjs_action_over': '''bvr.src_el.setStyle('background', bvr.hover)''',
'cbjs_action_out': '''bvr.src_el.setStyle('background', '')''',
}
swap.add_behavior(behavior)
content = DivWdg()
unique_id = content.set_unique_id("content")
swap.set_content_id(unique_id)
content.add("This is content!!!!")
top.add(content)
content.add_style("display: none")
return top
示例6: get_default_wdg
# 需要导入模块: from pyasm.web import DivWdg [as 别名]
# 或者: from pyasm.web.DivWdg import set_unique_id [as 别名]
def get_default_wdg(cls, aliases=[]):
div = DivWdg()
div.set_unique_id()
div.add_style("padding: 5px")
if aliases:
div.add("<b>Related links</b>:<br/><br/>")
titles = [Common.get_display_title(x.replace("-"," ")) for x in aliases]
for alias, title in zip(aliases, titles):
link_div = DivWdg()
div.add(link_div)
link_div.add_color("background", "background")
link_div.add(title)
link_div.add_behavior( {
'type': 'click_up',
'cbjs_action': '''
spt.help.set_top();
spt.help.load_alias("%s");
''' % alias
} )
link_div.add_class("spt_link")
link_div.add_class("hand")
div.add("<br/><br/>")
div.add("<b>Additional useful links</b>:<br/><br/>")
aliases = ['setup', 'end_user', 'developer', 'sys_admin']
titles = ['Project Setup Documentation', 'End User Documentation', 'Developer Documentation', 'System Administrator Documentation']
for alias, title in zip(aliases, titles):
link_div = DivWdg()
div.add(link_div)
link_div.add_color("background", "background")
link_div.add(title)
link_div.add_behavior( {
'type': 'click_up',
'cbjs_action': '''
spt.help.set_top();
spt.help.load_alias("%s");
''' % alias
} )
link_div.add_class("spt_link")
link_div.add_class("hand")
div.add("<br/>")
link_div = DivWdg()
div.add(link_div)
link_div.add("TACTIC Documentation (PDF)")
link_div.add_color("background", "background")
link_div.add_behavior( {
'type': 'click_up',
'cbjs_action': '''
window.open("/doc/", "TACTIC Docs");
'''
} )
link_div.add_class("spt_link")
link_div.add_class("hand")
link_div = DivWdg()
div.add(link_div)
link_div.add_color("background", "background")
link_div.add("TACTIC Community Site")
link_div.add_behavior( {
'type': 'click_up',
'cbjs_action': '''
window.open("http://community.southpawtech.com", "TACTIC Community Site");
'''
} )
link_div.add_class("spt_link")
link_div.add_class("hand")
return div
示例7: get_first_row_wdg
# 需要导入模块: from pyasm.web import DivWdg [as 别名]
# 或者: from pyasm.web.DivWdg import set_unique_id [as 别名]
def get_first_row_wdg(my):
# read the csv file
#my.file_path = ""
div = DivWdg(id='csv_import_main')
div.add_class('spt_panel')
div.add( my.get_upload_wdg() )
if not my.search_type:
return div
if not my.file_path:
return div
if not my.file_path.endswith(".csv"):
div.add('<br>')
div.add( "Uploaded file [%s] is not a csv file. Refreshing in 3 seconds. . ."% os.path.basename(my.file_path))
div.add_behavior( {'type': 'load', \
'cbjs_action': "setTimeout(function() {spt.panel.load('csv_import_main','%s', {}, {\
'search_type_filter': '%s'});}, 3000);" %(Common.get_full_class_name(my), my.search_type) } )
return div
if not os.path.exists(my.file_path):
raise TacticException("Path '%s' does not exist" % my.file_path)
div.add(HtmlElement.br(2))
# NOT NEEDED: clear the widget settings before drawing
#expr = "@SOBJECT(sthpw/wdg_settings['key','EQ','pyasm.widget.input_wdg.CheckboxWdg|column_enabled_']['login','$LOGIN']['project_code','$PROJECT'])"
#sobjs = Search.eval(expr)
#for sobj in sobjs:
# sobj.delete(log=False)
div.add( HtmlElement.b("The following is taken from the first line in the uploaded csv file. Select the appropriate column to match.") )
div.add(HtmlElement.br())
"""
text = HtmlElement.b("Make sure you have all the required columns** in the csv.")
text.add_style('text-align: left')
div.add(text)
"""
div.add(HtmlElement.br(2))
option_div_top = DivWdg()
option_div_top.add_color('color','color')
option_div_top.add_color('background','background', -5)
option_div_top.add_style("padding: 10px")
option_div_top.add_border()
option_div_top.add_style("width: 300px")
swap = SwapDisplayWdg(title="Parsing Options")
option_div_top.add(swap)
option_div_top.add_style("margin-right: 30px")
my.search_type_obj = SearchType.get(my.search_type)
option_div = DivWdg()
swap.set_content_id(option_div.set_unique_id() )
option_div.add_style("display: none")
option_div.add_style('margin-left: 14px')
option_div.add_style('margin-top: 10px')
option_div.add_style("font-weight: bold")
option_div_top.add(option_div)
# first row and second row
#option_div.add( HtmlElement.br() )
option_div.add(SpanWdg("Use Title Row: ", css='small'))
title_row_checkbox = CheckboxWdg("has_title")
title_row_checkbox.set_default_checked()
title_row_checkbox.add_behavior({'type' : 'click_up',
'propagate_evt': 'true',
'cbjs_action': "spt.panel.refresh('preview_data',\
spt.api.Utility.get_input_values('csv_import_main'))"})
option_div.add(title_row_checkbox)
option_div.add( HintWdg("Set this to use the first row as a title row to match up columns in the database") )
option_div.add( HtmlElement.br(2) )
option_div.add(SpanWdg("Use Lowercase Title: ", css='small'))
lower_title_checkbox = CheckboxWdg("lowercase_title")
lower_title_checkbox.add_behavior({'type' : 'click_up',
'propagate_evt': 'true',
'cbjs_action': "spt.panel.refresh('preview_data',\
spt.api.Utility.get_input_values('csv_import_main'))"})
option_div.add(lower_title_checkbox)
option_div.add( HtmlElement.br(2) )
option_div.add(SpanWdg("Sample Data Row: ", css='small'))
data_row_text = SelectWdg("data_row")
data_row_text.set_option('values', '1|2|3|4|5')
data_row_text.set_value('1')
data_row_text.add_behavior({'type' : 'change',
'cbjs_action': "spt.panel.refresh('preview_data',\
#.........这里部分代码省略.........
示例8: get_display
# 需要导入模块: from pyasm.web import DivWdg [as 别名]
# 或者: from pyasm.web.DivWdg import set_unique_id [as 别名]
#.........这里部分代码省略.........
button = ActionButtonWdg(title="Save As", tip="Save template as file")
button.add_style("float: right")
top.add(button)
button.add_behavior( {
'type': 'click_up',
'template_dir': template_dir,
'cbjs_action': '''
var applet = spt.Applet.get();
var dirname = applet.open_file_browser();
if (!dirname) {
return;
}
var class_name = 'tactic.ui.app.ProjectTemplateDownloadCmd';
var kwargs = {
'template_dir': bvr.template_dir
}
var server = TacticServerStub.get();
var ret_val = server.execute_cmd(class_name, kwargs);
var info = ret_val['info'];
var filename = info['filename'];
var env = spt.Environment.get();
var ticket = env.get_ticket();
var server = env.get_server_url();
var url = server + "/assets/_cache/" + ticket + "/" + filename;
applet.download_file(url, dirname + "/" + filename);
applet.open_explorer(dirname);
'''
} )
#button = ActionButtonWdg(title="Dump", tip="Create a template from a project")
#button.add_style("float: right")
#top.add(button)
#button.add_behavior( {
# 'type': 'click_up',
# 'cbjs_action': '''
# '''
#} )
info_div = DivWdg()
top.add(info_div)
info_div.add_style("padding: 20px")
info_div.set_unique_id()
info_div.add_smart_style("spt_none", "font-style", "italic")
info_div.add_smart_style("spt_none", "opacity", "0.5")
#project = Project.get()
# import the transaction data
from tactic.command import PluginInstaller
installer = PluginInstaller(manifest=manifest_xml)
project_path = "%s/%s" % (template_dir, "sthpw_project.spt")
jobs = installer.import_data(project_path, commit=False)
project = jobs[0]
project_code = project.get_code()
info_div.add("<br/>")
info_div.add("Template Code: <b>%s</b><br/>" % project_code)
info_div.add("<br/>")
info_div.add("Title: <b>%s</b><br/>" % project.get_value("title"))
info_div.add("<br/>")
description = project.get_value("description", no_exception=True)
if not description:
description = "<span class='spt_none'>None</span>"
info_div.add("Description: %s<br/>" % description)
info_div.add("<br/>")
version = project.get_value("version", no_exception=True)
if not version:
version = "<span class='spt_none'>None</span>"
info_div.add("Version: %s<br/>" % version)
info_div.add("<br/>")
status = project.get_value("status", no_exception=True)
if not status:
status = "<span class='spt_none'>None</span>"
info_div.add("Status: %s<br/>" % status )
info_div.add("<br/>")
top.add("<span style='opacity: 0.5'>Manifest Path: %s</span>" % manifest_path)
return top
示例9: get_display
# 需要导入模块: from pyasm.web import DivWdg [as 别名]
# 或者: from pyasm.web.DivWdg import set_unique_id [as 别名]
def get_display(self):
# NOTE: need to add this to fit as a table layout
self.chunk_size = 10000
self.edit_permission = True
self.view_editable = True
search_key = self.kwargs.get("search_key")
if search_key:
sobject = Search.get_by_search_key(search_key)
self.sobjects = [sobject]
elif self.kwargs.get("do_search") != "false":
self.handle_search()
top = DivWdg()
self.top = top
self.set_as_panel(top)
top.add_class("spt_sobject_top")
inner = DivWdg()
top.add(inner)
inner.add_color("background", "background")
inner.add_color("color", "color")
# NOTE: this is not the table and is called this for backwards
# compatibility
inner.add_class("spt_table")
inner.add_class("spt_layout")
# set the sobjects to all the widgets then preprocess
for widget in self.widgets:
widget.set_sobjects(self.sobjects)
widget.set_parent_wdg(self)
# preprocess the elements
widget.preprocess()
#is_refresh = self.kwargs.get("is_refresh")
#if self.kwargs.get("show_shelf") not in ['false', False]:
# action = self.get_action_wdg()
# inner.add(action)
# get all the edit widgets
"""
if self.view_editable and self.edit_permission:
edit_wdgs = self.get_edit_wdgs()
edit_div = DivWdg()
edit_div.add_class("spt_edit_top")
edit_div.add_style("display: none")
inner.add(edit_div)
for name, edit_wdg in edit_wdgs.items():
edit_div.add(edit_wdg)
"""
inner.set_unique_id()
inner.add_smart_style("spt_header", "vertical-align", "top")
inner.add_smart_style("spt_header", "text-align", "left")
inner.add_smart_style("spt_header", "width", "150px")
inner.add_smart_style("spt_header", "padding", "5px")
border = inner.get_color("table_border")
#inner.add_smart_style("spt_header", "border", "solid 1px %s" % border)
inner.add_smart_style("spt_cell_edit", "background-repeat", "no-repeat")
inner.add_smart_style("spt_cell_edit", "background-position", "bottom right")
inner.add_smart_style("spt_cell_edit", "padding", "5px")
inner.add_smart_style("spt_cell_edit", "min-width", "200px")
for i, sobject in enumerate(self.sobjects):
table = Table()
table.add_color("color", "color")
table.add_style("padding: 10px")
#table.add_style("margin-bottom: 10px")
table.add_style("width: 100%")
inner.add(table)
for j, widget in enumerate(self.widgets):
name = widget.get_name()
if name == 'preview':
continue
widget.set_current_index(i)
title = widget.get_title()
tr = table.add_row()
if isinstance(title, HtmlElement):
title.add_style("float: left")
th = table.add_header(title)
th.add_class("spt_header")
td = table.add_cell(widget.get_buffer_display())
td.add_class("spt_cell_edit")
if j % 2 == 0:
#.........这里部分代码省略.........
示例10: get_display
# 需要导入模块: from pyasm.web import DivWdg [as 别名]
# 或者: from pyasm.web.DivWdg import set_unique_id [as 别名]
def get_display(self):
top = DivWdg()
top.add_color("background", "background")
top.add_color("color", "color")
top.add_style("min-width: 600px")
os_name = os.name
top.set_unique_id()
top.add_smart_style("spt_info_title", "background", self.top.get_color("background3"))
top.add_smart_style("spt_info_title", "padding", "3px")
top.add_smart_style("spt_info_title", "font-weight", "bold")
# server
title_div = DivWdg()
top.add(title_div)
title_div.add("Server")
title_div.add_class("spt_info_title")
os_div = DivWdg()
top.add(os_div)
os_info = platform.uname()
try:
os_login = os.getlogin()
except Exception:
os_login = os.environ.get("LOGNAME")
table = Table()
table.add_color("color", "color")
table.add_style("margin: 10px")
os_div.add(table)
for i, title in enumerate(['OS','Node Name','Release','Version','Machine']):
table.add_row()
td = table.add_cell("%s: " % title)
td.add_style("width: 150px")
table.add_cell( os_info[i] )
table.add_row()
table.add_cell("CPU Count: ")
try :
import multiprocessing
table.add_cell( multiprocessing.cpu_count() )
except (ImportError, NotImplementedError):
table.add_cell( "n/a" )
table.add_row()
table.add_cell("Login: ")
table.add_cell( os_login )
# python
title_div = DivWdg()
top.add(title_div)
title_div.add("Python")
title_div.add_class("spt_info_title")
table = Table()
table.add_color("color", "color")
table.add_style("margin: 10px")
top.add(table)
table.add_row()
td = table.add_cell("Version: ")
td.add_style("width: 150px")
table.add_cell( sys.version )
# client
title_div = DivWdg()
top.add(title_div)
title_div.add("Client")
title_div.add_class("spt_info_title")
web = WebContainer.get_web()
user_agent = web.get_env("HTTP_USER_AGENT")
table = Table()
table.add_color("color", "color")
table.add_style("margin: 10px")
top.add(table)
table.add_row()
td = table.add_cell("User Agent: ")
td.add_style("width: 150px")
table.add_cell( user_agent )
table.add_row()
td = table.add_cell("TACTIC User: ")
table.add_cell( web.get_user_name() )
top.add('<br/>')
self.handle_load_balancing(top)
#.........这里部分代码省略.........
示例11: get_display
# 需要导入模块: from pyasm.web import DivWdg [as 别名]
# 或者: from pyasm.web.DivWdg import set_unique_id [as 别名]
def get_display(self):
widget = Widget()
div = DivWdg(css='spt_ui_options')
div.set_unique_id()
table = Table()
div.add(table)
table.add_style("margin: 5px 15px")
table.add_color('color','color')
swap = SwapDisplayWdg()
#swap.set_off()
app = WebContainer.get_web().get_selected_app()
outer_span = SpanWdg()
outer_span.add_style('float: right')
span = SpanWdg(app, css='small')
icon = IconWdg(icon=eval("IconWdg.%s"%app.upper()), width='13px')
outer_span.add(span)
outer_span.add(icon)
title = SpanWdg("Loading Options")
title.add(outer_span)
SwapDisplayWdg.create_swap_title(title, swap, div, is_open=False)
widget.add(swap)
widget.add(title)
widget.add(div)
if not self.hide_instantiation:
table.add_row()
table.add_blank_cell()
div = DivWdg(HtmlElement.b("Instantiation: "))
table.add_cell(div)
div = self.get_instantiation_wdg()
table.add_cell(div)
setting = self.get_default_setting()
default_instantiation = setting.get('instantiation')
default_connection = setting.get('connection')
default_dependency = setting.get('texture_dependency')
if not self.hide_connection:
table.add_row()
table.add_blank_cell()
con_div = DivWdg(HtmlElement.b("Connection: "))
table.add_cell(con_div)
td = table.add_cell()
is_unchecked = True
default_cb = None
for value in ['http', 'file system']:
name = self.get_element_name("connection")
checkbox = CheckboxWdg( name )
checkbox.set_option("value", value)
checkbox.set_persistence()
if value == default_connection:
default_cb = checkbox
if checkbox.is_checked():
is_unchecked = False
checkbox.add_behavior({'type': 'click_up',
'propagate_evt': True,
"cbjs_action": "spt.toggle_checkbox(bvr, '.spt_ui_options', '%s')" %name})
span = SpanWdg(checkbox, css='small')
span.add(value)
td.add(span)
if is_unchecked:
default_cb.set_checked()
if not self.hide_dependencies:
table.add_row()
table.add_blank_cell()
div = DivWdg(HtmlElement.b("Texture Dependencies: "))
table.add_cell(div)
td = table.add_cell()
is_unchecked = True
default_cb = None
for value in ['as checked in', 'latest', 'current']:
name = self.get_element_name("dependency")
checkbox = CheckboxWdg( name )
checkbox.set_option("value", value)
checkbox.set_persistence()
checkbox.add_behavior({'type': 'click_up',
'propagate_evt': True,
"cbjs_action": "spt.toggle_checkbox(bvr, '.spt_ui_options', '%s')" %name})
if value == default_dependency:
default_cb = checkbox
if checkbox.is_checked():
is_unchecked = False
span = SpanWdg(checkbox, css='small')
span.add(value)
#.........这里部分代码省略.........