本文整理汇总了Python中pyasm.widget.HiddenWdg.add_class方法的典型用法代码示例。如果您正苦于以下问题:Python HiddenWdg.add_class方法的具体用法?Python HiddenWdg.add_class怎么用?Python HiddenWdg.add_class使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyasm.widget.HiddenWdg
的用法示例。
在下文中一共展示了HiddenWdg.add_class方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_info_wdg
# 需要导入模块: from pyasm.widget import HiddenWdg [as 别名]
# 或者: from pyasm.widget.HiddenWdg import add_class [as 别名]
def get_info_wdg(my):
widget = Widget()
context_input = HiddenWdg("%s|context" % my.get_input_name(), my.context)
context_input.add_class('spt_upload_context')
widget.add(context_input)
# override the column
column = my.get_option("column")
if column != "":
column_input = HiddenWdg("%s|column" % my.get_input_name(), column)
widget.add(column_input)
return widget
示例2: get_display
# 需要导入模块: from pyasm.widget import HiddenWdg [as 别名]
# 或者: from pyasm.widget.HiddenWdg import add_class [as 别名]
def get_display(my):
top = DivWdg()
top.add_color("color", "color")
#top.add_color("background", "background")
top.add_class("spt_simple_upload_top")
top.add(my.browse)
hidden = HiddenWdg( "%s|path" % my.get_input_name() )
hidden.add_class("spt_upload_hidden")
top.add(hidden)
# this can be used for some other transaction that picks up this file to checkin
hidden = HiddenWdg( "%s|ticket" % my.get_input_name() )
hidden.add_class("spt_upload_ticket")
top.add(hidden)
# if not specified, get the sobject's icon context
my.context = my.kwargs.get("context")
if not my.context:
current = my.get_current_sobject()
if current:
my.context = current.get_icon_context()
else:
from pyasm.biz import Snapshot
my.context = Snapshot.get_default_context()
top.add_attr("spt_context", my.context)
top.add( my.get_info_wdg() )
files_div = DivWdg()
top.add(files_div)
files_div.add_class("spt_upload_files")
files_div.add_style("font-size: 11px")
files_div.add_style("margin-top: 10px")
my.add_action()
return top
示例3: get_display
# 需要导入模块: from pyasm.widget import HiddenWdg [as 别名]
# 或者: from pyasm.widget.HiddenWdg import add_class [as 别名]
def get_display(my):
relative_dir = my.kwargs.get("relative_dir")
my.relative_dir = relative_dir
div = DivWdg()
div.add_class("spt_ingest_top")
div.add_style("width: 100%px")
div.add_style("min-width: 500px")
div.add_style("padding: 20px")
div.add_color("background", "background")
title_div = DivWdg()
div.add(title_div)
title_div.add("Ingest Files")
title_div.add_style("font-size: 14px")
title_div.add_style("font-weight: bold")
title_div.add_style("padding: 10px")
title_div.add_color("background", "background3")
title_div.add_border()
my.search_type = my.kwargs.get("search_type")
if not my.search_type:
div.add("No search type specfied")
return div
if relative_dir:
folder_div = DivWdg()
div.add(folder_div)
folder_div.add("Folder: %s" % relative_dir)
folder_div.add_style("opacity: 0.5")
folder_div.add_style("font-style: italic")
folder_div.add_style("margin-bottom: 10px")
title_div.add_style("margin: -20px -21px 5px -21px")
else:
title_div.add_style("margin: -20px -21px 15px -21px")
div.add("Add files or drag/drop files to be uploaded and ingested:")
div.add("<br/>"*2)
data_div = my.get_data_wdg()
data_div.add_style("float: left")
data_div.add_style("float: left")
div.add(data_div)
# create the help button
help_button_wdg = DivWdg()
div.add(help_button_wdg)
help_button_wdg.add_style("margin-top: -3px")
help_button_wdg.add_style("float: right")
help_button = ActionButtonWdg(title="?", tip="Ingestion Widget Help", size='s')
help_button_wdg.add(help_button)
help_button.add_behavior( {
'type': 'click_up',
'cbjs_action': '''spt.help.load_alias("ingestion_widget")'''
} )
from tactic.ui.input import Html5UploadWdg
upload = Html5UploadWdg(multiple=True)
div.add(upload)
button = ActionButtonWdg(title="Add")
button.add_style("float: right")
button.add_style("margin-top: -3px")
div.add(button)
button.add_behavior( {
'type': 'click_up',
'cbjs_action': '''
var top = bvr.src_el.getParent(".spt_ingest_top");
var files_el = top.getElement(".spt_upload_files");
var onchange = function (evt) {
var files = spt.html5upload.get_files();
for (var i = 0; i < files.length; i++) {
spt.drag.show_file(files[i], files_el, 0, true);
}
}
spt.html5upload.set_form( top );
spt.html5upload.select_file( onchange );
'''
} )
button = ActionButtonWdg(title="Clear")
button.add_style("float: right")
button.add_style("margin-top: -3px")
div.add(button)
button.add_behavior( {
'type': 'click_up',
#.........这里部分代码省略.........
示例4: get_display
# 需要导入模块: from pyasm.widget import HiddenWdg [as 别名]
# 或者: from pyasm.widget.HiddenWdg import add_class [as 别名]
def get_display(self):
top = DivWdg()
top.add_class("ad_input_top")
name = self.get_name()
text = TextWdg(self.get_input_name())
# get the login
sobject = self.get_current_sobject()
client = sobject.get_value("contact_name")
print "client: ", client
if client:
login_sobj = Login.get_by_code(client)
else:
login_sobj = Environment.get_login()
# build the display_name
login = login_sobj.get_value("login")
display_name = login_sobj.get_value("display_name")
if not display_name:
display_name = "%s %s" % (user.get('first_name'), user.get('last_name'))
display_name = display_name.replace('"', "'")
print "login: ", login
hidden = HiddenWdg(self.get_input_name())
hidden.set_options( self.options.copy() )
hidden.add_class("spt_ad_input")
if login:
hidden.set_value(login)
top.add(hidden)
# copy over some options
#text.set_options( self.options.copy() )
if login:
text.set_value(display_name)
text.set_option("read_only", "true")
text.add_class("spt_ad_display")
top.add(text)
top.add(" ")
groups_str = self.get_option("groups_allowed_to_search")
if groups_str:
stmt = 'groups_list = %s' % groups_str
exec stmt
else:
groups_list = None
allow_search = True
if groups_list:
allow_search = False
login_in_group_list = Search.eval("@SOBJECT(sthpw/login_in_group['login','=','%s'])" % login)
for login_in_group in login_in_group_list:
group = login_in_group.get_value("login_group")
if group in groups_list:
allow_search = True
break
if login == 'admin':
allow_search = True
if allow_search:
button = IconButtonWdg('Search for User', IconWdg.USER)
#button = ButtonWdg()
button.add_behavior( {
'type': 'click_up',
'cbjs_action': '''
var top = bvr.src_el.getParent('.ad_input_top');
var content = top.getElement('.ad_input_content');
spt.toggle_show_hide(content);
'''
} )
top.add(button)
ad_top = DivWdg()
ad_top.add_class("ad_input_content")
ad_top.add_style("display: none")
ad_top.add_style("position: absolute")
ad_top.add_style("background: #222")
ad_top.add_style("min-width: 300px")
ad_top.add_style("border: solid 1px #000")
ad_top.add_style("padding: 20px")
cbjs_action = '''
var value = bvr.src_el.getAttribute('spt_input_value');
var display_value = bvr.src_el.getAttribute('spt_display_value');
var phone_number = bvr.src_el.getAttribute('spt_phone_number');
var email = bvr.src_el.getAttribute('spt_mail');
var top = bvr.src_el.getParent('.ad_input_top');
#.........这里部分代码省略.........
示例5: get_display
# 需要导入模块: from pyasm.widget import HiddenWdg [as 别名]
# 或者: from pyasm.widget.HiddenWdg import add_class [as 别名]
def get_display(my):
my.sobject = my.kwargs.get("sobject")
search_key = my.sobject.get_search_key()
top = DivWdg()
top.add_class("spt_checkin_publish")
top.add_style("padding: 10px")
margin_top = '60px'
top.add_style("margin-top", margin_top)
top.add_style("position: relative")
current_changelist = WidgetSettings.get_value_by_key("current_changelist")
current_branch = WidgetSettings.get_value_by_key("current_branch")
current_workspace = WidgetSettings.get_value_by_key("current_workspace")
top.add("Branch: %s<br/>" % current_branch)
top.add("Changelist: %s<br/>" % current_changelist)
top.add("Workspace: %s<br/>" % current_workspace)
top.add("<br/>")
checked_out_div = DivWdg()
checkbox = CheckboxWdg("editable")
top.add(checked_out_div)
checkbox.add_class("spt_checkin_editable")
checked_out_div.add(checkbox)
checked_out_div.add("Leave files editable")
top.add("<br/>")
top.add("Publish Description<br/>")
text = TextAreaWdg("description")
# this needs to be set or it will stick out to the right
text.add_style("width: 220px")
text.add_class("spt_checkin_description")
top.add(text)
# add as a note
note_div = DivWdg()
top.add(note_div)
note_div.add_class("spt_add_note")
checkbox = CheckboxWdg("add_note")
web = WebContainer.get_web()
browser = web.get_browser()
if browser in ['Qt']:
checkbox.add_style("margin-top: -4px")
checkbox.add_style("margin-right: 3px")
note_div.add_style("margin-top: 3px")
checkbox.add_class("spt_checkin_add_note")
note_div.add(checkbox)
note_div.add("Also add as note")
top.add("<br/><br/>")
button = ActionButtonWdg(title="Check-in", icon=IconWdg.PUBLISH, size='medium')
top.add(button)
my.repo_type = 'perforce'
if my.repo_type == 'perforce':
# the depot is set per project (unless overridden)
project = my.sobject.get_project()
depot = project.get_value("location", no_exception=True)
if not depot:
depot = project.get_code()
asset_dir = Environment.get_asset_dir()
sandbox_dir = Environment.get_sandbox_dir()
changelist = WidgetSettings.get_value_by_key("current_changelist")
button.add_behavior( {
'type': 'click_up',
'depot': depot,
'changelist': changelist,
'sandbox_dir': sandbox_dir,
'search_key': search_key,
'cbjs_action': '''
var paths = spt.checkin.get_selected_paths();
spt.app_busy.show("Checking in "+paths.length+" file/s into Perforce");
var top = bvr.src_el.getParent(".spt_checkin_top");
var description = top.getElement(".spt_checkin_description").value;
var add_note = top.getElement(".spt_checkin_add_note").value;
var editable = top.getElement(".spt_checkin_editable").value;
if (editable == 'on') {
editable = true;
}
else {
editable = false;
}
#.........这里部分代码省略.........
示例6: get_display
# 需要导入模块: from pyasm.widget import HiddenWdg [as 别名]
# 或者: from pyasm.widget.HiddenWdg import add_class [as 别名]
def get_display(my):
top = my.top
my.set_as_panel(top)
top.set_unique_id()
top.add_class("spt_search_limit_top")
# this info comes from the SearchLimit above (function get_info() )
count = my.kwargs.get("count")
if count == 0:
return top
search_limit = my.kwargs.get("search_limit")
# account for cases where this shouldn't even be called in a non search scenario
if not search_limit:
search_limit = 100
current_offset = my.kwargs.get("current_offset")
num_pages = int( float(count-1) / float(search_limit) ) + 1
current_page = int (float(current_offset) / count * num_pages) + 1
if num_pages == 1:
return top
#print "current: ", current_offset
#print "search_limit: ", search_limit
#print "current_page: ", current_page
top.add_color("background", "background3")
top.add_color("color", "color3")
top.add_style("margin: 15px -1px 10px -1px")
top.add_border()
table = Table()
table.add_style("margin-left: 30px")
top.add(table)
table.add_row()
top.add_smart_style("spt_link", "padding", "5px 10px 5px 10px")
top.add_smart_style("spt_link", "margin", "0px 5px 0px 5x")
top.add_smart_style("spt_link", "cursor", "pointer")
#top.add_smart_style("spt_link", "border", "solid 1px blue")
top.add_smart_style("spt_no_link", "padding", "5px 10px 5px 10px")
top.add_smart_style("spt_no_link", "margin", "0px 5px 0px 5x")
top.add_smart_style("spt_no_link", "opacity", "0.5")
top.add_smart_style("spt_no_link", "font-style", "italic")
top.add_relay_behavior( {
'type': 'mouseup',
'search_limit': search_limit,
'limit': search_limit,
'current_page': current_page,
'num_pages': num_pages,
'bvr_match_class': 'spt_link',
'cbjs_action': '''
var top = bvr.src_el.getParent(".spt_search_limit_top");
var page_el = top.getElement(".spt_page");
var value = bvr.src_el.getAttribute("spt_page");
if (value == 'next') {
value = bvr.current_page + 1;
if ( value < 1 ) value = 1;
}
else if (value == 'prev') {
value = bvr.current_page - 1;
if ( value > bvr.num_pages ) value = bvr.num_pages;
}
page_el.value = value;
bvr.src_el = bvr.src_el.getParent('.spt_table_top');
//bvr.panel = bvr.src_el.getParent('.spt_view_panel');
spt.dg_table.search_cbk(evt, bvr);
'''
} )
bgcolor = top.get_color("background3")
bgcolor2 = top.get_color("background3", 10)
top.add_relay_behavior( {
'type': 'mouseover',
'bgcolor': bgcolor2,
'bvr_match_class': 'spt_link',
'cbjs_action': '''
bvr.src_el.setStyle("background", bvr.bgcolor);
'''
} )
top.add_relay_behavior( {
'type': 'mouseout',
'bgcolor': bgcolor,
'bvr_match_class': 'spt_link',
'cbjs_action': '''
if (!bvr.src_el.hasClass('spt_current_page'))
bvr.src_el.setStyle("background", bvr.bgcolor);
'''
#.........这里部分代码省略.........
示例7: handle_dir_or_item
# 需要导入模块: from pyasm.widget import HiddenWdg [as 别名]
# 或者: from pyasm.widget.HiddenWdg import add_class [as 别名]
def handle_dir_or_item(my, item_div, dirname, basename):
spath = "%s/%s" % (dirname, basename)
fspath = "%s/%s" % (dirname, File.get_filesystem_name(basename))
md5 = my.md5s.get(fspath)
changed = False
context = None
error_msg = None
snapshot = None
file_obj = my.checked_in_paths.get(fspath)
if not file_obj:
if fspath.startswith(my.base_dir):
rel = fspath.replace("%s/" % my.base_dir, "")
file_obj = my.checked_in_paths.get(rel)
if file_obj != None:
snapshot_code = file_obj.get_value("snapshot_code")
snapshot = my.snapshots_dict.get(snapshot_code)
if not snapshot:
# last resort
snapshot = file_obj.get_parent()
if snapshot:
context = snapshot.get_value("context")
item_div.add_attr("spt_snapshot_code", snapshot.get_code())
snapshot_md5 = file_obj.get_value("md5")
item_div.add_attr("spt_md5", snapshot_md5)
item_div.add_attr("title", "Checked-in as: %s" % file_obj.get_value("file_name"))
if md5 and md5 != snapshot_md5:
item_div.add_class("spt_changed")
changed = True
else:
error_msg = 'snapshot not found'
status = None
if file_obj != None:
if changed:
check = IconWdg( "Checked-In", IconWdg.ERROR, width=12 )
status = "changed"
else:
check = IconWdg( "Checked-In", IconWdg.CHECK, width=12 )
status = "same"
item_div.add_color("color", "color", [0, 0, 50])
else:
check = None
item_div.add_style("opacity: 0.8")
status = "unversioned"
if check:
item_div.add(check)
check.add_style("float: left")
check.add_style("margin-left: -16px")
check.add_style("margin-top: 4px")
# add the file name
filename_div = DivWdg()
item_div.add(filename_div)
filename_div.add(basename)
file_info_div = None
if snapshot and status != 'unversioned':
file_info_div = SpanWdg()
filename_div.add(file_info_div)
if error_msg:
filename_div.add(' (%s)'%error_msg)
filename_div.add_style("float: left")
filename_div.add_style("overflow: hidden")
filename_div.add_style("width: 65%")
# DEPRECATED
from pyasm.widget import CheckboxWdg, TextWdg, SelectWdg, HiddenWdg
checkbox = CheckboxWdg("check")
checkbox.add_style("display: none")
checkbox.add_class("spt_select")
checkbox.add_style("float: right")
checkbox.add_style("margin-top: 1px")
item_div.add(checkbox)
subcontext_val = ''
cat_input = None
is_select = True
if my.context_options:
context_sel = SelectWdg("context")
context_sel.add_attr('title', 'context')
context_sel.set_option("show_missing", False)
context_sel.set_option("values", my.context_options)
#.........这里部分代码省略.........
示例8: get_page_two
# 需要导入模块: from pyasm.widget import HiddenWdg [as 别名]
# 或者: from pyasm.widget.HiddenWdg import add_class [as 别名]
def get_page_two(my):
'''let's browse an optional image here'''
info_page = DivWdg()
# add an icon for this project
image_div = DivWdg()
image_div.add_class("spt_image_top")
image_div.add_color("background", "background")
image_div.add_color("color", "color")
image_div.add_style("padding: 20px")
image_div.add(HtmlElement.b("Order Image:"))
image_div.add("<br/>"*3)
button = ActionButtonWdg(title="Browse")
image_div.add(button)
button.add_style("margin-left: auto")
button.add_style("margin-right: auto")
button.add_behavior( {
'type': 'click_up',
'cbjs_action': '''
var applet = spt.Applet.get();
spt.app_busy.show("Browsing for order image");
var path = applet.open_file_browser();
var top = bvr.src_el.getParent(".spt_image_top");
var text = top.getElement(".spt_image_path");
var display = top.getElement(".spt_path_display");
var check_icon = top.getElement(".spt_check_icon");
text.value = path;
applet.upload_file(path);
display.innerHTML = "Uploaded: " + path;
display.setStyle("padding", "10px");
check_icon.setStyle("display", "");
path = path + "";
/*
path = path.replace(/\\\\/g, "/");
var parts = path.split("/");
var filename = parts[parts.length-1];
*/
var filename = spt.path.get_basename(path);
filename = spt.path.get_filesystem_name(filename);
var server = TacticServerStub.get();
var kwargs = {
filename: filename
}
try {
var ret_val = server.execute_cmd("tactic.command.CopyFileToAssetTempCmd", kwargs);
var info = ret_val.info;
var path = info.path;
display.innerHTML = display.innerHTML + "<br/><br/><div style='text-align: center'><img style='width: 80px;' src='"+path+"'/></div>";
}
catch(e) {
spt.alert(spt.exception.handler(e));
}
spt.app_busy.hide();
'''
} )
text = HiddenWdg("order_image_path")
text.add_class("spt_image_path")
image_div.add(text)
check_div = DivWdg()
image_div.add(check_div)
check_div.add_class("spt_check_icon")
check_icon = IconWdg("Image uploaded", IconWdg.CHECK)
check_div.add(check_icon)
check_div.add_style("display: none")
check_div.add_style("float: left")
check_div.add_style("padding-top: 8px")
path_div = DivWdg()
image_div.add(path_div)
path_div.add_class("spt_path_display")
image_div.add(HtmlElement.br(3))
span = DivWdg()
image_div.add(span)
span.add_style("padding: 20px 20px 20px 20px")
span.add_color("background", "background3")
span.add(IconWdg("INFO", IconWdg.CREATE))
span.add("This optional order image can be used in verious places as a visual representation of this order.")
#info_page.add("<br/><br/>")
return image_div
示例9: get_display
# 需要导入模块: from pyasm.widget import HiddenWdg [as 别名]
# 或者: from pyasm.widget.HiddenWdg import add_class [as 别名]
def get_display(my):
top = my.top
top.add_class("spt_input_top")
top.add_style("position: relative")
top.add_style("width: 150px")
top.add_style("margin-top: -1px")
top.add_style("margin-left: -1px")
top.add_color("background", "background", -20)
top.add_border()
title = "Big"
div = DivWdg()
top.add(div)
icon_div = DivWdg()
div.add(icon_div)
icon_div.add_style("width: 20px")
icon_div.add_style("height: 21px")
icon_div.add_style("padding-left: 3px")
icon_div.add_style("margin: -3 6 0 -3")
icon_div.add_color("background", "background", [+15, 0, 0])
icon_div.add_style("float: left")
icon_div.add_style("opacity: 0.5")
icon = IconWdg("Select", IconWdg.FILM)
icon_div.add(icon)
div.add_behavior( {
'type': 'click_up',
'cbjs_action': '''
var top = bvr.src_el.getParent(".spt_input_top");
var content = spt.get_element( top, ".spt_input_content");
spt.toggle_show_hide(content);
spt.body.add_focus_element(content);
content.position(top);
'''
} )
div.add(title)
div.add_class("hand")
div.add_style("padding: 3px")
#top.add( TextWdg("hello") )
select_div = DivWdg()
top.add(select_div)
select_div.add_style("position: absolute")
select_div.add_class("spt_input_content")
select_div.add_color("background", "background")
select_div.add_style("top: 0px")
select_div.add_style("left: 0px")
select_div.add_style("display: none")
select_div.add_style("z-index: 1000")
select_div.set_box_shadow()
select_div.add_border()
select_div.add_class("SPT_PUW")
for title in ("Big", "Fat", "Cow", "Horse", "Donkeys"):
div = DivWdg()
select_div.add(div)
icon_div = DivWdg()
div.add(icon_div)
icon_div.add_style("width: 20px")
icon_div.add_style("height: 21px")
icon_div.add_style("margin: -3 6 0 -3")
icon_div.add_color("background", "background", [+15, 0, 0])
icon_div.add_style("float: left")
icon_div.add_style("opacity: 0.5")
icon_div.add(" ")
div.add(title)
div.add_class("hand")
div.add_style("padding: 3px")
div.add_style("width: 100px")
hover = div.get_color("background", [-30, -30, 20])
div.add_behavior( {
'type': 'hover',
'hover': hover,
'cbjs_action_over': '''
bvr.src_el.setStyle("background", bvr.hover);
''',
'cbjs_action_out': '''
bvr.src_el.setStyle("background", "");
'''
} )
div.add_behavior( {
'type': 'click_up',
#.........这里部分代码省略.........
示例10: DropElementWdg
# 需要导入模块: from pyasm.widget import HiddenWdg [as 别名]
# 或者: from pyasm.widget.HiddenWdg import add_class [as 别名]
class DropElementWdg(SimpleTableElementWdg):
ARGS_KEYS = {
'accepted_drop_type': {
'description': 'This will enforce the SType that can be accepted on this drop',
'category': 'Options',
'order': 1
},
'cbjs_drop_action': {
'description': 'Custom javascript callback to call when a drop has occured. This is optional',
'type': 'TextAreaWdg',
'category': 'Options',
'order': 3
},
'instance_type': {
'description': 'The SType name for the table that carries out the association',
'category': 'Options',
'order': 2
},
'display_expr': {
'description': 'Display Expression for the dropped item. e.g. @GET(.code)',
'category': 'Options',
'order': 4
}
#'cbpy_drop_action': 'Custom python callback when save is done'
}
"""
def get_args_keys(cls):
return cls.ARGS_KEYS
get_args_keys = classmethod(get_args_keys)
"""
def get_width(self):
return 150
def _get_sorted_instances(self):
sobject = self.get_current_sobject()
instance_type = self.get_option("instance_type")
instances = sobject.get_related_sobjects(instance_type)
# sorting now
name_dict ={}
for inst in instances:
name_dict[inst] = inst.get_display_value()
return sorted(instances, key=name_dict.__getitem__)
def is_editable(cls):
return False
is_editable = classmethod(is_editable)
def handle_layout_behaviors(self, layout):
#self.menu.set_activator_over(layout, "spt_drop_item")
#self.menu.set_activator_out(layout, "spt_drop_item")
layout.add_behavior( {
'type': 'load',
'cbjs_action': get_onload_js()
} )
def handle_td(self, td):
# FIXME: this is some hackery borrowed from the work to make gantt widget not commit on change
# ... need to clean this up at some point!
version = self.parent_wdg.get_layout_version()
if version != "2":
td.add_attr('spt_input_type', 'gantt')
td.add_class("spt_input_inline")
super(DropElementWdg, self).handle_td(td)
def get_value_wdg(self):
return self.value_wdg
def handle_tr(self, tr):
# define the drop zone
version = self.parent_wdg.get_layout_version()
def handle_th(self, th, wdg_idx=None):
th.add_attr('spt_input_type', 'inline')
"""
# handle finger menu
self.top_class = "spt_drop_element_menu"
from tactic.ui.container import MenuWdg, MenuItem
self.menu = MenuWdg(mode='horizontal', width = 25, height=20, top_class=self.top_class)
menu_item = MenuItem('action', label=IconWdg("Add User", IconWdg.ADD))
self.menu.add(menu_item)
#.........这里部分代码省略.........
示例11: get_data_wdg
# 需要导入模块: from pyasm.widget import HiddenWdg [as 别名]
# 或者: from pyasm.widget.HiddenWdg import add_class [as 别名]
def get_data_wdg(my):
div = DivWdg()
from pyasm.biz import Pipeline
from pyasm.widget import SelectWdg
search_type_obj = SearchType.get(my.search_type)
base_type = search_type_obj.get_base_key()
search = Search("sthpw/pipeline")
search.add_filter("search_type", base_type)
pipelines = search.get_sobjects()
if pipelines:
pipeline = pipelines[0]
process_names = pipeline.get_process_names()
if process_names:
table = Table()
div.add(table)
table.add_row()
table.add_cell("Process: ")
select = SelectWdg("process")
table.add_cell(select)
process_names.append("---")
process_names.append("publish")
process_names.append("icon")
select.set_option("values", process_names)
####
buttons = Table()
div.add(buttons)
buttons.add_row()
#button = IconButtonWdg(title="Fill in Data", icon=IconWdg.EDIT)
button = ActionButtonWdg(title="Metadata")
button.add_style("float: left")
button.add_style("margin-top: -3px")
buttons.add_cell(button)
select_label = DivWdg("Update mode");
select_label.add_style("float: left")
select_label.add_style("margin-top: -3px")
select_label.add_style("margin-left: 20px")
buttons.add_cell(select_label)
update_mode_option = my.kwargs.get("update_mode")
if not update_mode_option:
update_mode_option = "true"
update_mode = SelectWdg(name="update mode")
update_mode.add_class("spt_update_mode_select")
update_mode.set_option("values", ["false", "true", "sequence"])
update_mode.set_option("labels", ["Off", "On", "Sequence"])
update_mode.set_option("default", update_mode_option)
update_mode.add_style("float: left")
update_mode.add_style("margin-top: -3px")
update_mode.add_style("margin-left: 5px")
update_mode.add_style("margin-right: 5px")
buttons.add_cell(update_mode)
update_info = DivWdg()
update_info.add_class("glyphicon")
update_info.add_class("glyphicon-info-sign")
update_info.add_style("float: left")
update_info.add_style("margin-top: -3px")
update_info.add_style("margin-left: 10px")
update_info.add_behavior( {
'type': 'click_up',
'cbjs_action': '''
spt.info("When update mode is on, if a file shares the name of one other file in the asset library, the file will update on ingest. If more than one file shares the name of an ingested asset, a new asset is created.<br> If sequence mode is selected, the system will update the sobject on ingest if a file sequence sharing the same name already exists.", {type: 'html'});
'''
} )
buttons.add_cell(update_info);
dialog = DialogWdg(display="false", show_title=False)
div.add(dialog)
dialog.set_as_activator(button, offset={'x':-10,'y':10})
dialog_data_div = DivWdg()
dialog_data_div.add_color("background", "background")
dialog_data_div.add_style("padding", "20px")
dialog.add(dialog_data_div)
# Order folders by date
name_div = DivWdg()
dialog_data_div.add(name_div)
name_div.add_style("margin: 15px 0px")
if SearchType.column_exists(my.search_type, "relative_dir"):
category_div = DivWdg()
name_div.add(category_div)
checkbox = RadioWdg("category")
checkbox.set_option("value", "none")
category_div.add(checkbox)
category_div.add(" No categories")
category_div.add_style("margin-bottom: 5px")
checkbox.set_option("checked", "true")
#.........这里部分代码省略.........
示例12: get_display
# 需要导入模块: from pyasm.widget import HiddenWdg [as 别名]
# 或者: from pyasm.widget.HiddenWdg import add_class [as 别名]
def get_display(my):
relative_dir = my.kwargs.get("relative_dir")
my.relative_dir = relative_dir
div = DivWdg()
div.add_class("spt_ingest_top")
div.add_style("width: 100%px")
div.add_style("min-width: 500px")
div.add_style("padding: 20px")
div.add_color("background", "background")
my.search_type = my.kwargs.get("search_type")
if not my.search_type:
div.add("No search type specfied")
return div
if relative_dir:
folder_div = DivWdg()
div.add(folder_div)
folder_div.add("Folder: %s" % relative_dir)
folder_div.add_style("opacity: 0.5")
folder_div.add_style("font-style: italic")
folder_div.add_style("margin-bottom: 10px")
data_div = my.get_data_wdg()
data_div.add_style("float: left")
data_div.add_style("float: left")
div.add(data_div)
# create the help button
help_button_wdg = DivWdg()
div.add(help_button_wdg)
help_button_wdg.add_style("float: right")
help_button = ActionButtonWdg(title="?", tip="Ingestion Widget Help", size='s')
help_button_wdg.add(help_button)
help_button.add_behavior( {
'type': 'click_up',
'cbjs_action': '''spt.help.load_alias("ingestion_widget")'''
} )
from tactic.ui.input import Html5UploadWdg
upload = Html5UploadWdg(multiple=True)
div.add(upload)
button = ActionButtonWdg(title="Add")
button.add_style("float: right")
button.add_style("margin-top: -3px")
div.add(button)
button.add_behavior( {
'type': 'click_up',
'normal_ext': File.NORMAL_EXT,
'cbjs_action': '''
var top = bvr.src_el.getParent(".spt_ingest_top");
var files_el = top.getElement(".spt_to_ingest_files");
var regex = new RegExp('(' + bvr.normal_ext.join('|') + ')$', 'i');
//clear upload progress
var upload_bar = top.getElement('.spt_upload_progress');
if (upload_bar) {
upload_bar.setStyle('width','0%');
upload_bar.innerHTML = '';
}
var onchange = function (evt) {
var files = spt.html5upload.get_files();
var delay = 0;
for (var i = 0; i < files.length; i++) {
var size = files[i].size;
var file_name = files[i].name;
var is_normal = regex.test(file_name);
if (size >= 10*1024*1024 || is_normal) {
spt.drag.show_file(files[i], files_el, 0, false);
}
else {
spt.drag.show_file(files[i], files_el, delay, true);
if (size < 100*1024) delay += 50;
else if (size < 1024*1024) delay += 500;
else if (size < 10*1024*1024) delay += 1000;
}
}
}
spt.html5upload.clear();
spt.html5upload.set_form( top );
spt.html5upload.select_file( onchange );
'''
} )
button = ActionButtonWdg(title="Clear")
button.add_style("float: right")
button.add_style("margin-top: -3px")
#.........这里部分代码省略.........
示例13: get_data_wdg
# 需要导入模块: from pyasm.widget import HiddenWdg [as 别名]
# 或者: from pyasm.widget.HiddenWdg import add_class [as 别名]
#.........这里部分代码省略.........
category_div = DivWdg()
name_div.add(category_div)
checkbox = RadioWdg("category")
checkbox.set_option("value", "by_week")
category_div.add(checkbox)
category_div.add(" Categorize files by Week")
category_div.add_style("margin-bottom: 5px")
category_div = DivWdg()
name_div.add(category_div)
checkbox = RadioWdg("category")
checkbox.set_option("value", "by_year")
category_div.add(checkbox)
category_div.add(" Categorize files by Year")
category_div.add_style("margin-bottom: 5px")
"""
checkbox = RadioWdg("category")
checkbox.set_option("value", "custom")
name_div.add(checkbox)
name_div.add(" Custom")
"""
name_div.add("<br/>")
hidden = HiddenWdg(name="parent_key")
dialog_data_div.add(hidden)
hidden.add_class("spt_parent_key")
parent_key = my.kwargs.get("parent_key") or ""
if parent_key:
hidden.set_value(parent_key)
dialog_data_div.add("Keywords:<br/>")
dialog.add(dialog_data_div)
text = TextAreaWdg(name="keywords")
dialog_data_div.add(text)
text.add_class("spt_keywords")
text.add_style("padding: 1px")
dialog_data_div.add("<br/>"*2)
extra_data = my.kwargs.get("extra_data")
if not isinstance(extra_data, basestring):
extra_data = jsondumps(extra_data)
dialog_data_div.add("Extra Data (JSON):<br/>")
text = TextAreaWdg(name="extra_data")
dialog_data_div.add(text)
if extra_data != "null":
text.set_value(extra_data)
text.add_class("spt_extra_data")
text.add_style("padding: 1px")
示例14: get_display
# 需要导入模块: from pyasm.widget import HiddenWdg [as 别名]
# 或者: from pyasm.widget.HiddenWdg import add_class [as 别名]
def get_display(my):
if not my.preprocessed:
my.preprocess()
if my.is_refresh:
top = Widget()
else:
top = DivWdg()
top.add_class("spt_work_hours_top")
hidden = HiddenWdg('workhour_data')
hidden.add_class('spt_workhour_data')
header_data = {'start_date': str(my.start_date)}
header_data = jsondumps(header_data).replace('"', """)
hidden.set_value(header_data, set_form_value=False )
top.add(hidden)
days = []
for date in my.dates:
days.append( date.strftime("%Y_%m_%d") )
today = my.today.strftime("%Y_%m_%d")
task = my.get_current_sobject()
if not my.is_refresh:
my.set_as_panel(top)
entries = my.entries.get(task.get_code())
if isinstance(task, Task):
parent = task.get_parent()
if not parent:
disabled = True
else:
disabled = False
else:
disabled = False
if not entries:
entries = {}
table = Table()
top.add(table)
if my.use_straight_time:
row_list = [my.ST_ROW]
if my.show_overtime:
row_list.append(my.OT_ROW)
prefix_list = ['','ot']
else:
row_list = [my.STT_ROW, my.ENT_ROW]
prefix_list = ['stt','ent']
text = HiddenWdg(my.get_name() )
text.add_class("spt_data")
table.add_color("color", "color")
table.add_styles("width: %spx; float: left"%my.table_width)
for row_to_draw in row_list:
tr = table.add_row()
tr.add_style('line-height','8px')
td = table.add_blank_cell()
offset_width = my.MONTH_WIDTH + my.LEFT_WIDTH+8
td.add_style("min-width: %spx" % offset_width)
td.add(text)
# go through each day and draw an input for overtime
total_hours_st = 0
total_hours_ot = 0
search_key = task.get_search_key()
# Add a label to indicate if the row is straight time or overtime
time_prefix = ''
if row_to_draw == my.OT_ROW:
time_prefix = 'ot'
div = DivWdg()
div.add("OT")
div.add_styles('text-align: right; margin-right: 4px')
td.add(div)
elif row_to_draw == my.STT_ROW:
time_prefix = 'stt'
div = DivWdg()
div.add("ST")
div.add_styles('text-align: right; margin: 0 4px 4px 0')
td.add(div)
elif row_to_draw == my.ENT_ROW:
time_prefix = 'ent'
div = DivWdg()
div.add("ET")
div.add_styles('text-align: right; margin: 0 4px 4px 0')
td.add(div)
for idx, day in enumerate(days):
day_wdg = DivWdg()
#.........这里部分代码省略.........
示例15: get_display
# 需要导入模块: from pyasm.widget import HiddenWdg [as 别名]
# 或者: from pyasm.widget.HiddenWdg import add_class [as 别名]
def get_display(self):
#return None
div = DivWdg()
div.add_class("spt_gantt_top")
value_wdg = HiddenWdg(self.get_name())
value_wdg.add_class("spt_gantt_value")
div.add( value_wdg )
content_div = DivWdg()
content_div.add_style("width: 100%")
content_div.add_style("height: 100%")
content_div.add_behavior( {
'type': 'accept_drop',
'drop_code': 'DROP_ROW',
'cbjs_action': '''
var src_el = bvr._drop_source_bvr.src_el;
var src_table_top = src_el.getParent(".spt_table_top");
var src_table = src_table_top.getElement(".spt_table");
var src_search_keys = spt.dg_table.get_selected_search_keys(src_table);
if (src_search_keys.length == 0) {
var tbody = src_el.getParent(".spt_table_tbody");
var src_search_key = tbody.getAttribute("spt_search_key");
src_search_keys = [ src_search_key ];
}
var src_search_key = src_search_keys[0];
var drop_el = bvr.src_el;
var top_wdg = drop_el.getParent('.spt_gantt_top');
var value_wdg = top_wdg.getElement('.spt_gantt_value');
value_wdg.value = src_search_key;
var content_wdg = top_wdg.getElement('.spt_content');
var server = TacticServerStub.get();
var sobject = server.get_by_search_key(src_search_key);
var code = sobject['code'];
content_wdg.innerHTML = code;
spt.dg_table.edit.widget = top_wdg;
var key_code = spt.kbd.special_keys_map.ENTER;
spt.dg_table.edit_cell_cbk( value_wdg, key_code );
'''
} )
sobject = self.get_current_sobject()
try:
parent = sobject.get_parent()
if parent:
value = parent.get_code()
else:
value = " "
except SearchException as e:
# skips unknown search_type/project
print e.__str__()
search_type = sobject.get_search_type()
if search_type in ['sthpw/task','sthpw/note','sthpw/snapshot']:
value = "Parent cannot be found for this parent key [%s&id=%s]" %(sobject.get_value('search_type'), sobject.get_value('search_id'))
else:
search_key = sobject.get_search_key()
value = "Invalid parent for [%s]" % search_key
content_div.add_class('spt_content')
content_div.add(value)
div.add(content_div)
return div