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


Python Form.dropdown方法代码示例

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


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

示例1: main

# 需要导入模块: from forms import Form [as 别名]
# 或者: from forms.Form import dropdown [as 别名]
    def main(self, message='', **kwargs):
        if not cfg.users.expert():
            return '<p>' + _('Only members of the expert group are allowed to see and modify the system setup.') + '</p>'

        sys_store = filedict_con(cfg.store_file, 'sys')
        hostname = get_hostname()
        # this layer of persisting configuration in sys_store could/should be
        # removed -BLN
        defaults = {'time_zone': "slurp('/etc/timezone').rstrip()",
                    'hostname': "hostname",
                    }
        for k,c in defaults.items():
            if not k in kwargs:
                try:
                    kwargs[k] = sys_store[k]
                except KeyError:
                    exec("if not '%(k)s' in kwargs: sys_store['%(k)s'] = kwargs['%(k)s'] = %(c)s" % {'k':k, 'c':c})
        # over-ride the sys_store cached value
        kwargs['hostname'] = hostname

        ## Get the list of supported timezones and the index in that list of the current one
        module_file = __file__
        if module_file.endswith(".pyc"):
            module_file = module_file[:-1]
        time_zones = json.loads(slurp(os.path.join(os.path.dirname(os.path.realpath(module_file)), "time_zones")))
        for i in range(len(time_zones)):
            if kwargs['time_zone'] == time_zones[i]:
                time_zone_id = i
                break

        ## A little sanity checking.  Make sure the current timezone is in the list.
        try:
            cfg.log('kwargs tz: %s, from_table: %s' % (kwargs['time_zone'], time_zones[time_zone_id]))
        except NameError:
            cfg.log.critical("Unknown Time Zone: %s" % kwargs['time_zone'])
            raise cherrypy.HTTPError(500, "Unknown Time Zone: %s" % kwargs['time_zone'])

        ## And now, the form.
        form = Form(title=_("General Config"), 
                        action="/sys/config/general/index", 
                        name="config_general_form",
                        message=message )
        form.html(self.help())
        form.dropdown(_("Time Zone"), name="time_zone", vals=time_zones, select=time_zone_id)
        form.html("<p>Your hostname is the local name by which other machines on your LAN can reach you.</p>")
        form.text_input('Hostname', name='hostname', value=kwargs['hostname'])
        form.submit(_("Submit"))
        return form.render()
开发者ID:copyninja,项目名称:Plinth,代码行数:50,代码来源:config.py

示例2: main

# 需要导入模块: from forms import Form [as 别名]
# 或者: from forms.Form import dropdown [as 别名]
    def main(self, wan_ip0=0, wan_ip1=0, wan_ip2=0, wan_ip3=0, 
             subnet0=0, subnet1=0, subnet2=0, subnet3=0, 
             gateway0=0, gateway1=0, gateway2=0, gateway3=0, 
             dns10=0, dns11=0, dns12=0, dns13=0, 
             dns20=0, dns21=0, dns22=0, dns23=0, 
             dns30=0, dns31=0, dns32=0, dns33=0, 
             message=None, **kwargs):
        if not cfg.users.expert():
            return ''

        store = filedict_con(cfg.store_file, 'router')
        defaults = {'connect_type': "'DHCP'",
                    }
        for k,c in defaults.items():
            if not k in kwargs:
                try:
                    kwargs[k] = store[k]
                except KeyError:
                    exec("if not '%(k)s' in kwargs: store['%(k)s'] = kwargs['%(k)s'] = %(c)s" % {'k':k, 'c':c})

        form = Form(title="WAN Connection", 
                        action="/router/setup/wan/index", 
                        name="wan_connection_form",
                        message=message)
        form.dropdown('Connection Type', vals=["DHCP", "Static IP"], id="connect_type", onchange="hideshow_static()")
        form.html('<div id="static_ip_form">')
        form.dotted_quad("WAN IP Address", name="wan_ip", quad=[wan_ip0, wan_ip1, wan_ip2, wan_ip3])
        form.dotted_quad("Subnet Mask", name="subnet", quad=[subnet0, subnet1, subnet2, subnet3])
        form.dotted_quad("Gateway", name="gateway", quad=[gateway0, gateway1, gateway2, gateway3])
        form.dotted_quad("Static DNS 1", name="dns1", quad=[dns10, dns11, dns12, dns13])
        form.dotted_quad("Static DNS 2", name="dns2", quad=[dns20, dns21, dns22, dns23])
        form.dotted_quad("Static DNS 3", name="dns3", quad=[dns30, dns31, dns32, dns33])
        form.html('</div>')
        form.html("""  <script LANGUAGE="JavaScript">
    <!--
      hideshow_static();
    // --> 
  </script>""")
        form.submit("Set Wan")
        return form.render()
开发者ID:copiesofcopies,项目名称:Plinth,代码行数:42,代码来源:router.py

示例3: main

# 需要导入模块: from forms import Form [as 别名]
# 或者: from forms.Form import dropdown [as 别名]
    def main(self, message="", **kwargs):
        sys_store = filedict_con(cfg.store_file, "sys")
        defaults = {"time_zone": "slurp('/etc/timezone').rstrip()", "hostname": "gethostname()"}
        for k, c in defaults.items():
            if not k in kwargs:
                try:
                    kwargs[k] = sys_store[k]
                except KeyError:
                    exec("if not '%(k)s' in kwargs: sys_store['%(k)s'] = kwargs['%(k)s'] = %(c)s" % {"k": k, "c": c})

        ## Get the list of supported timezones and the index in that list of the current one
        module_file = __file__
        if module_file.endswith(".pyc"):
            module_file = module_file[:-1]
        time_zones = json.loads(slurp(os.path.join(os.path.dirname(os.path.realpath(module_file)), "time_zones")))
        for i in range(len(time_zones)):
            if kwargs["time_zone"] == time_zones[i]:
                time_zone_id = i
                break

        ## A little sanity checking.  Make sure the current timezone is in the list.
        try:
            cfg.log("kwargs tz: %s, from_table: %s" % (kwargs["time_zone"], time_zones[time_zone_id]))
        except NameError:
            cfg.log.critical("Unknown Time Zone: %s" % kwargs["time_zone"])
            raise cherrypy.HTTPError(500, "Unknown Time Zone: %s" % kwargs["time_zone"])

        ## And now, the form.
        form = Form(
            title=_("General Config"), action="/sys/config/general/index", name="config_general_form", message=message
        )
        form.html(self.help())
        form.dropdown(_("Time Zone"), name="time_zone", vals=time_zones, select=time_zone_id)
        form.html("<p>Your hostname is the local name by which other machines on your LAN can reach you.</p>")
        form.text_input("Hostname", name="hostname", value=kwargs["hostname"])
        form.submit(_("Submit"))
        return form.render()
开发者ID:Keith2,项目名称:Plinth,代码行数:39,代码来源:config.py


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