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


Python OptionsWidget._attributes方法代码示例

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


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

示例1: widget

# 需要导入模块: from gluon.sqlhtml import OptionsWidget [as 别名]
# 或者: from gluon.sqlhtml.OptionsWidget import _attributes [as 别名]
    def widget(self, field, value,**attributes):



        #generate the standard widget for this field
        if self.multiple == True:
            select_widget = MultipleOptionsWidget.widget(field, value, size=7)
            attr =  MultipleOptionsWidget._attributes(field, {'value':value}, **attributes)
        else:
            select_widget = OptionsWidget.widget(field, value)
            attr = OptionsWidget._attributes(field, {'value':value}, **attributes)

        #get the widget's id (need to know later on so can tell receiving controller what to update)
        my_select_id = select_widget.attributes.get('_id', None)
        add_args = [my_select_id]
        #create a div that will load the specified controller via ajax
        form_loader_div = DIV(LOAD(c=self.controller, f=self.function, args=add_args,ajax=True), _id=my_select_id+"_dialog-form", _title=self.form_title)
        #generate the "add" button that will appear next the options widget and open our dialog

        activator_button = A(XML('<button type="button" class="btn btn-primary" data-toggle="button">'+T(self.button_text)+'</button>'), _id=my_select_id+"_option_add_trigger")
        #create javascript for creating and opening the dialog
        js = '$( "#%s_dialog-form" ).dialog({autoOpen: false, show: "blind", hide: "explode", width: %s});' % (my_select_id, self.dialog_width)
        js += '$( "#%s_option_add_trigger" ).click(function() { $( "#%s_dialog-form" ).dialog( "open" );return false;}); ' % (my_select_id, my_select_id)        #decorate our activator button for good measure
        js += '$(function() { $( "#%s_option_add_trigger" ).button({text: true, icons: { primary: "ui-icon-circle-plus"} }); });' % (my_select_id)
        jq_script=SCRIPT(js, _type="text/javascript")

        wrapper = DIV(_id=my_select_id+"_adder_wrapper")
        wrapper.components.extend([select_widget, form_loader_div, activator_button, jq_script])
        return wrapper
开发者ID:aferhati,项目名称:plug-and-play-1.0-RC,代码行数:31,代码来源:a_widgets.py

示例2: widget

# 需要导入模块: from gluon.sqlhtml import OptionsWidget [as 别名]
# 或者: from gluon.sqlhtml.OptionsWidget import _attributes [as 别名]
    def widget(field, value, **attributes):
        """
        generates a TABLE tag, including INPUT checkboxes (multiple allowed)

        see also: :meth:`FormWidget.widget`
        """

        # was values = re.compile('[\w\-:]+').findall(str(value))
        if isinstance(value, (list, tuple)):
            values = [str(v) for v in value]
        else:
            values = [str(value)]

        attr = OptionsWidget._attributes(field, {}, **attributes)

        requires = field.requires
        if not isinstance(requires, (list, tuple)):
            requires = [requires]
        if requires:
            if hasattr(requires[0], 'options'):
                options = requires[0].options()
            else:
                raise SyntaxError('widget cannot determine options of %s' % field)

        options = [(k, v) for k, v in options if k != '']
        opts = []
        cols = attributes.get('cols', 1)
        totals = len(options)
        mods = totals % cols
        rows = totals / cols
        if mods:
            rows += 1

        for r_index in range(rows):
            tds = []
            for k, v in options[r_index * cols:(r_index + 1) * cols]:
                if k in values:
                    r_value = k
                else:
                    r_value = []
                tds.append(LI(INPUT(_type='checkbox', _id='%s%s' % (field.name, k), _name=field.name,
                         requires=attr.get('requires', None),
                         hideerror=True, _value=k,
                         value=r_value), LABEL(v, _for='%s%s' % (field.name, k))))
            opts.append(UL(tds, _style='list-style-type: none;'))

        if opts:
            opts[-1][0][0]['hideerror'] = False
        return DIV(*opts, **attr)
开发者ID:1nn7erplay,项目名称:Movuca,代码行数:51,代码来源:widgets.py


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