PyWebIO Input Usage Demonstrate various input usage supported by PyWebIO. 演示PyWebIO输入模块的使用
()
| 12 | |
| 13 | |
| 14 | def main(): |
| 15 | """PyWebIO Input Usage |
| 16 | |
| 17 | Demonstrate various input usage supported by PyWebIO. |
| 18 | 演示PyWebIO输入模块的使用 |
| 19 | """ |
| 20 | set_env(auto_scroll_bottom=True) |
| 21 | |
| 22 | put_markdown(t("""# PyWebIO Input Example |
| 23 | |
| 24 | You can get the source code of this demo in [here](https://github.com/wang0618/PyWebIO/blob/dev/demos/input_usage.py) |
| 25 | |
| 26 | This demo only introduces part of the functions of the PyWebIO input module. For the complete features, please refer to the [User Guide](https://pywebio.readthedocs.io/zh_CN/latest/guide.html). |
| 27 | |
| 28 | The input functions are all defined in the `pywebio.input` module and can be imported using `from pywebio.input import *`. |
| 29 | |
| 30 | ### Basic input |
| 31 | Here are some basic types of input. |
| 32 | |
| 33 | #### Text input |
| 34 | ```python |
| 35 | name = input("What's your name?") |
| 36 | ``` |
| 37 | """, |
| 38 | """# PyWebIO 输入演示 |
| 39 | |
| 40 | 在[这里](https://github.com/wang0618/PyWebIO/blob/dev/demos/input_usage.py)可以获取本Demo的源码。 |
| 41 | |
| 42 | 本Demo仅提供了PyWebIO输入模块的部分功能的演示,完整特性请参阅[用户指南](https://pywebio.readthedocs.io/zh_CN/latest/guide.html)。 |
| 43 | |
| 44 | PyWebIO的输入函数都定义在 `pywebio.input` 模块中,可以使用 `from pywebio.input import *` 引入。 |
| 45 | |
| 46 | ### 基本输入 |
| 47 | 首先是一些基本类型的输入 |
| 48 | |
| 49 | #### 文本输入 |
| 50 | ```python |
| 51 | name = input("What's your name?") |
| 52 | ``` |
| 53 | """)) |
| 54 | put_text(t("The results of the above example are as follows:", "这样一行代码的效果如下:")) |
| 55 | name = input("What's your name?") |
| 56 | put_markdown("`name = %r`" % name) |
| 57 | |
| 58 | # 其他类型的输入 |
| 59 | put_markdown(t(""" |
| 60 | PyWebIO’s input functions is blocking and will not return until the form is successfully submitted. |
| 61 | #### Other types of input |
| 62 | Here are some other types of input functions: |
| 63 | ```python |
| 64 | # Password input |
| 65 | password = input("Input password", type=PASSWORD) |
| 66 | |
| 67 | # Drop-down selection |
| 68 | gift = select('Which gift you want?', ['keyboard', 'ipad']) |
| 69 | |
| 70 | # CheckBox |
| 71 | agree = checkbox("User Term", options=['I agree to terms and conditions']) |
nothing calls this directly
no test coverage detected
searching dependent graphs…