python - 如何在烧瓶 wtf 中创建下拉字段
问题描述
我想使用烧瓶 wtforms 创建下拉菜单。我在 bootstrap 4 中找到了下拉菜单,但我无法使用它。我想用烧瓶 wtf 来做。这是我想要实现的目标:
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet"/>
<form class="" action="index.html" method="post">
<div class="form-group">
<label for="exampleFormControlSelect1">Example select</label>
<select class="form-control" id="exampleFormControlSelect1">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
</select>
</div>
</form>
解决方案
wtforms
提供SelectField
请参阅文档 https://wtforms.readthedocs.io/en/2.3.x/fields/#wtforms.fields.SelectField
示例(来自文档)
class PastebinEntry(Form):
language = SelectField(u'Programming Language', choices=[('cpp', 'C++'), ('py', 'Python'), ('text', 'Plain Text')])
推荐阅读
- css - 具有响应式设计和纯 CSS 的动态导航
- selenium - 如何基于 JS 选择动态列表值与 Selenium Webdriver 和 Java 反应?
- reactjs - ReactJS:创建具有动态内容的可重用表格行组件
- javascript - 使用 waitForKeyElements 依次单击两个按钮,一旦页面正确加载
- django - Django不发送电子邮件
- javascript - 如何关闭相机灯(手电筒)?
- java - 文件不会编译
- json - 在 package.json 中使用依赖项
- css - 转换完成后将可见性属性更改为隐藏不起作用
- python - 在 Tensorflow 中生成关键点热图