本文整理汇总了Python中pyasm.widget.TextWdg.add_behavior方法的典型用法代码示例。如果您正苦于以下问题:Python TextWdg.add_behavior方法的具体用法?Python TextWdg.add_behavior怎么用?Python TextWdg.add_behavior使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyasm.widget.TextWdg
的用法示例。
在下文中一共展示了TextWdg.add_behavior方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_display
# 需要导入模块: from pyasm.widget import TextWdg [as 别名]
# 或者: from pyasm.widget.TextWdg import add_behavior [as 别名]
def get_display(my):
widget = DivWdg()
table = Table()
table.add_attr('class','scraper')
table.add_row()
tb = TextWdg('title_box')
tb.add_attr('id','title_box')
multiple_titles = None
print "MY.TITLE_OF_SHOW = %s" % my.title_of_show
if my.title_of_show not in [None,'']:
tb.set_value(my.title_of_show)
#poster_url_text = my.get_poster_url(my.title_of_show)
#poster_url = poster_url_text.split('=')[1]
multiple_titles = my.get_multiple_title_info(my.title_of_show)
print "MULTIPLE_TITLES = %s" % multiple_titles
tb.add_behavior(my.get_search())
table.add_cell(tb)
if multiple_titles not in [None,''] and len(multiple_titles) > 0:
for m in multiple_titles:
table.add_row()
table.add_cell('<img src="%s"/>' % m['TopLevel']['poster'])
mkeys = m.keys()
for k in mkeys:
table.add_row()
table.add_cell('<b><u>%s</u></b>' % k)
dudes = m[k]
dkeys = dudes.keys()
for d in dkeys:
table.add_row()
table.add_cell('%s: %s' % (d, dudes[d]))
widget.add(table)
return widget
示例2: get_display
# 需要导入模块: from pyasm.widget import TextWdg [as 别名]
# 或者: from pyasm.widget.TextWdg import add_behavior [as 别名]
def get_display(my):
sobject = my.get_current_sobject()
key = sobject.get_value("key")
options = sobject.get_value("options")
type = sobject.get_value("type")
# get the value of the users preferences
search = Search("sthpw/pref_setting")
search.add_user_filter()
search.add_filter("key", key)
pref_setting = search.get_sobject()
if pref_setting:
value = pref_setting.get_value("value")
else:
value = ""
div = DivWdg()
element_name = "%s_%s" % (my.get_name(), sobject.get_id() )
script = '''var server = TacticServerStub.get();
var value = bvr.src_el.value;
if (!value) return;
spt.app_busy.show("Saving", "Saving Preference for [%s]");
setTimeout( function() {
try{
server.execute_cmd('tactic.ui.table.SetPreferenceCmd', {key: '%s', value: value});
}catch(e){
spt.alert(spt.exception.handler(e));
}
spt.app_busy.hide()
}, 200);'''%(key, key)
if key in ['skin', 'palette', 'js_logging_level']:
script = '''%s; spt.app_busy.show('Reloading Page ...'); setTimeout('spt.refresh_page()', 200);'''%script
if type == "sequence":
from pyasm.prod.web import SelectWdg
select = SelectWdg(element_name)
select.add_behavior({'type': "change",
'cbjs_action': script})
select.set_option("values",options)
if value:
select.set_value(value)
div.add(select)
else:
text = TextWdg(element_name)
text.add_behavior({'type': "blur",
'cbjs_action': script})
if value:
text.set_value(value)
div.add(text)
return div
示例3: txtbox
# 需要导入模块: from pyasm.widget import TextWdg [as 别名]
# 或者: from pyasm.widget.TextWdg import add_behavior [as 别名]
def txtbox(my, name, val, code, old_val, width='200px', js='no'):
txt = TextWdg(name)
txt.add_attr('id', name)
txt.add_attr('code', code)
txt.add_attr('old_val', old_val)
txt.add_style('width: %s;' % width)
txt.set_value(val)
if js == 'yes':
txt.add_behavior(my.get_nums_only())
return txt
示例4: get_display
# 需要导入模块: from pyasm.widget import TextWdg [as 别名]
# 或者: from pyasm.widget.TextWdg import add_behavior [as 别名]
def get_display(my):
from pyasm.search import Search
#from tactic_client_lib import TacticServerStub
barcode = ''
sources = []
bad_sources = []
if 'barcode' in my.kwargs.keys():
barcode = my.kwargs.get('barcode')
tracker_s = Search("twog/location_tracker")
tracker_s.add_filter('location_barcode',barcode)
trackers = tracker_s.get_sobjects()
#print "BARCODE = %s" % barcode
#print "LEN TRACKERS = %s" % len(trackers)
for t in trackers:
tdate = t.get('timestamp')
source_barcode = t.get('source_barcode')
other_tracks = Search("twog/location_tracker")
other_tracks.add_filter('source_barcode',source_barcode)
other_tracks.add_filter('timestamp',tdate, op=">")
others = other_tracks.get_sobjects()
if len(others) == 0:
source_s = Search("twog/source")
source_s.add_filter('barcode',source_barcode)
source = source_s.get_sobject()
if source:
if source.get_value('in_house') in [True,'true','True',1,'1']:
sources.append(source)
else:
bad_sources.append({'barcode': source_barcode, 'title': 'UNKNOWN SOURCE'})
table = Table()
table.add_attr('class','location_inventory_wdg')
table.add_row()
bc = TextWdg('nextbc')
bc.add_attr('id', 'location_inventory_txtbox')
bc.add_behavior(my.get_entry_bvr())
bc.set_value(barcode)
table.add_cell(bc)
#print "LEN SOURCES = %s" % len(sources)
if len(sources) > 0:
table.add_row()
table.add_cell("<b>TOTAL: %s (UNKNOWN: %s)</b>" % (len(sources), len(bad_sources)))
for source in sources:
table.add_row()
table.add_cell('Barcode: %s, Code: %s, Name: %s: %s' % (source.get_value('barcode'), source.get_code(), source.get_value('title'), source.get_value('episode')))
if len(bad_sources) > 0:
table.add_row()
table.add_cell("<b>UNKNOWN SOURCES</b>")
for b in bad_sources:
table.add_row()
table.add_cell('Barcode: %s, Name: %s' % (b.get('barcode'), b.get('title')))
widget = DivWdg()
widget.add(table)
return widget
示例5: get_display
# 需要导入模块: from pyasm.widget import TextWdg [as 别名]
# 或者: from pyasm.widget.TextWdg import add_behavior [as 别名]
def get_display(my):
raise Exception("tactic.widget.ColorInputWdg is deprecated")
color_div = DivWdg()
color_div.add_style("z-index: 1000")
# color_div.add_style("float: left")
import random
number = random.randint(1, 1000)
rainbow_id = "rainbow_%s" % number
color_div.add(
"""
<img id="%s" src="/context/spt_js/mooRainbow/rainbow.png" alt="[r]" width="16" height="16" />
"""
% rainbow_id
)
# <input id="myInput" name="myInput" type="text" size="13" />
text = TextWdg(my.get_name())
text.set_id("myInput")
behavior = {"type": "keyboard", "kbd_handler_name": "DgTableMultiLineTextEdit"}
text.add_behavior(behavior)
color_div.add(text)
color_div.add_behavior(
{
"type": "load",
"cbjs_action": """
var r = new MooRainbow('%s', {
startColor: [58, 142, 246],
imgPath: '/context/spt_js/mooRainbow/images/',
onComplete: function(color) { $(myInput).value=color.hex; }
});
"""
% rainbow_id,
}
)
return color_div
示例6: get_display
# 需要导入模块: from pyasm.widget import TextWdg [as 别名]
# 或者: from pyasm.widget.TextWdg import add_behavior [as 别名]
def get_display(my):
table = Table()
my.movement_code = my.kwargs.get('movement_code')
table.add_attr('class', 'movement_add_source')
table.add_attr('movement_id','')
table.add_attr('movement_sk','')
table.add_attr('movement_code','')
top_row = table.add_row()
top_row.add_style('background-color: #eaeaea;')
if my.movement_code not in ['',None]:
ms = MovementScripts(movement_code=my.movement_code)
barcode_text_wdg = TextWdg('source_barcode_insert')
barcode_text_wdg.add_attr('id','source_barcode_insert')
barcode_text_wdg.add_behavior(ms.get_barcode_insert_behavior())
table.add_cell('Barcode: ')
table.add_cell(barcode_text_wdg)
widget = DivWdg()
widget.add(table)
if my.movement_code not in ['',None]:
widget.add_behavior(my.get_on_load_js())
return widget
示例7: get_display
# 需要导入模块: from pyasm.widget import TextWdg [as 别名]
# 或者: from pyasm.widget.TextWdg import add_behavior [as 别名]
def get_display(my):
my.icon_string = my.get_value("icon")
my.icon_label = my.get_value("label")
top = DivWdg()
top.add_class("spt_icon_chooser_top")
# FIXME: this is being generated every time .... where to put is?
icon_chooser = IconChooserWdg( is_popup=True )
top.add( icon_chooser )
icon_entry_text = TextWdg(my.get_input_name())
icon_entry_text.set_option("size", "30")
#icon_entry_text.set_attr("disabled", "disabled")
icon_entry_text.add_class( "SPT_ICON_ENTRY_TEXT" )
button = ActionButtonWdg(title='Choose', tip='Click to select an icon')
icon_img = HtmlElement.img()
icon_img.add_class( "SPT_ICON_IMG" )
if my.icon_string:
# icon_path = IconWdg.icons.get(my.icon_string)
icon_path = IconWdg.get_icon_path(my.icon_string)
if icon_path:
# icon = IconWdg( my.icon_string, icon_path, right_margin='0px' )
icon_img.set_attr("src", icon_path)
else:
icon_img.set_attr("src", IconWdg.get_icon_path("TRANSPARENT"))
icon_entry_text.set_value( my.icon_string )
else:
icon_entry_text.set_value( "" )
icon_img.set_attr("src", IconWdg.get_icon_path("TRANSPARENT"))
named_event_name = "ICON_CHOOSER_SELECTION_MADE"
icon_entry_text.add_behavior( {'type': 'listen', 'event_name': named_event_name,
'cbjs_action': '''
var top = $("IconChooserPopup");
var chooser = spt.get_element(top, ".SPT_ICON_CHOOSER_WRAPPER_DIV");
//var chooser = spt.get_cousin( bvr.src_el,
// ".spt_icon_chooser_top", ".SPT_ICON_CHOOSER_WRAPPER_DIV" );
var icon_name = chooser.getProperty("spt_icon_selected");
var icon_path = chooser.getProperty("spt_icon_path");
// bvr.src_el.innerHTML = icon_name;
bvr.src_el.value = icon_name;
if( spt.is_hidden( bvr.src_el ) ) { spt.show( bvr.src_el ); }
var img_el = spt.get_cousin( bvr.src_el,
".spt_icon_chooser_top", ".SPT_ICON_IMG" );
if( icon_path ) {
img_el.setProperty("src", icon_path);
} else {
img_el.setProperty("src","/context/icons/common/transparent_pixel.gif");
}
''' } )
top.add_behavior( {'type': 'click_up', 'cbjs_action': 'spt.popup.open( "IconChooserPopup", false);' } )
#top.add( my.icon_label )
spacing = "<img src='%s' style='width: %spx;' />" % (IconWdg.get_icon_path("TRANSPARENT"), 3)
#button.add_behavior( {'type': 'click_up', 'cbjs_action': 'spt.popup.open( "IconChooserPopup", false);' } )
#top.add( button )
#button.add_style("float: right")
#button.add_style("margin-top: -3px")
top.add( icon_img )
top.add( spacing )
top.add( icon_entry_text )
return top
示例8: get_display
# 需要导入模块: from pyasm.widget import TextWdg [as 别名]
# 或者: from pyasm.widget.TextWdg import add_behavior [as 别名]
def get_display(my):
widget = DivWdg()
table = Table()
table.add_attr('class', 'scraper')
table.add_style('background-color: #FFFFFF;')
table.add_style('height: 1000px;')
table.add_row()
tb = TextWdg('title_box')
tb.add_attr('id', 'title_box')
tb.add_attr('size', '45')
multiple_titles = None
searched_imdb = False
orders = []
# TODO: Remove hard-coded URL
no_img = 'http://tactic.2gdigital.com/imdb_images/no_image.png'
if 'code' in my.kwargs.keys() and my.title_of_show in [None, '']:
server = TacticServerStub.get()
this_order = server.eval("@SOBJECT(twog/order['code','%s'])" % my.kwargs.get('code'))[0]
my.title_of_show = this_order.get('name')
if my.title_of_show not in [None, '']:
tb.set_value(my.title_of_show)
if my.search_when_loaded:
# poster_url_text = my.get_poster_url(my.title_of_show)
# poster_url = poster_url_text.split('=')[1]
server = TacticServerStub.get()
orders = server.eval("@SOBJECT(twog/order['name','~','%s']['classification','not in','Master|Cancelled'])" % my.title_of_show)
# order_s = Search("twog/order")
# order_s.add_where("\"name\" like '%s%s%s'" % ('%', my.title_of_show.lower(), '%'))
# statement = order_s.get_statement()
# print "STATEMENT = %s" % statement
# orders = order_s.get_sobjects()
# print "ORDER LEN = %s" % len(orders)
if len(orders) > 0:
multiple_titles = get_multiple_title_info(my.title_of_show)
# print "MULTIPLE TITLES = %s" % multiple_titles
searched_imdb = True
tb.add_behavior(my.get_search())
top_tbl = Table()
top_tbl.add_attr('width', '400px')
top_tbl.add_attr('height', '50px')
top_tbl.add_attr('cellpadding', '20')
top_tbl.add_attr('cellspacing', '20')
top_tbl.add_style('background-color: #417e97;')
top_tbl.add_row()
if len(orders) > 0:
butt = top_tbl.add_cell('<input type="button" value="Associate All Selected"/>')
butt.add_behavior(my.get_associate_em())
sn = top_tbl.add_cell('<font color="#d9af1f"><b>Search Name:</b></font> ')
sn.add_attr('align', 'right')
sn.add_attr('nowrap', 'nowrap')
tb_cell1 = top_tbl.add_cell(tb)
tb_cell = table.add_cell(top_tbl)
tb_cell.add_attr('colspan', '2')
tb_cell.add_attr('align', 'center')
order_table = Table()
order_table.add_attr('border', '1')
order_table.add_attr('cellpadding', '10')
order_table.add_row()
if len(orders) > 0:
toggler = CustomCheckboxWdg(name='chk_toggler', additional_js=my.get_toggler(), value_field='toggler',
id='selection_toggler', checked='false', text='<b><- Select/Deselect ALL</b>',
text_spot='right', text_align='left', nowrap='nowrap')
order_table.add_cell(toggler)
order_table.add_row()
order_table.add_cell('Selector')
order_table.add_cell('Poster')
order_table.add_cell('Order Builder')
order_table.add_cell('Code')
order_table.add_cell('Name')
order_table.add_cell('Client')
order_table.add_cell('PO Number')
order_table.add_cell('Classification')
order_table.add_cell('Platform')
order_table.add_cell('Due Date')
order_table.add_cell('Completion Ratio')
order_table.add_cell('Scheduler')
elif my.title_of_show not in [None, ''] and my.search_when_loaded:
description_box = order_table.add_cell('<b>No Tactic Orders Were Found With "%s" In The Name</b>' % my.title_of_show)
description_box.add_style('font-size: 14px;')
else:
description_box = order_table.add_cell('<b>Please type the name of the show in the box above</b>')
description_box.add_style('font-size: 14px;')
for order in orders:
checkbox = CustomCheckboxWdg(name='associate_order_%s' % order.get('code'),
additional_js=my.highlight_order_row(order.get('code')),
alert_name=order.get('name'),
value_field=order.get('code'),
checked='false',
dom_class='associated_orders')
imarow = order_table.add_row()
imarow.add_attr('id', 'row_%s' % order.get('code'))
chk = order_table.add_cell(checkbox)
chk.add_attr('align', 'center')
poster_cell = order_table.add_cell(OrderImageWdg(code=order.get('code')))
poster_cell.add_attr('id', 'img_%s' % order.get('code'))
#.........这里部分代码省略.........
示例9: get_display
# 需要导入模块: from pyasm.widget import TextWdg [as 别名]
# 或者: from pyasm.widget.TextWdg import add_behavior [as 别名]
def get_display(my):
widget = DivWdg(id='new_item_panel')
widget.add_class("new_item_panel")
widget.add_class("spt_new_item_top")
div = DivWdg()
div.add_color("background", "background")
div.add_color("color", "color")
div.add_style("padding", "5px")
div.add_border()
if my.is_personal:
is_personal = 'true'
else:
is_personal = 'false'
if my.type == 'new_folder':
#div.set_attr('spt_view', 'new_folder')
div.add(HtmlElement.b('Create New Folder'))
div.add(HtmlElement.br(2))
"""
# add exisiting views in the div for checking with client's input
# add exiting views:
from panel_wdg import ViewPanelSaveWdg
views = ViewPanelSaveWdg.get_existing_views(my.is_personal)
hidden = HiddenWdg('existing_views', '|'.join(views))
div.add(hidden)
"""
text2 = TextWdg("new_title")
text2.add_class("spt_new_item_title")
span = SpanWdg("Title: ")
span.set_id('create_new_title')
#span.add_style('display: none')
span.add_style('padding-left: 8px')
span.add(text2)
div.add(span)
div.add(HtmlElement.br(2))
div.add_style("width: 350px")
action = '''
var top = bvr.src_el.getParent(".spt_new_item_top");
var name_el = top.getElement(".spt_new_item_name");
var title = bvr.src_el.value;
var name = title.replace(/[\[email protected]#$%^&*()'"]/g, "");
name = name.replace(/ /g, "_");
name = name.toLowerCase();
name_el.value = name;
'''
# change the name based on the title
text2.add_behavior( {
'type': 'change',
'cbjs_action': action
} )
div.add("The name of the folder is a hidden name that is used by other elements to refer to uniquely to this item.<br/><br/>")
text = TextWdg('new_name')
text.add_class("spt_new_item_name")
span = SpanWdg('Name: ')
span.add(text)
div.add(span)
div.add(HtmlElement.br(2))
#script = "spt.side_bar.manage_section_action_cbk({'value':'predefined'},'project_view');"
#link = HtmlElement.js_href(script, data='[ Predefined View ]')
#div3 = DivWdg('Optional: drag existing elements from Project Views or %s into this new folder' %link.get_buffer_display())
#div.add(div3)
#item_div = DivWdg(css='spt_new_item spt_side_bar_content')
#div.add(item_div)
div.add("<hr/>")
#save_div = SpanWdg(css='med hand')
#div.add(save_div)
#save_div.add(IconWdg('Save Folder', IconWdg.SAVE))
save_button = ActionButtonWdg(title='Create', tip='Create a new folder')
div.add(save_button)
bvr = {
"type": "click_up",
"view": my.view,
"is_personal": is_personal == 'true',
'cbjs_action': '''
var top = bvr.src_el.getParent(".spt_new_item_top");
var name_el = top.getElement(".spt_new_item_name");
var name_value = name_el.value;
if (name_value == "") {
var title_el = top.getElement(".spt_new_item_title");
var title = title_el.value;
var name = spt.convert_to_alpha_numeric(title);
name_el.value = name;
}
if (name_value == "") {
spt.alert("Please fill in a value for name.");
#.........这里部分代码省略.........
示例10: get_default_display_wdg
# 需要导入模块: from pyasm.widget import TextWdg [as 别名]
# 或者: from pyasm.widget.TextWdg import add_behavior [as 别名]
def get_default_display_wdg(cls, element_name, display_options, element_type, kbd_handler=False):
from pyasm.widget import TextAreaWdg, CheckboxWdg, SelectWdg, TextWdg
if element_type in ["integer", "smallint", "bigint", "int"]:
behavior = {
'type': 'keyboard',
'kbd_handler_name': 'DgTableIntegerTextEdit'
}
input = TextWdg("main")
input.set_options(display_options)
if kbd_handler:
input.add_behavior(behavior)
elif element_type in ["float"]:
behavior = {
'type': 'keyboard',
'kbd_handler_name': 'DgTableFloatTextEdit'
}
input = TextAreaWdg("main")
input.set_options(display_options)
if kbd_handler:
input.add_behavior(behavior)
elif element_type in ["string", "link", "varchar", "character", "timecode"]:
behavior = {
'type': 'keyboard',
'kbd_handler_name': 'DgTableMultiLineTextEdit'
}
input = TextWdg('main')
input.set_options(display_options)
if kbd_handler:
input.add_behavior(behavior)
elif element_type in ["text"]:
behavior = {
'type': 'keyboard',
'kbd_handler_name': 'DgTableMultiLineTextEdit'
}
input = TextAreaWdg('main')
input.set_options(display_options)
if kbd_handler:
input.add_behavior(behavior)
elif element_type == "boolean":
input = CheckboxWdg('main')
input.set_options(display_options)
input.add_behavior(
{"type" : "click_up",
'propagate_evt': True})
elif element_type in ["timestamp", "date", "time", "datetime2"]:
from tactic.ui.widget import CalendarInputWdg, CalendarWdg, TimeInputWdg
# FIXME: take wild guess for the time
if element_name.endswith("_time"):
#input = TimeInputWdg()
behavior = {
'type': 'keyboard',
'kbd_handler_name': 'DgTableMultiLineTextEdit'
}
input = TextWdg('main')
input.set_options(display_options)
if kbd_handler:
input.add_behavior(behavior)
else:
#input = CalendarWdg()
input = CalendarInputWdg()
input.set_option('show_activator', False)
#input.set_options(display_options)
elif element_type == 'datetime':
from tactic.ui.widget import CalendarInputWdg
input = CalendarInputWdg()
input.set_option('show_time', 'true')
elif element_type == "color":
from tactic.ui.widget import ColorInputWdg
input = ColorInputWdg()
input.set_options(display_options)
elif element_type =="sqlserver_timestamp":
# better then set it to None
input = TextWdg()
input.add_attr('disabled','disabled')
else:
# else try to instantiate it as a class
print "WARNING: EditWdg handles type [%s] as default TextWdg" %element_type
input = TextWdg()
input.add("No input defined")
return input
示例11: handle_item_div
# 需要导入模块: from pyasm.widget import TextWdg [as 别名]
# 或者: from pyasm.widget.TextWdg import add_behavior [as 别名]
#.........这里部分代码省略.........
icon_string = my.get_file_icon(dirname, basename)
icon_div = DivWdg()
td = table.add_cell(icon_div)
td.add_style("width: 15px")
icon = IconWdg("%s/%s" % (dirname, basename), icon_string)
icon_div.add(icon)
icon_div.add_style("float: left")
icon_div.add_style("margin-top: -1px")
path = "%s/%s" % (dirname, basename)
status = my.path_info.get(path)
margin_left = -16
if status == 'same':
check = IconWdg( "No Changes", IconWdg.CHECK, width=12 )
elif status == 'added':
check = IconWdg( "Added", IconWdg.NEW, width=16 )
margin_left = -18
elif status == 'unversioned':
check = IconWdg( "Unversioned", IconWdg.HELP, width=12 )
elif status == 'missing':
check = IconWdg( "Missing", IconWdg.WARNING, width=12 )
elif status == 'editable':
check = IconWdg( "Editable", IconWdg.EDIT, width=12 )
elif status == 'modified':
check = IconWdg( "Modified", IconWdg.WARNING, width=12 )
else:
check = IconWdg( "Error (unknown status)", IconWdg.ERROR, width=12 )
if check:
td = table.add_cell(check)
td.add_style("width: 3px")
check.add_style("float: left")
check.add_style("margin-left: %spx" % margin_left)
check.add_style("margin-top: 4px")
item_div.add_color("color", "color", [0, 0, 50])
if status == 'missing':
item_div.add_style("opacity: 0.3")
else:
item_div.add_style("opacity: 0.8")
name_div = DivWdg()
td = table.add_cell(name_div)
name_div.add(basename)
name_div.add_style("float: left")
if status != "same":
name_div.add(" <i style='opacity: 0.5; font-size: 10px'>(%s)</i>" % status)
spath = path.replace(" ", "_")
# add the size of the file
size_div = DivWdg()
td = table.add_cell(size_div)
td.add_style("width: 60px")
size = my.sizes.get(spath)
if size is None or size == -1:
size_div.add("-")
else:
size_div.add(FormatValue().get_format_value(size, 'KB'))
size_div.add_style("margin-right: 5px")
size_div.add_style('text-align: right')
# FIXME: this still is needed right now, although really used.
my.subcontext_options = []
if not my.subcontext_options:
subcontext = TextWdg("subcontext")
subcontext = HiddenWdg("subcontext")
subcontext.add_class("spt_subcontext")
subcontext.add_style("float: right")
else:
subcontext = SelectWdg("subcontext")
subcontext = HiddenWdg("subcontext")
subcontext.set_option("show_missing", False)
subcontext.set_option("values", my.subcontext_options)
subcontext.add_empty_option("----")
subcontext.add_behavior( {
'type': 'click_up',
'propagate_evt': False,
'cbjs_action': '''
bvr.src_el.focus();
'''
} )
subcontext.add_style("display: none")
item_div.add(subcontext)
示例12: get_display
# 需要导入模块: from pyasm.widget import TextWdg [as 别名]
# 或者: from pyasm.widget.TextWdg import add_behavior [as 别名]
def get_display(my):
from tactic_client_lib import TacticServerStub
login = Environment.get_login()
user_name = login.get_login()
user_name = user_name.replace('.','')
barcodes = []
complete = False
errors = ''
first_loc_num1 = 5660
last_loc_num1 = 5991
first_loc_num2 = 6020
last_loc_num2 = 6037
if 'barcodes' in my.kwargs.keys():
barcodes = my.kwargs.get('barcodes').split(',')
if 'complete' in my.kwargs.keys():
complete = my.kwargs.get('complete')
if 'errors' in my.kwargs.keys():
errors = my.kwargs.get('errors')
table = Table()
table.add_attr('id','tracker_%s' % user_name)
table.add_attr('class','tracker_%s' % user_name)
if errors not in [None,'']:
table.add_row()
csp1 = table.add_cell(errors)
csp1.add_attr('colspan','2')
count = 0
if complete:
server = TacticServerStub.get()
t2 = Table()
for bc in barcodes:
if 'EMP' in bc:
that_user = server.eval("@SOBJECT(sthpw/login['barcode','%s'])" % bc)
if that_user:
that_user = that_user[0]
else:
that_user = {'login': 'UNKNOWN USER'}
t2.add_row()
t2.add_cell('USER: ')
t2.add_cell(that_user.get('login'))
t2.add_cell('BARCODE: %s' % bc)
for bc in barcodes:
bc_num = 555555555
if '2G' in bc:
bc_num = bc.replace('2G','').replace('A','').replace('B','').replace('C','').replace('V','')
bc_num = int(bc_num)
if (bc_num >= first_loc_num1 and bc_num <= last_loc_num1) or (bc_num >= first_loc_num2 and bc_num <= last_loc_num2):
that_location = server.eval("@SOBJECT(twog/inhouse_locations['barcode','%s'])" % bc)
if that_location:
that_location = that_location[0]
else:
that_location = {'name': 'UNKNOWN LOCATION'}
t2.add_row()
t2.add_cell('LOCATION: ')
t2.add_cell(that_location.get('name'))
t2.add_cell('BARCODE: %s' % bc)
for bc in barcodes:
bc_num = 555555555
if '2G' in bc:
bc_num = bc.replace('2G','').replace('A','').replace('B','').replace('C','').replace('V','')
bc_num = int(bc_num)
#if 'LOC' not in bc and 'EMP' not in bc:
if not ((bc_num >= first_loc_num1 and bc_num <= last_loc_num1) or (bc_num >= first_loc_num2 and bc_num <= last_loc_num2)) and 'EMP' not in bc:
that_src = server.eval("@SOBJECT(twog/source['barcode','%s'])" % bc)
if that_src:
that_src = that_src[0]
else:
that_src = {'title': 'UNKNOWN SOURCE', 'episode': '', 'season': '', 'part': ''}
full_name = that_src.get('title')
if that_src.get('episode') not in [None,'']:
full_name = '%s EPISODE: %s' % (full_name, that_src.get('episode'))
if that_src.get('season') not in [None,'']:
full_name = '%s SEASON: %s' % (full_name, that_src.get('season'))
if that_src.get('part') not in [None,'']:
full_name = '%s PART: %s' % (full_name, that_src.get('part'))
t2.add_row()
t2.add_cell('SOURCE: ')
t2.add_cell(full_name)
t2.add_cell('BARCODE: %s' % bc)
table.add_row()
csp2 = table.add_cell(t2)
csp2.add_attr('colspan','2')
else:
for bc in barcodes:
table.add_row()
table.add_cell('BARCODE: ')
oldtxt = TextWdg('oldtxt')
oldtxt.set_attr('id', 'txt_%s' % count)
oldtxt.set_value(bc)
table.add_cell(oldtxt)
count = count + 1
table.add_row()
nextbc = TextWdg('nextbc')
nextbc.add_attr('id', 'txt_%s' % count)
nextbc.add_behavior(my.get_entry_bvr(user_name))
table.add_cell('Barcode: ')
table.add_cell(nextbc)
widget = DivWdg()
widget.add(table)
#.........这里部分代码省略.........
示例13: get_page_one
# 需要导入模块: from pyasm.widget import TextWdg [as 别名]
# 或者: from pyasm.widget.TextWdg import add_behavior [as 别名]
def get_page_one(my):
info_page = DivWdg()
#info_page.add_class("spt_project_top")
info_page.add_style("font-size: 12px")
info_page.add_color("background", "background")
info_page.add_color("color", "color")
info_page.add_style("padding: 20px")
from tactic.ui.input import TextInputWdg
info_page.add("<b>Title:</b> ")
text = TextWdg("order_title")
#text = TextInputWdg(title="project_title")
info_page.add(text)
text.add_style("width: 250px")
info_page.add(HtmlElement.br(3))
span = DivWdg()
info_page.add(span)
span.add_style("padding: 20px 20px 20px 20px")
span.add(IconWdg("INFO", IconWdg.CREATE))
span.add_color("background", "background3")
span.add("The order title can be descriptive and contain spaces and special characters.")
info_page.add("<br/><br/><hr/><br/><br/>")
text.add_behavior( {
'type': 'change',
'cbjs_action': '''
var title = bvr.src_el.value;
var code = spt.convert_to_alpha_numeric(title);
var top = bvr.src_el.getParent(".twog_wizard_top");
var code_el = top.getElement(".spt_project_code");
code_el.value = code;
'''
} )
info_page.add("<b>Client Name: </b>")
text = TextWdg("client_name")
text.add_style("width: 250px")
text.add_class("spt_client_name")
info_page.add(text)
# line breaks
info_page.add(HtmlElement.br(2))
info_page.add("<b>Special code: </b>")
text = TextWdg("special code")
text.add_style("width: 250px")
# this is just meant for DOM element search covenience
text.add_class("spt_special_code")
# this behavior is go for eliminlating special symbols
#MTM this will help get rid of the stupid ascii errors
text.add_behavior( {
'type': 'blur',
'cbjs_action': '''
var value = bvr.src_el.value;
var code = spt.convert_to_alpha_numeric(value);
bvr.src_el.value = code;
'''
} )
info_page.add(text)
info_page.add(HtmlElement.br(4))
span = DivWdg()
info_page.add(span)
span.add_style("padding: 20px 20px 20px 20px")
span.add(IconWdg("INFO", IconWdg.CREATE))
span.add_color("background", "background3")
span.add("Some more info here.")
info_page.add(span)
info_page.add("<br/>")
return info_page
示例14: get_scale_wdg
# 需要导入模块: from pyasm.widget import TextWdg [as 别名]
# 或者: from pyasm.widget.TextWdg import add_behavior [as 别名]
def get_scale_wdg(my):
show_scale = my.kwargs.get("show_scale")
div = DivWdg()
if show_scale in [False, 'false']:
div.add_style("display: none")
div.add_style("padding: 5px")
div.add_class("spt_table_search")
hidden = HiddenWdg("prefix", "tile_layout")
div.add(hidden)
div.add_behavior( {
'type': 'load',
'cbjs_action': '''
spt.tile_layout = {}
spt.tile_layout.layout = null;
spt.tile_layout.set_layout = function(layout) {
if (!layout.hasClass("spt_layout")) {
layout = layout.getParent(".spt_layout");
}
spt.tile_layout.layout = layout;
return layout;
}
spt.tile_layout.get_scale = function() {
var scale_value = spt.tile_layout.layout.getElement(".spt_scale_value");
var value = scale_value.value;
value = parseInt(value);
return value;
}
spt.tile_layout.set_scale = function(scale) {
var scale_value = spt.tile_layout.layout.getElement(".spt_scale_value");
scale_value.value = scale;
var size_x = 240*scale/100;
var size_y = 160*scale/100;
//var top = bvr.src_el.getParent(".spt_tile_layout_top");
var top = spt.tile_layout.layout;
var els = top.getElements(".spt_tile_content");
for (var i = 0; i < els.length; i++) {
var el = els[i];
el.setStyle( "width", size_x);
el.setStyle( "height", size_y);
}
spt.container.set_value("tile_layout::scale", scale);
}
spt.tile_layout.drag_start_x = null;
spt.tile_layout.drag_start_value = null;
spt.tile_layout.drag_setup = function(evt, bvr, mouse_411) {
spt.tile_layout.set_layout(bvr.src_el);
spt.tile_layout.drag_start_x = mouse_411.curr_x;
var src_el = spt.behavior.get_bvr_src( bvr );
if (!src_el.value) {
src_el.value = 0;
}
spt.tile_layout.drag_start_value = src_el.value;
src_el.focus();
src_el.select();
}
spt.tile_layout.drag_motion = function(evt, bvr, mouse_411) {
var start_value = spt.tile_layout.drag_start_value;
if (isNaN(parseInt(start_value))) {
return;
}
var dx = mouse_411.curr_x - spt.tile_layout.drag_start_x;
var increment = parseInt(dx / 5);
var multiplier;
if (increment < 0)
multiplier = 0.975;
else
multiplier = 1 / 0.975;
increment = Math.abs(increment);
var scale = spt.tile_layout.drag_start_value;
for (var i = 0; i < increment; i++) {
scale = scale * multiplier;
}
scale = parseInt(scale);
spt.tile_layout.set_scale(scale);
}
''' } )
div.add_behavior( {
'type': 'load',
'cbjs_action': '''
#.........这里部分代码省略.........
示例15: get_display
# 需要导入模块: from pyasm.widget import TextWdg [as 别名]
# 或者: from pyasm.widget.TextWdg import add_behavior [as 别名]
def get_display(my):
my.sob_code = str(my.kwargs.get("sob_code"))
my.sob_sk = str(my.kwargs.get("sob_sk"))
my.sob_st = str(my.kwargs.get("sob_st"))
my.sob_name = str(my.kwargs.get("sob_name"))
my.pipeline = str(my.kwargs.get("pipeline"))
my.order_sk = str(my.kwargs.get("order_sk"))
order_code = my.order_sk.split("code=")[1]
if "is_master" in my.kwargs.keys():
my.is_master = my.kwargs.get("is_master")
else:
order_search = Search("twog/order")
order_search.add_filter("code", order_code)
order = order_search.get_sobject()
order_classification = order.get_value("classification")
if order_classification in ["master", "Master"]:
my.is_master = True
if my.sob_st == "twog/title":
my.prereq_st = "twog/title_prereq"
my.prereq_field = "title_code"
elif my.sob_st == "twog/work_order":
my.prereq_st = "twog/work_order_prereq"
my.prereq_field = "work_order_code"
user_group_names = Environment.get_group_names()
groups_str = ""
for mg in user_group_names:
if groups_str == "":
groups_str = mg
else:
groups_str = "%s,%s" % (groups_str, mg)
user_is_scheduler = False
if "scheduling" in groups_str:
user_is_scheduler = True
prereq_search = Search(my.prereq_st)
prereq_search.add_filter(my.prereq_field, my.sob_code)
prereqs = prereq_search.get_sobjects()
overhead = Table()
overhead.add_attr("class", "overhead_%s" % my.sob_code)
table = Table()
table.add_attr("class", "prereq_adder_%s" % my.sob_code)
table.add_row()
if my.sob_st == "twog/work_order" and user_is_scheduler:
kill_title_pqs_btn = table.add_cell('<input type="button" value="Remove\nTitle PreReqs"/>')
kill_title_pqs_btn.add_attr("colspan", "2")
kill_title_pqs_btn.add_behavior(
get_kill_wos_title_prereqs_behavior(my.sob_sk, my.order_sk, my.sob_name, my.pipeline)
)
else:
table.add_cell(" ")
table.add_cell(" ")
table.add_cell(" ")
table.add_cell(" ")
sat = table.add_cell("Satisfied?")
sat.add_attr("align", "center")
table.add_cell(" ")
for p in prereqs:
table.add_row()
if user_is_scheduler:
killer = table.add_cell(my.x_butt)
killer.add_style("cursor: pointer;")
killer.add_behavior(
get_prereq_killer_behavior(
p.get_value("code"),
my.prereq_st,
my.sob_code,
my.sob_sk,
my.sob_st,
my.sob_name,
my.pipeline,
my.order_sk,
)
)
prereq_text = "PreReq: "
if my.sob_st == "twog/work_order":
if p.get_value("from_title") == True:
prereq_text = "Title PreReq: "
alabel = table.add_cell(prereq_text)
alabel.add_attr("align", "center")
table.add_cell(
'<input type="text" class="prereq_%s" value="%s" style="width: 500px;"/>'
% (p.get_value("code"), p.get_value("prereq"))
)
save_butt = table.add_cell('<input type="button" class="save_%s" value="Save"/>' % (p.get_value("code")))
save_butt.add_behavior(
get_save_prereq_behavior(p.get_value("code"), my.prereq_st, my.sob_code, my.pipeline)
)
if p.get_value("satisfied") == True:
check_val = "true"
else:
check_val = "false"
checkbox = CustomCheckboxWdg(
name="satisfied_%s" % p.get_value("code"),
value_field=p.get_value("code"),
checked=check_val,
dom_class="prereq_selector",
code=p.get_value("code"),
#.........这里部分代码省略.........