当前位置: 首页>>代码示例>>Python>>正文


Python HtmlElement.input方法代码示例

本文整理汇总了Python中pyasm.web.HtmlElement.input方法的典型用法代码示例。如果您正苦于以下问题:Python HtmlElement.input方法的具体用法?Python HtmlElement.input怎么用?Python HtmlElement.input使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyasm.web.HtmlElement的用法示例。


在下文中一共展示了HtmlElement.input方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_example_display

# 需要导入模块: from pyasm.web import HtmlElement [as 别名]
# 或者: from pyasm.web.HtmlElement import input [as 别名]
    def get_example_display(self):

        div = DivWdg()

        int_edit_div = DivWdg()
        int_edit_div.add_styles( "width: auto; height: auto;" )
        int_edit_div.add_class( "SPT_INPUT_WRAPPER" )

        int_edit = HtmlElement.input()
        int_edit.set_attr("type", "text")
        int_edit.set_attr("value", "856")
        int_edit.set_attr("name", "int_edit")
        int_edit.add_behavior( { 'type': 'keyboard', 'kbd_handler_name': 'IntegerTextEdit',
                                 'validation_warning': 'You must enter a number greater than 50',
                                 'cbjs_validation':
                                 '''
                                 log.debug( "Check the value: " + value );
                                 if( parseInt( value ) <= 50 ) {
                                     return false;
                                 }
                                 return true;
                                 '''
                                 } )

        int_edit_div.add( int_edit )
        int_edit_div.add( "<img class='SPT_INPUT_VALIDATION_WARNING' src='/context/icons/silk/exclamation.png' " \
                            "title='' style='display: none;' />" )
        int_edit_div.add( " Enter a value of 50 or less to fail validation, anything over 50 to succeed" \
                          " -- Integer edit example (uses 'kbd_handler_name' of 'IntegerTextEdit')" )

        div.add( int_edit_div )
        div.add( "<br/><br/>" )

        float_edit = HtmlElement.input()
        float_edit.set_attr("type", "text")
        float_edit.set_attr("value", "12.45")
        float_edit.set_attr("name", "int_edit")
        float_edit.add_behavior( { 'type': 'keyboard', 'kbd_handler_name': 'FloatTextEdit' } )

        div.add( float_edit )
        div.add( " Float edit example (uses 'kbd_handler_name' of 'FloatTextEdit')" )
        div.add( "<br/><br/>" )

        textarea = HtmlElement.textarea( 10, 40, "This is a multi-line example." )
        textarea.add_behavior( { 'type': 'keyboard', 'kbd_handler_name': 'MultiLineTextEdit' } )

        div.add( textarea )
        div.add( " Multi-line edit example (uses 'kbd_handler_name' of 'MultiLineTextEdit')" )
        div.add( "<br/><br/>" )

        return div
开发者ID:mincau,项目名称:TACTIC,代码行数:53,代码来源:keyboard_handler_examples_wdg.py

示例2: get_display

# 需要导入模块: from pyasm.web import HtmlElement [as 别名]
# 或者: from pyasm.web.HtmlElement import input [as 别名]
    def get_display(my):

        top = my.top
        form = my.form
        form.add_style("margin: 0px")
        form.add_style("padding: 0px")
        top.add(form)


        input = HtmlElement.input()
        form.add(input)
        input.set_attr("name", "file")
        input.add_class("spt_file")
        input.set_attr("type", "file")
        #input.add_style("display: none")
        #input.add_style("visibility: hidden")
        input.add_style("position: absolute")
        input.add_style("margin-left: -5000px")
        #input.add_style("margin-left: 500px")
        #input.add_style("margin-top: -50px")

        multiple = my.kwargs.get("multiple")
        if multiple in [True, 'true']:
            input.add_attr("multiple", "multiple")

        from pyasm.common import Container
        if not Container.get_dict("JSLibraries", "spt_html5upload"):
            form.add_behavior( {
            'type': 'load',
            'form_id': my.form_id,
            'cbjs_action': '''

if (spt.html5upload)
    return;

spt.Environment.get().add_library("spt_html5upload")

spt.html5upload = {};
spt.html5upload.form = $(bvr.form_id);
spt.html5upload.files = [];
spt.html5upload.events = {};


spt.html5upload.set_form = function(form) {
    if (!form) {
        spt.alert('Cannot initialize the HTML upload. Invalid form detected.');
        return;
    }
    spt.html5upload.form = form;
}

// get the last one in the list since this FileList is readonly and it is additive if multiple attr is on
spt.html5upload.get_file = function() {
    var files = spt.html5upload.get_files();
    if (files.length == 0) {
        return null;
    }
    return files[files.length-1];
}


//FIXME: it doesn't need to be stored as files since it should be called
// every time an upload occurs
spt.html5upload.get_files = function() {
    var file_input = spt.html5upload.form.getElement('.spt_file');
    spt.html5upload.files = file_input.files;
    return spt.html5upload.files;
}


spt.html5upload.select_file = function(onchange) {
    var files = spt.html5upload.select_files(onchange);
    if (!files) {
        spt.alert('You may need to refresh this page.');
        return null;
    }
        
    if (files.length == 0) {
        return null;
    }
    return files[0];
}


spt.html5upload.select_files = function(onchange) {
    var form = spt.html5upload.form;
    if (!form) {
        spt.alert('Cannot locate the upload form. Refresh this page/tab and try again');
        return; 
    }
    var el = form.getElement(".spt_file") ;
  
    /*
    if (replace) {
        spt.html5upload.events['select_file'] = null;
        el.removeEventListener("change", onchange);
        alert('remove')
    }
    */
   
#.........这里部分代码省略.........
开发者ID:makeittotop,项目名称:python-scripts,代码行数:103,代码来源:html5_upload_wdg.py


注:本文中的pyasm.web.HtmlElement.input方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。