本文整理匯總了Python中pyasm.widget.TextAreaWdg.add_behavior方法的典型用法代碼示例。如果您正苦於以下問題:Python TextAreaWdg.add_behavior方法的具體用法?Python TextAreaWdg.add_behavior怎麽用?Python TextAreaWdg.add_behavior使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pyasm.widget.TextAreaWdg
的用法示例。
在下文中一共展示了TextAreaWdg.add_behavior方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: get_display
# 需要導入模塊: from pyasm.widget import TextAreaWdg [as 別名]
# 或者: from pyasm.widget.TextAreaWdg import add_behavior [as 別名]
def get_display(self):
self.run_init()
name = self.get_name()
if not name:
name = self.kwargs.get("name")
if self.is_refresh:
widget = Widget()
else:
widget = DivWdg()
self.set_as_panel(widget)
widget.add_class("spt_note_top")
widget.set_attr("spt_name", name)
widget.set_attr("spt_parent_key", self.parent_key)
web = WebContainer.get_web()
value = web.get_form_value(name)
text = TextAreaWdg(name)
widget.add(text)
if value:
text.set_value(value)
text.add_style("width: 100%")
text.add_style("min-width: 200")
text.add_attr("rows", "5")
text.add_class('spt_note_text')
color = text.get_color("background", -10);
text.add_behavior( {
'type': 'blur',
'cbjs_action': '''
//spt.dg_table._toggle_commit_btn($(this), false);
var el = bvr.src_el;
var td = el.getParent(".spt_table_td");
var tbody = el.getParent(".spt_table_tbody");
td.setStyle('background-color','#909977');
td.addClass('spt_value_changed');
tbody.addClass('spt_value_changed');
td.setAttribute('spt_input_value', el.value);
'''
} )
#text.add_event("onblur", "spt.dg_table._toggle_commit_btn($(this), false);$(this).getParent('.spt_table_td').setStyle('background-color','#030');$(this).getParent('.spt_table_td').addClass('spt_value_changed');$(this).getParent('.spt_table_tbody').addClass('spt_value_changed');$(this).getParent('.spt_table_td').setAttribute('spt_input_value',this.value)")
#text.add_event("onclick", "spt.dg_table.edit_cell_cbk( this, spt.kbd.special_keys_map.ENTER)" );
#behavior = {
# 'type': 'keyboard',
# 'kbd_handler_name': 'DgTableMultiLineTextEdit'
#}
#text.add_behavior(behavior)
action_wdg = self.get_action_wdg(name)
widget.add(action_wdg)
return widget
示例2: get_display
# 需要導入模塊: from pyasm.widget import TextAreaWdg [as 別名]
# 或者: from pyasm.widget.TextAreaWdg import add_behavior [as 別名]
def get_display(my):
top = my.top
view = my.kwargs.get("view")
top.add_class("spt_help_edit_content")
search = Search("config/widget_config")
search.add_filter("category", "HelpWdg")
search.add_filter("view", view)
sobject = search.get_sobject()
if not sobject:
value = ""
search_key = ""
else:
xml_value = sobject.get_xml_value("config")
value = xml_value.get_value("config/%s/html/div" % (view) )
search_key = sobject.get_search_key()
title_wdg = DivWdg()
top.add(title_wdg)
title_wdg.add("<b>View: %s</b>" % view)
title_wdg.add_style("font-style: bold")
title_wdg.add_style("padding: 5px")
title_wdg.add_gradient("background", "background", 0, -10)
hidden = HiddenWdg("view")
top.add(hidden)
hidden.set_value(view)
text = TextAreaWdg("content")
text_id = text.set_unique_id()
text.set_value(value)
from tactic.ui.widget import ActionButtonWdg
if sobject:
delete_button = ActionButtonWdg(title="Delete")
top.add(delete_button)
delete_button.add_style("float: right")
delete_button.add_style("margin-top: -3px")
delete_button.add_behavior( {
'type': 'click_up',
'search_key': search_key,
'cbjs_action': '''
if (!confirm("Are you sure you wish to delete this help page?")) {
return;
}
var server = TacticServerStub.get();
server.delete_sobject(bvr.search_key);
var top = bvr.src_el.getParent(".spt_help_edit_top");
spt.panel.refresh(top);
'''
})
test_button = ActionButtonWdg(title="Preview")
top.add(test_button)
test_button.add_style("float: right")
test_button.add_style("margin-top: -3px")
test_button.add_behavior( {
'type': 'click_up',
'text_id': text_id,
'cbjs_action': '''
var js_file = "ckeditor/ckeditor.js";
var url = "/context/spt_js/" + js_file;
var js_el = document.createElement("script");
js_el.setAttribute("type", "text/javascript");
js_el.setAttribute("src", url);
var head = document.getElementsByTagName("head")[0];
head.appendChild(js_el);
var cmd = "CKEDITOR.instances." + bvr.text_id + ".getData()";
var text_value = eval( cmd );
bvr.options = {};
bvr.options.html = text_value;
spt.named_events.fire_event("show_help", bvr)
'''
})
save_button = ActionButtonWdg(title="Save")
top.add(save_button)
save_button.add_style("float: right")
save_button.add_style("margin-top: -3px")
top.add("<br/>")
#.........這裏部分代碼省略.........
示例3: get_chat_wdg
# 需要導入模塊: from pyasm.widget import TextAreaWdg [as 別名]
# 或者: from pyasm.widget.TextAreaWdg import add_behavior [as 別名]
def get_chat_wdg(my, key, interval=False):
div = DivWdg()
div.add_class("spt_chat_session_top")
div.add_color("background", "background")
title_wdg = DivWdg()
div.add(title_wdg)
title_wdg.add_color("background", "background3")
title_wdg.add_style("padding: 5px")
title_wdg.add_style("font-weight: bold")
title_wdg.add_border()
icon = IconButtonWdg(title="Remove Chat", icon=IconWdg.DELETE)
icon.add_style("float: right")
icon.add_style("margin-top: -5px")
title_wdg.add(icon)
icon.add_behavior( {
'type': 'click_up',
'key': key,
'cbjs_action': '''
var server = TacticServerStub.get();
var top = bvr.src_el.getParent(".spt_chat_session_top");
spt.behavior.destroy_element(top);
'''
} )
current_user = Environment.get_user_name()
logins = Search.eval("@SOBJECT(sthpw/subscription['message_code','%s'].sthpw/login)" % key)
for login in logins:
if login.get_value("login") == current_user:
continue
thumb = ThumbWdg()
thumb.set_icon_size(45)
thumb.set_sobject(login)
thumb.add_style("float: left")
thumb.add_style("margin: -5px 10px 0px -5px")
title_wdg.add(thumb)
title_wdg.add(login.get_value("display_name"))
title_wdg.add("<br clear='all'/>")
history_div = DivWdg()
div.add(history_div)
history_div.add_class("spt_chat_history")
history_div.add_style("width: auto")
history_div.add_style("height: auto")
history_div.add_style("max-height: 400px")
history_div.add_style("padding: 5px")
history_div.add_class("spt_resizable")
history_div.add_border()
history_div.add_style("overflow-y: auto")
#history_div.add_style("font-size: 0.9em")
search = Search("sthpw/message_log")
search.add_filter("message_code", key)
search.add_order_by("timestamp")
message_logs = search.get_sobjects()
last_login = None;
last_date = None;
for message_log in message_logs:
login = message_log.get("login")
message = message_log.get("message")
timestamp = message_log.get_datetime_value("timestamp")
#timestamp = timestamp.strftime("%b %d, %Y - %H:%M")
timestamp_str = timestamp.strftime("%H:%M")
date_str = timestamp.strftime("%b %d, %Y")
msg = "";
msg += "<table style='margin-top: 5px; font-size: 0.9em; width: 100%'><tr><td colspan='2'>";
if date_str != last_date:
msg += "<br/><b style='font-size: 1.0em'>"+date_str+"</b><hr/></td></tr>";
msg += "<tr><td>";
last_login = None
if login != last_login:
msg += "<b>"+login+"</b><br/>";
msg += message.replace("\n",'<br/>');
msg += "</td><td style='text-align: right; margin-bottom: 5px; width: 75px; vertical-align: top'>";
msg += timestamp_str;
msg += "</td></tr></table>";
history_div.add(msg)
last_login = login
last_date = date_str
history_div.add_behavior( {
'type': 'load',
'cbjs_action': '''
bvr.src_el.scrollTop = bvr.src_el.scrollHeight;
'''
#.........這裏部分代碼省略.........
示例4: CKEditorWdg
# 需要導入模塊: from pyasm.widget import TextAreaWdg [as 別名]
# 或者: from pyasm.widget.TextAreaWdg import add_behavior [as 別名]
class CKEditorWdg(BaseRefreshWdg):
def init(self):
name = self.kwargs.get("name")
assert(name)
self.text = TextAreaWdg(name)
self.text_id = self.kwargs.get("text_id")
if not self.text_id:
self.text_id = self.text.set_unique_id()
def get_display(self):
top = self.top
top.add_style("min-width: 600px")
top.add_class("spt_ckeditor_top")
top.add_attr("text_id", self.text_id)
top.add(self.text)
value = self.kwargs.get("value")
if value:
self.text.set_value(value)
self.text.add_style("width: 100%")
self.text.add_style("height: 100%")
self.text.add_style("min-height: 500px")
self.text.add_style("display: none")
self.text.set_id(self.text_id)
self.text.add_behavior( {
'type': 'load',
'color': self.text.get_color("background", -10),
'text_id': self.text_id,
'cbjs_action': '''
/*
var js_file = "ckeditor/ckeditor.js";
var url = "/context/spt_js/" + js_file;
var js_el = document.createElement("script");
js_el.setAttribute("type", "text/javascript");
js_el.setAttribute("src", url);
var head = document.getElementsByTagName("head")[0];
head.appendChild(js_el);
*/
var init = function() {
CKEDITOR.on( 'instanceReady', function( ev )
{
ev.editor.dataProcessor.writer.indentationChars = ' ';
});
var config = {
toolbar: 'Full',
uiColor: bvr.color,
height: '800px'
};
/*
config.toolbar_Full =
[
['Source'],
//['Cut','Copy','Paste'],
['Undo','Redo','-','Find','Replace'],
['Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'ImageButton', 'HiddenField'],
['Bold','Italic','Underline','Strike','-','Subscript','Superscript'],
'/',
['NumberedList','BulletedList','-','Outdent','Indent','Blockquote','CreateDiv'],
['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],
['HorizontalRule','SpecialChar'],
['Styles','Format','FontSize'],
['TextColor','BGColor'],
['Maximize', 'ShowBlocks']
];
*/
config.toolbar_Full =
[
{ name: 'document', items : [ 'Source','-','Save','NewPage','DocProps','Preview','Print','-','Templates' ] },
{ name: 'clipboard', items : [ 'Cut','Copy','Paste','PasteText','PasteFromWord','-','Undo','Redo' ] },
{ name: 'editing', items : [ 'Find','Replace','-','SelectAll','-','SpellChecker', 'Scayt' ] },
{ name: 'forms', items : [ 'Form', 'Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'ImageButton',
'HiddenField' ] },
'/',
{ name: 'basicstyles', items : [ 'Bold','Italic','Underline','Strike','Subscript','Superscript','-','RemoveFormat' ] },
{ name: 'paragraph', items : [ 'NumberedList','BulletedList','-','Outdent','Indent','-','Blockquote','CreateDiv',
'-','JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock','-','BidiLtr','BidiRtl' ] },
{ name: 'links', items : [ 'Link','Unlink','Anchor' ] },
{ name: 'insert', items : [ 'Image','Flash','Table','HorizontalRule','Smiley','SpecialChar','PageBreak','Iframe' ] },
'/',
{ name: 'styles', items : [ 'Styles','Format','Font','FontSize' ] },
{ name: 'colors', items : [ 'TextColor','BGColor' ] },
{ name: 'tools', items : [ 'Maximize', 'ShowBlocks','-','About' ] }
];
config.entities = false;
config.basicEntities = false;
#.........這裏部分代碼省略.........