diff --git a/README.md b/README.md index 71bd2d11..7977c6b4 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ Package version - Python Version + Python Version
@@ -173,7 +173,7 @@ Document is on [https://pywebio.readthedocs.io](https://pywebio.readthedocs.io) Package version - Python Version + Python Version
diff --git a/demos/__main__.py b/demos/__main__.py index 00b5a018..d70b39bc 100644 --- a/demos/__main__.py +++ b/demos/__main__.py @@ -17,10 +17,10 @@ index_md = r"""### Basic demo - - [BMI calculation](./bmi): Calculating Body Mass Index based on height and weight [source](https://github.com/wang0618/PyWebIO/blob/dev/demos/bmi.py) - - [Online chat room](./chat_room): Chat with everyone currently online [source](https://github.com/wang0618/PyWebIO/blob/dev/demos/chat_room.py) - - [Input demo](./input_usage): Demonstrate various input usage supported by PyWebIO [source](https://github.com/wang0618/PyWebIO/blob/dev/demos/input_usage.py) - - [Output demo](./output_usage): Demonstrate various output usage supported by PyWebIO [source](https://github.com/wang0618/PyWebIO/blob/dev/demos/output_usage.py) + - [BMI calculation](./bmi): Calculating Body Mass Index based on height and weight + - [Online chat room](./chat_room): Chat with everyone currently online + - [Input demo](./input_usage): Demonstrate various input usage supported by PyWebIO + - [Output demo](./output_usage): Demonstrate various output usage supported by PyWebIO ### Data visualization demo PyWebIO supports for data visualization with the third-party libraries. @@ -58,10 +58,10 @@ index_md_zh = r"""### 基本demo - - [BMI计算](./bmi): 根据身高体重计算BMI指数 [源码](https://github.com/wang0618/PyWebIO/blob/dev/demos/bmi.py) - - [聊天室](./chat_room): 和当前所有在线的人聊天 [源码](https://github.com/wang0618/PyWebIO/blob/dev/demos/chat_room.py) - - [输入演示](./input_usage): 演示PyWebIO输入模块的用法 [源码](https://github.com/wang0618/PyWebIO/blob/dev/demos/input_usage.py) - - [输出演示](./output_usage): 演示PyWebIO输出模块的用法 [源码](https://github.com/wang0618/PyWebIO/blob/dev/demos/output_usage.py) + - [BMI计算](./bmi): 根据身高体重计算BMI指数 + - [聊天室](./chat_room): 和当前所有在线的人聊天 + - [输入演示](./input_usage): 演示PyWebIO输入模块的用法 + - [输出演示](./output_usage): 演示PyWebIO输出模块的用法 - 更多Demo请见[文档](https://pywebio.readthedocs.io)中示例代码的在线Demo ### 数据可视化demo diff --git a/demos/input_usage.py b/demos/input_usage.py index ed5d6ddf..b176b85b 100644 --- a/demos/input_usage.py +++ b/demos/input_usage.py @@ -19,7 +19,7 @@ def t(eng, chinese): def main(): - """PyWebIO input demo + """PyWebIO Input Usage Demonstrate various input usage supported by PyWebIO. 演示PyWebIO输入模块的使用 @@ -122,7 +122,7 @@ def main(): # 输入选项 put_markdown(t("""#### Parameter of input functions There are many parameters that can be passed to the input function: - ""","""#### 输入选项 + """, """#### 输入选项 输入函数可指定的参数非常丰富: """), strip_indent=4) put_markdown(""" @@ -137,7 +137,7 @@ def main(): datalist=['candidate1', 'candidate2', 'candidate2']) # 校验函数 - put_markdown(t("""You can specify a validation function for the input by using validate parameter. The validation function should return None when the check passes, otherwise an error message will be returned:""", """我们可以为输入指定校验函数,校验函数校验通过时返回None,否则返回错误消息:"""), strip_indent=4) + put_markdown(t("""You can specify a validation function for the input by using `validate` parameter. The validation function should return `None` when the check passes, otherwise an error message will be returned:""", """我们可以为输入指定校验函数,校验函数校验通过时返回`None`,否则返回错误消息:"""), strip_indent=4) put_markdown(""" ```python def check_age(p): # return None when the check passes, otherwise return the error message @@ -160,7 +160,7 @@ def check_age(p): # 检验函数校验通过时返回None,否则返回错误 put_markdown('`age = %r`' % age) # Codemirror - put_markdown(t("""You can use `code` parameter in `pywebio.input.textarea()` to make a code editing textarea:""", """PyWebIO 的 `textarea()` 输入函数还支持使用 [Codemirror](https://codemirror.net/) 实现代码风格的编辑区,只需使用 `code` 参数传入Codemirror支持的选项即可(最简单的情况是直接传入` code={}` 或 `code=True`):"""), strip_indent=4) + put_markdown(t("""You can use `code` parameter in `pywebio.input.textarea()` to create a code editing textarea:""", """PyWebIO 的 `textarea()` 输入函数还支持使用 [Codemirror](https://codemirror.net/) 实现代码风格的编辑区,只需使用 `code` 参数传入Codemirror支持的选项即可(最简单的情况是直接传入` code={}` 或 `code=True`):"""), strip_indent=4) put_markdown(r""" ```python code = textarea('Code Edit', code={ @@ -179,7 +179,7 @@ def check_age(p): # 检验函数校验通过时返回None,否则返回错误 # 输入组 put_markdown(t("""### Input Group - `input_group()` accepts a list of single input function call as parameter, and returns a dictionary with the name from the single input function as the key and the input data as the value. + `input_group()` accepts a list of single input function call as parameter, and returns a dictionary with the name of the single input function as the key and the input data as the value. The input group also supports using `validate` parameter to set the validation function, which accepts the entire form data as parameter:""", """### 输入组 `input_group()` 接受单项输入组成的列表作为参数,输入组中需要在每一项输入函数中提供 `name` 参数来用于在结果中标识不同输入项。输入组中同样支持设置校验函数,其接受整个表单数据作为参数。检验函数校验通过时返回None,否则返回 `(input name,错误消息)` diff --git a/demos/output_usage.py b/demos/output_usage.py index 940f24d2..2f503979 100644 --- a/demos/output_usage.py +++ b/demos/output_usage.py @@ -36,7 +36,7 @@ def run_code(code, scope): async def main(): - """PyWebIO Output demo + """PyWebIO Output Usage Demonstrate various output usage supported by PyWebIO. 演示PyWebIO输出模块的使用 @@ -95,13 +95,13 @@ async def main(): put_file('hello_word.txt', b'hello word!') """)) - put_markdown(t(r"""For all output functions provided by PyWebIO, please refer to the document. + put_markdown(t(r"""For all output functions provided by PyWebIO, please refer to the [document](https://pywebio.readthedocs.io/en/latest/output.html#output-func-list). ### Combined Output - The output functions whose name starts with put_ can be combined with some output functions as part of the final output: + The output functions whose name starts with `put_` can be combined with some output functions as part of the final output: You can pass `put_xxx()` calls to `put_table()` as cell content: - """, r"""PyWebIO提供的全部输出函数请参考PyWebIO文档 + """, r"""PyWebIO提供的全部输出函数请参考[PyWebIO文档](https://pywebio.readthedocs.io/zh_CN/latest/output.html#output-func-list) ### 组合输出 @@ -134,11 +134,11 @@ async def main(): ]) """) - put_markdown(t(r"For more output functions that accept `put_xxx()` calls as parameters, please refer to corresponding function documentation.", - r"更多接受`put_xxx()`作为参数的输出函数请参考函数文档。")) + put_markdown(t(r"For more output functions that accept `put_xxx()` calls as parameters, please refer to the [document](https://pywebio.readthedocs.io/en/latest/output.html#output-func-list).", + r"更多接受`put_xxx()`作为参数的输出函数请参考[函数文档](https://pywebio.readthedocs.io/zh_CN/latest/output.html#output-func-list)。")) put_markdown(t(r"""### Callback - PyWebIO allows you to output some buttons, and the provided callback function will be executed when the button is clicked. + PyWebIO allows you to output some buttons and bind callbacks to them. The provided callback function will be executed when the button is clicked. This is an example:%s The call to `put_table()` will not block. When user clicks a button, the corresponding callback function will be invoked: @@ -177,7 +177,7 @@ def edit_row(choice, row): ]) set_scope('table-callback') - put_markdown(t("Of course, PyWebIO also supports outputting individual button:", "当然,PyWebIO还支持单独的按钮控件:")+r""" + put_markdown(t("Of course, PyWebIO also supports outputting individual buttons:", "当然,PyWebIO还支持单独的按钮控件:")+r""" ```python def btn_click(btn_val): put_markdown("> You click `%s` button" % btn_val) diff --git a/docs/assets/demo.gif b/docs/assets/demo.gif index c9a213e4..2d8b0f7c 100644 Binary files a/docs/assets/demo.gif and b/docs/assets/demo.gif differ diff --git a/docs/assets/demo.png b/docs/assets/demo.png index 1cd1414f..b4885c03 100644 Binary files a/docs/assets/demo.png and b/docs/assets/demo.png differ diff --git a/docs/assets/input_1.png b/docs/assets/input_1.png index 058f656d..f800009d 100644 Binary files a/docs/assets/input_1.png and b/docs/assets/input_1.png differ diff --git a/docs/assets/input_2.png b/docs/assets/input_2.png index 7b2db0c6..42d58655 100644 Binary files a/docs/assets/input_2.png and b/docs/assets/input_2.png differ diff --git a/docs/guide.rst b/docs/guide.rst index 395d192e..a8a5dd39 100644 --- a/docs/guide.rst +++ b/docs/guide.rst @@ -124,7 +124,7 @@ The results of the above example are as follows: Input Group ^^^^^^^^^^^^^ -PyWebIO uses input group to get multiple inputs in a single form. `pywebio.input.input_group()` accepts a list of single input function call as parameter, and returns a dictionary with the ``name`` from the single input function as the key and the input data as the value: +PyWebIO uses input group to get multiple inputs in a single form. `pywebio.input.input_group()` accepts a list of single input function call as parameter, and returns a dictionary with the ``name`` of the single input function as the key and the input data as the value: .. exportable-codeblock:: @@ -301,9 +301,9 @@ For a full list of functions that support context manager, see :ref:`Output func Callback ^^^^^^^^^^^^^^ -As we can see from the above, PyWebIO divides the interaction into two parts: input and output. The input function is blocking, a form will be displayed on the user's web browser when calling input function, the input function will not return util the user submits the form. The output function is used to output content to the browser in real time. The behavior of input and output is consistent with the console program. That's why we say PyWebIO turning the browser into a "rich text terminal". So you can write PyWebIO applications in script programing way. +As we can see from the above, the interaction of PyWebIO has two parts: input and output. The input function of PyWebIO is blocking, a form will be displayed on the user's web browser when calling input function, the input function will not return until the user submits the form. The output function is used to output content to the browser in real time. The input/output behavior of PyWebIO is consistent with the console program. That's why we say PyWebIO turning the browser into a "rich text terminal". So you can write PyWebIO applications in script programing way. -In addition, PyWebIO also supports event callbacks: PyWebIO allows you to output some buttons, and the provided callback function will be executed when the button is clicked. +In addition, PyWebIO also supports event callbacks: PyWebIO allows you to output some buttons and bind callbacks to them. The provided callback function will be executed when the button is clicked. This is an example: @@ -410,9 +410,9 @@ The results of the above code are as follows:: show_time() # ..demo-only time.sleep(1) # ..demo-only -When calling ``show_time()`` for the first time, a ``time`` scope will be created at the current position, and the current time will be output to it. And then every time the ``show_time()`` is called, the new content will replace the previous content. +When calling ``show_time()`` for the first time, a ``time`` scope will be created, and the current time will be output to it. And then every time the ``show_time()`` is called, the new content will replace the previous content. -Scopes can be nested. At the beginning, PyWebIO applications have only one ``ROOT`` Scope. Each time a new scope is created, the nesting level of the scope will increase by one level, and each time the current scope is exited, the nesting level of the scope will be reduced by one. PyWebIO uses the Scope stack to save the nesting level of scope at runtime. +Scopes can be nested. At the beginning, PyWebIO applications have only one ``ROOT`` Scope. Each time a new scope is created, the nesting level of the scope will increase by one level, and each time the current scope is exited, the nesting level of the scope will be reduced by one. PyWebIO uses the Scope stack to save the scope nesting level at runtime. For example, the following code will create 3 scopes: @@ -438,7 +438,7 @@ For example, the following code will create 3 scopes: put_buttons([('Put text to %s' % i, i) for i in ('A', 'B', 'C')], lambda s: put_text(s, scope=s)) # ..demo-only -The above code will generate the following Scope layout:: +The above code will generate the following scope layout:: ┌─ROOT────────────────────┐ │ │ @@ -478,13 +478,13 @@ The results of the above code are as follows:: text2 in scope3 text in ROOT scope -In addition to directly specifying the target scope name, the ``scope`` parameter can also accept an integer to determine the scope by indexing the scope stack: 0 means the top level scope(the ROOT Scope), -1 means the current Scope, -2 means the scope used before entering the current scope, ... +In addition to directly specifying the target scope name, the ``scope`` parameter can also accept an integer to determine the scope by indexing the scope stack: 0 means the top level scope(the ROOT Scope), -1 means the current scope, -2 means the scope used before entering the current scope, ... -By default, the content output to the same scope will be arranged from top to bottom according to the calling order of the output function, and the output function called last will output the content to the bottom of the target scope. The output content can be inserted into other positions of the target scope by using the ``position`` parameter of the output function. +By default, the content output to the same scope will be arranged from top to bottom according to the calling order of the output function. The output content can be inserted into other positions of the target scope by using the ``position`` parameter of the output function. Each output item in a scope has an index, the first item's index is 0, and the next item's index is incremented by one. You can also use a negative number to index the items in the scope, -1 means the last item, -2 means the item before the last... -The ``position`` parameter of output functions is an integer. When ``position>=0``, it means to insert content before the item whose index equal ``position``; when ``position<0``, it means to insert content after the item whose index equal ``position``: +The ``position`` parameter of output functions accepts an integer. When ``position>=0``, it means to insert content before the item whose index equal ``position``; when ``position<0``, it means to insert content after the item whose index equal ``position``: .. exportable-codeblock:: :name: put-xxx-position @@ -532,7 +532,7 @@ To view the effects of environment settings, please visit :demo_host:`set_env De Layout ^^^^^^^^^^^^^^ -In general, using the various output functions introduced above is enough to output what you want, but these outputs are arranged vertically. If you want to make a more complex layout (such as displaying a code block on the left side of the page and an image on the right), you need to use layout functions. +In general, using the output functions introduced above is enough to output what you want, but these outputs are arranged vertically. If you want to create a more complex layout (such as displaying a code block on the left side of the page and an image on the right), you need to use layout functions. The ``pywebio.output`` module provides 3 layout functions, and you can create complex layouts by combining them: @@ -569,7 +569,7 @@ The layout function also supports customizing the size of each part:: put_row([put_image(...), put_image(...)], size='40% 60%') # The ratio of the width of two images is 2:3 -For more information, please refer to the :ref:`layout function documentation `. +For more information, please refer to the :ref:`layout functions documentation `. Style ^^^^^^^^^^^^^^ @@ -617,9 +617,9 @@ In PyWebIO, there are two modes to run PyWebIO applications: running as a script **Server mode** -In Server mode, PyWebIO will start a web server to continuously provide services. When the user accesses the service address, PyWebIO will open a new session and run PyWebIO application in it. +In server mode, PyWebIO will start a web server to continuously provide services. When the user accesses the service address, PyWebIO will open a new session and run PyWebIO application in it. -Use `start_server() ` to start a web server and serve given PyWebIO applications on it. `start_server() ` accepts a function as PyWebIO application. In addition, `start_server() ` also accepts a list of task function or a dictionary of it, so that one PyWebIO Server can have multiple services with different functions. You can use `go_app() ` or `put_link() ` to jump between services:: +Use `start_server() ` to start a web server and serve given PyWebIO applications on it. `start_server() ` accepts a function as PyWebIO application. In addition, `start_server() ` also accepts a list of task function or a dictionary of it, so one PyWebIO Server can have multiple services with different functions. You can use `go_app() ` or `put_link() ` to jump between services:: def task_1(): put_text('task_1') @@ -635,7 +635,8 @@ Use `start_server() ` to start a web serv put_link('Go task 1', app='task_1') # Use `app` parameter to specify the task name put_link('Go task 2', app='task_2') - start_server([index, task_1, task_2]) # or start_server({'index': index, 'task_1': task_1, 'task_2': task_2}) For more information, please refer to the function documentation. + # equal to `start_server({'index': index, 'task_1': task_1, 'task_2': task_2})` + start_server([index, task_1, task_2]) Use `path_deploy() ` to deploy the PyWebIO applications from a directory. @@ -651,12 +652,12 @@ For example, given the following folder structure:: │ └── b.py └── c.py -If you use this directory in `path_deploy() `, you can access the PyWebIO application in ``b.py`` by using URL ``http://:/A/b``. -And if the files have been modified after run `path_deploy() `, you can use ``reload`` URL parameter to reload application in the file: ``http://:/A/b?reload`` +If you use this directory in `path_deploy() `, you can access the PyWebIO application in ``b.py`` by using URL ``http://:/A/b``. +And if the files have been modified after run `path_deploy() `, you can use ``reload`` URL parameter to reload application in the file: ``http://:/A/b?reload`` You can also use the command ``pywebio-path-deploy`` to start a server just like using `path_deploy() `. For more information, refer ``pywebio-path-deploy --help`` -In Server mode, you can use `pywebio.platform.seo()` to set the `SEO `_ information. If not ``seo()`` is not used, the `docstring `_ of the task function will be regarded as SEO information by default. +In Server mode, you can use `pywebio.platform.seo()` to set the `SEO `_ information. If ``seo()`` is not used, the `docstring `_ of the task function will be regarded as SEO information by default. .. attention:: @@ -727,9 +728,9 @@ You can use `defer_call(func) ` to set the function Integration with web framework --------------------------------- -The PyWebIO application can be integrated into an existing Python Web project, and the PyWebIO application and the Web project share a web framework. PyWebIO currently supports integration with Flask, Tornado, Django and aiohttp web frameworks. +The PyWebIO application can be integrated into an existing Python Web project, the PyWebIO application and the Web project share a web framework. PyWebIO currently supports integration with Flask, Tornado, Django and aiohttp web frameworks. -The integration methods of different web frameworks are as follows: +The integration methods of those web frameworks are as follows: .. tabs:: @@ -821,7 +822,7 @@ The integration methods of different web frameworks are as follows: **aiohttp** - One route need to be added to communicate with the browser through WebSocket::: + One route need to be added to communicate with the browser through WebSocket:: from aiohttp import web from pywebio.platform.aiohttp import static_routes, webio_handler @@ -851,7 +852,7 @@ In addition, you can also pass a string to ``cdn`` parameter to directly set the The path of the static file of PyWebIO is stored in ``pywebio.STATIC_PATH``, you can use the command ``python3 -c "import pywebio; print(pywebio.STATIC_PATH)"`` to print it out. -.. note:: ``start_server()`` also support ``cdn`` parameter, if it is set to ``False``, the static resource will be hosted in local server automatically, without manual hosting. +.. note:: ``start_server()`` and ``path_deploy()`` also support ``cdn`` parameter, if it is set to ``False``, the static resource will be hosted in local server automatically, without manual hosting. .. _coroutine_based_session: @@ -917,7 +918,7 @@ In the coroutine task function, you can also use ``await`` to call other corouti Although the PyWebIO coroutine session is compatible with the ``awaitable objects`` in the standard library ``asyncio``, the ``asyncio`` library is not compatible with the ``awaitable objects`` in the PyWebIO coroutine session. - That is to say, you can't pass PyWebIO ``awaitable objects`` to the `asyncio`` functions that accept ``awaitable objects``. For example, the following calls are **not supported** :: + That is to say, you can't pass PyWebIO ``awaitable objects`` to the ``asyncio`` functions that accept ``awaitable objects``. For example, the following calls are **not supported** :: await asyncio.shield(pywebio.input()) await asyncio.gather(asyncio.sleep(1), pywebio.session.eval_js('1+1')) @@ -1000,7 +1001,7 @@ Example of coroutine-based session integration into Flask: threading.Thread(target=run_event_loop, daemon=True).start() app.run(host='localhost', port=80) -Finally, coroutine-based session is not available in the Script mode. You always need to use ``start_server()`` to run coroutine task function or integrate it to a web framework. +Finally, coroutine-based session is not available in the script mode. You always need to use ``start_server()`` to run coroutine task function or integrate it to a web framework. Last but not least --------------------- diff --git a/docs/locales/zh_CN/LC_MESSAGES/guide.po b/docs/locales/zh_CN/LC_MESSAGES/guide.po index f8338ff8..45f82e9d 100644 --- a/docs/locales/zh_CN/LC_MESSAGES/guide.po +++ b/docs/locales/zh_CN/LC_MESSAGES/guide.po @@ -7,8 +7,8 @@ msgid "" msgstr "" "Project-Id-Version: PyWebIO 1.1.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2021-03-18 14:41+0800\n" -"PO-Revision-Date: 2021-03-18 15:27+0800\n" +"POT-Creation-Date: 2021-03-23 19:49+0800\n" +"PO-Revision-Date: 2021-03-23 19:57+0800\n" "Last-Translator: WangWeimin \n" "Language: zh_CN\n" "Language-Team: \n" @@ -232,10 +232,10 @@ msgstr "输入组" #: ../../guide.rst:127 msgid "" "PyWebIO uses input group to get multiple inputs in a single form. `pywebio.input.input_group()` accepts a list of single input function call as " -"parameter, and returns a dictionary with the ``name`` from the single input function as the key and the input data as the value:" +"parameter, and returns a dictionary with the ``name`` of the single input function as the key and the input data as the value:" msgstr "" -"PyWebIO支持输入组, 返回结果为一个字典。`pywebio.input.input_group()` 接受单项输入组成的列表作为参数, 返回以单项输入函数中的 ``name`` 作为键、以输入" -"数据为值的字典:" +"PyWebIO支持输入组, 返回结果为一个字典。`pywebio.input.input_group()` 接受单项输入组成的列表作为参数, 返回以单项输入中的 ``name`` 作为键、以输入数据" +"为值的字典:" #: ../../guide.rst:130 msgid "" @@ -452,19 +452,19 @@ msgstr "事件回调" #: ../../guide.rst:304 msgid "" -"As we can see from the above, PyWebIO divides the interaction into two parts: input and output. The input function is blocking, a form will be " -"displayed on the user's web browser when calling input function, the input function will not return util the user submits the form. The output " -"function is used to output content to the browser in real time. The behavior of input and output is consistent with the console program. That's why " -"we say PyWebIO turning the browser into a \"rich text terminal\". So you can write PyWebIO applications in script programing way." +"As we can see from the above, the interaction of PyWebIO has two parts: input and output. The input function of PyWebIO is blocking, a form will be " +"displayed on the user's web browser when calling input function, the input function will not return until the user submits the form. The output " +"function is used to output content to the browser in real time. The input/output behavior of PyWebIO is consistent with the console program. That's " +"why we say PyWebIO turning the browser into a \"rich text terminal\". So you can write PyWebIO applications in script programing way." msgstr "" "从上面可以看出,PyWebIO把交互分成了输入和输出两部分:输入函数为阻塞式调用,会在用户浏览器上显示一个表单,在用户提交表单之前输入函数将不会返回;输出" "函数将内容实时输出至浏览器。这种交互方式和控制台程序是一致的,因此PyWebIO应用非常适合使用控制台程序的编写逻辑来进行开发。" #: ../../guide.rst:306 msgid "" -"In addition, PyWebIO also supports event callbacks: PyWebIO allows you to output some buttons, and the provided callback function will be executed " -"when the button is clicked." -msgstr "此外,PyWebIO还支持事件回调:PyWebIO允许你输出一些控件,当控件被点击时执行提供的回调函数。" +"In addition, PyWebIO also supports event callbacks: PyWebIO allows you to output some buttons and bind callbacks to them. The provided callback " +"function will be executed when the button is clicked." +msgstr "此外,PyWebIO还支持事件回调:PyWebIO允许你输出一些控件并绑定回调函数,当控件被点击时相应的回调函数便会被执行。" #: ../../guide.rst:308 msgid "This is an example:" @@ -621,16 +621,15 @@ msgstr "" #: ../../guide.rst:413 msgid "" -"When calling ``show_time()`` for the first time, a ``time`` scope will be created at the current position, and the current time will be output to " -"it. And then every time the ``show_time()`` is called, the new content will replace the previous content." -msgstr "" -"第一次调用 ``show_time`` 时,将会在当前位置创建 ``time`` 输出域并在其中输出当前时间,之后每次调用 ``show_time()`` ,时间都会输出到相同的区域。" +"When calling ``show_time()`` for the first time, a ``time`` scope will be created, and the current time will be output to it. And then every time " +"the ``show_time()`` is called, the new content will replace the previous content." +msgstr "第一次调用 ``show_time`` 时,将会创建 ``time`` 输出域并在其中输出当前时间,之后每次调用 ``show_time()`` ,输出域都会被新的内容覆盖。" #: ../../guide.rst:415 msgid "" "Scopes can be nested. At the beginning, PyWebIO applications have only one ``ROOT`` Scope. Each time a new scope is created, the nesting level of " "the scope will increase by one level, and each time the current scope is exited, the nesting level of the scope will be reduced by one. PyWebIO " -"uses the Scope stack to save the nesting level of scope at runtime." +"uses the Scope stack to save the scope nesting level at runtime." msgstr "" "Scope是可嵌套的,初始条件下,PyWebIO应用只有一个最顶层的 ``ROOT`` Scope。每创建一个新Scope,Scope的嵌套层级便会多加一层,每退出当前Scope,Scope的嵌" "套层级便会减少一层。PyWebIO使用Scope栈来保存运行时的Scope的嵌套层级。" @@ -661,7 +660,7 @@ msgid "" msgstr "" #: ../../guide.rst:441 -msgid "The above code will generate the following Scope layout::" +msgid "The above code will generate the following scope layout::" msgstr "以上代码将会产生如下Scope布局::" #: ../../guide.rst:443 @@ -714,16 +713,15 @@ msgstr "" #: ../../guide.rst:481 msgid "" "In addition to directly specifying the target scope name, the ``scope`` parameter can also accept an integer to determine the scope by indexing the " -"scope stack: 0 means the top level scope(the ROOT Scope), -1 means the current Scope, -2 means the scope used before entering the current scope, ..." +"scope stack: 0 means the top level scope(the ROOT Scope), -1 means the current scope, -2 means the scope used before entering the current scope, ..." msgstr "" "``scope`` 参数除了直接指定目标Scope名,还可以使用一个整形通过索引Scope栈来确定Scope:0表示最顶层也就是ROOT Scope,-1表示当前Scope,-2表示进入当前" "Scope前所使用的Scope,……" #: ../../guide.rst:483 msgid "" -"By default, the content output to the same scope will be arranged from top to bottom according to the calling order of the output function, and the " -"output function called last will output the content to the bottom of the target scope. The output content can be inserted into other positions of " -"the target scope by using the ``position`` parameter of the output function." +"By default, the content output to the same scope will be arranged from top to bottom according to the calling order of the output function. The " +"output content can be inserted into other positions of the target scope by using the ``position`` parameter of the output function." msgstr "" "默认条件下,在同一Scope中的输出内容,会根据输出函数的调用顺序从上往下排列,最后调用的输出函数会输出内容到目标Scope的底部。通过输出函数的 " "``position`` 参数可以将输出内容插入到目标Scope的其他位置。" @@ -738,8 +736,8 @@ msgstr "" #: ../../guide.rst:487 msgid "" -"The ``position`` parameter of output functions is an integer. When ``position>=0``, it means to insert content before the item whose index equal " -"``position``; when ``position<0``, it means to insert content after the item whose index equal ``position``:" +"The ``position`` parameter of output functions accepts an integer. When ``position>=0``, it means to insert content before the item whose index " +"equal ``position``; when ``position<0``, it means to insert content after the item whose index equal ``position``:" msgstr "" "``position`` 参数类型为整形, ``position>=0`` 时表示输出内容到目标Scope的第position号元素的前面; ``position<0`` 时表示输出内容到目标Scope第position" "号元素之后:" @@ -829,12 +827,10 @@ msgstr "布局" #: ../../guide.rst:535 msgid "" -"In general, using the various output functions introduced above is enough to output what you want, but these outputs are arranged vertically. If " -"you want to make a more complex layout (such as displaying a code block on the left side of the page and an image on the right), you need to use " -"layout functions." +"In general, using the output functions introduced above is enough to output what you want, but these outputs are arranged vertically. If you want " +"to create a more complex layout (such as displaying a code block on the left side of the page and an image on the right), you need to use layout " +"functions." msgstr "" -"一般情况下,使用上文介绍的各种输出函数足以完成各种内容的展示,但直接调用输出函数产生的输出之间都是竖直排列的,如果想实现更复杂的布局(比如在页面左侧" -"显示一个代码块,在右侧显示一个图像),就需要借助布局函数。" #: ../../guide.rst:537 msgid "The ``pywebio.output`` module provides 3 layout functions, and you can create complex layouts by combining them:" @@ -883,7 +879,7 @@ msgid "put_row([put_image(...), put_image(...)], size='40% 60%') # The ratio of msgstr "put_row([put_image(…), put_image(…)], size='40% 60%') # 左右两图宽度比2:3" #: ../../guide.rst:572 -msgid "For more information, please refer to the :ref:`layout function documentation `." +msgid "For more information, please refer to the :ref:`layout functions documentation `." msgstr "更多布局函数的用法及代码示例请查阅 :ref:`布局函数文档 ` ." #: ../../guide.rst:575 @@ -945,13 +941,13 @@ msgstr "" "在PyWebIO中,有两种方式用来运行PyWebIO应用:作为脚本运行和使用 `start_server() ` 或 `path_deploy() ` 来作为Web服务运行。" -#: ../../guide.rst:618 ../../guide.rst:689 +#: ../../guide.rst:618 ../../guide.rst:690 msgid "**Server mode**" msgstr "**Server模式**" #: ../../guide.rst:620 msgid "" -"In Server mode, PyWebIO will start a web server to continuously provide services. When the user accesses the service address, PyWebIO will open a " +"In server mode, PyWebIO will start a web server to continuously provide services. When the user accesses the service address, PyWebIO will open a " "new session and run PyWebIO application in it." msgstr "在Server模式下,PyWebIO会启动一个Web服务来持续性地提供服务。当用户访问服务地址时,PyWebIO会开启一个新会话并运行PyWebIO应用。" @@ -959,7 +955,7 @@ msgstr "在Server模式下,PyWebIO会启动一个Web服务来持续性地提 msgid "" "Use `start_server() ` to start a web server and serve given PyWebIO applications on it. `start_server() " "` accepts a function as PyWebIO application. In addition, `start_server() ` also accepts a list of task function or a dictionary of it, so that one PyWebIO Server can have multiple services with different " +"start_server>` also accepts a list of task function or a dictionary of it, so one PyWebIO Server can have multiple services with different " "functions. You can use `go_app() ` or `put_link() ` to jump between services::" msgstr "" "使用 `start_server() ` 启动一个Web Server来将PyWebIO应用作为Web服务运行, `start_server() ` to deploy the PyWebIO applications from a directory. The python file under this directory need " "contain the ``main`` function to be seen as the PyWebIO application. You can access the application by using the file path as the URL." @@ -1011,11 +1007,11 @@ msgstr "" "使用 `path_deploy() ` 可以从一个路径中部署PyWebIO应用。位于该路径下的python文件需要包含名字为 ``main`` 的PyWebIO任务函" "数才能被视为PyWebIO应用程序。服务端会根据用户访问的URL来确定需要加载的文件并从中读取PyWebIO应用来运行。" -#: ../../guide.rst:645 +#: ../../guide.rst:646 msgid "For example, given the following folder structure::" msgstr "例如,给定如下文件结构::" -#: ../../guide.rst:647 +#: ../../guide.rst:648 msgid "" ".\n" "├── A\n" @@ -1025,17 +1021,17 @@ msgid "" "└── c.py" msgstr "" -#: ../../guide.rst:654 +#: ../../guide.rst:655 msgid "" "If you use this directory in `path_deploy() `, you can access the PyWebIO application in ``b.py`` by using URL " -"``http://:/A/b``. And if the files have been modified after run `path_deploy() `, you can use ``reload`` " -"URL parameter to reload application in the file: ``http://:/A/b?reload``" +"``http://:/A/b``. And if the files have been modified after run `path_deploy() `, you can use ``reload`` " +"URL parameter to reload application in the file: ``http://:/A/b?reload``" msgstr "" -"如果使用以上路径调用 `path_deploy() ` ,你可以通过 URL ``http://:/A/b`` 来访问 ``b.py`` 文件中的PyWebIO应" -"用。当文件在运行 `path_deploy() ` 之后被修改,可以使用 ``reload`` URL参数来重载文件: ``http://:/A/b?" +"如果使用以上路径调用 `path_deploy() ` ,你可以通过 URL ``http://:/A/b`` 来访问 ``b.py`` 文件中的PyWebIO应" +"用。当文件在运行 `path_deploy() ` 之后被修改,可以使用 ``reload`` URL参数来重载文件: ``http://:/A/b?" "reload``" -#: ../../guide.rst:657 +#: ../../guide.rst:658 msgid "" "You can also use the command ``pywebio-path-deploy`` to start a server just like using `path_deploy() `. For more " "information, refer ``pywebio-path-deploy --help``" @@ -1043,22 +1039,22 @@ msgstr "" "你还可以使用 ``pywebio-path-deploy`` 命令来启动一个和 `path_deploy() ` 效果一样的server。关于命令的更多信息请查阅命令" "帮助: ``pywebio-path-deploy —help``" -#: ../../guide.rst:659 +#: ../../guide.rst:660 msgid "" "In Server mode, you can use `pywebio.platform.seo()` to set the `SEO `_ information. If " -"not ``seo()`` is not used, the `docstring `_ of the task function will be regarded as SEO information by " +"``seo()`` is not used, the `docstring `_ of the task function will be regarded as SEO information by " "default." msgstr "" "在Server模式下,可以使用 `pywebio.platform.seo()` 函数来设置任务函数SEO信息(在被搜索引擎索引时提供的网页信息,包含应用标题和应用简介),如果不使用 " -"``seo()`` 函数,默认条件下,PyWebIO会将任务函数的函数注释作为SEO信息(应用标题和简介之间使用一个空行分隔)。" +"``seo()`` 函数,默认条件下,PyWebIO会将任务函数的函数注释作为SEO信息(应用标题和简介之间使用一个空行分隔)。 " -#: ../../guide.rst:663 +#: ../../guide.rst:664 msgid "" "Note that in Server mode, PyWebIO's input and output functions can only be called in the context of task functions. For example, the following code " "is **not allowed**::" msgstr "注意,在Server模式下,仅能在任务函数上下文中对PyWebIO的交互函数进行调用。比如如下调用是 **不被允许的** ::" -#: ../../guide.rst:665 +#: ../../guide.rst:666 msgid "" "import pywebio\n" "from pywebio.input import input\n" @@ -1067,15 +1063,15 @@ msgid "" "pywebio.start_server(my_task_func, port=int(port))" msgstr "" -#: ../../guide.rst:672 ../../guide.rst:685 +#: ../../guide.rst:673 ../../guide.rst:686 msgid "**Script mode**" msgstr "**Script模式**" -#: ../../guide.rst:674 +#: ../../guide.rst:675 msgid "In Script mode, PyWebIO input and output functions can be called anywhere." msgstr "Script模式下,在任何位置都可以调用PyWebIO的交互函数。" -#: ../../guide.rst:676 +#: ../../guide.rst:677 msgid "" "If the user closes the browser before the end of the session, then calls to PyWebIO input and output functions in the session will cause a " "`SessionException ` exception." @@ -1083,15 +1079,15 @@ msgstr "" "如果用户在会话结束之前关闭了浏览器,那么之后会话内对于PyWebIO交互函数的调用将会引发一个 `SessionException ` 异" "常。" -#: ../../guide.rst:681 +#: ../../guide.rst:682 msgid "Concurrent" msgstr "并发" -#: ../../guide.rst:683 +#: ../../guide.rst:684 msgid "PyWebIO can be used in a multi-threading environment." msgstr "PyWebIO 支持在多线程环境中使用。" -#: ../../guide.rst:687 +#: ../../guide.rst:688 msgid "" "In Script mode, you can freely start new thread and call PyWebIO interactive functions in it. When all `non-daemonic `_ threads finish running, the script exits." @@ -1099,7 +1095,7 @@ msgstr "" "在 Script模式下,你可以自由地启动线程,并在其中调用PyWebIO的交互函数。当所有非 `Daemon线程 `_ 运行结束后,脚本退出。" -#: ../../guide.rst:691 +#: ../../guide.rst:692 msgid "" "In Server mode, if you need to use PyWebIO interactive functions in new thread, you need to use `register_thread(thread) ` to register the new thread (so that PyWebIO can know which session the thread belongs to). If the PyWebIO interactive function is " @@ -1114,11 +1110,11 @@ msgstr "" "理,其调用PyWebIO的交互函数将会产生 `SessionNotFoundException ` 异常。\n" "当会话的任务函数和会话内通过 `register_thread(thread) ` 注册的线程都结束运行时,会话关闭。" -#: ../../guide.rst:693 +#: ../../guide.rst:694 msgid "Example of using multi-threading in Server mode::" msgstr "Server模式下多线程的使用示例::" -#: ../../guide.rst:695 +#: ../../guide.rst:696 msgid "" "def show_time():\n" " while True:\n" @@ -1141,11 +1137,11 @@ msgid "" "start_server(app, port=8080, debug=True)" msgstr "" -#: ../../guide.rst:719 ../../guide.rst:955 +#: ../../guide.rst:720 ../../guide.rst:956 msgid "Close of session" msgstr "会话的结束" -#: ../../guide.rst:721 +#: ../../guide.rst:722 msgid "" "The close of session may also be caused by the user closing the browser page. After the browser page is closed, PyWebIO input function calls that " "have not yet returned in the current session will cause `SessionClosedException `, and subsequent calls " @@ -1156,7 +1152,7 @@ msgstr "" "SessionClosedException>` 异常,之后对于PyWebIO交互函数的调用将会产生 `SessionNotFoundException ` 或 " "`SessionClosedException ` 异常。" -#: ../../guide.rst:723 +#: ../../guide.rst:724 msgid "" "You can use `defer_call(func) ` to set the function to be called when the session closes. Whether it is because the " "user closes the page or the task finishes to cause session closed, the function set by `defer_call(func) ` will be " @@ -1168,33 +1164,33 @@ msgstr "" "`defer_call(func) ` 可以用于资源清理等工作。在会话中可以多次调用 `defer_call() ` ,会话结束后" "将会顺序执行设置的函数。" -#: ../../guide.rst:728 +#: ../../guide.rst:729 msgid "Integration with web framework" msgstr "与Web框架集成" -#: ../../guide.rst:730 +#: ../../guide.rst:731 msgid "" -"The PyWebIO application can be integrated into an existing Python Web project, and the PyWebIO application and the Web project share a web " -"framework. PyWebIO currently supports integration with Flask, Tornado, Django and aiohttp web frameworks." +"The PyWebIO application can be integrated into an existing Python Web project, the PyWebIO application and the Web project share a web framework. " +"PyWebIO currently supports integration with Flask, Tornado, Django and aiohttp web frameworks." msgstr "可以将PyWebIO应用集成到现有的Python Web项目中,PyWebIO应用与Web项目共用一个Web框架。目前支持与Flask、Tornado、Django和aiohttp Web框架的集成。" -#: ../../guide.rst:732 -msgid "The integration methods of different web frameworks are as follows:" -msgstr "不同Web框架的集成方法如下:" +#: ../../guide.rst:733 +msgid "The integration methods of those web frameworks are as follows:" +msgstr "不同Web框架的集成方法如下: " -#: ../../guide.rst:736 +#: ../../guide.rst:737 msgid "Tornado" msgstr "" -#: ../../guide.rst:740 +#: ../../guide.rst:741 msgid "**Tornado**" msgstr "" -#: ../../guide.rst:742 +#: ../../guide.rst:743 msgid "Need to add a ``RequestHandler`` to Tornado application::" msgstr "需要在Tornado应用中引入一个 ``RequestHandler`` ::" -#: ../../guide.rst:744 +#: ../../guide.rst:745 msgid "" "import tornado.ioloop\n" "import tornado.web\n" @@ -1214,7 +1210,7 @@ msgid "" " tornado.ioloop.IOLoop.current().start()" msgstr "" -#: ../../guide.rst:762 +#: ../../guide.rst:763 msgid "" "In above code, we use `webio_handler(task_func) ` to get the Tornado `WebSocketHandler `_ that communicates with the browser, and bind it to the ``/tool`` " @@ -1224,7 +1220,7 @@ msgstr "" "www.tornadoweb.org/en/stable/websocket.html#tornado.websocket.WebSocketHandler>`_ ,并将其绑定在 ``/tool`` 路由下。启动Tornado服务器后,访问 " "``http://localhost/tool`` 即可打开PyWebIO应用。" -#: ../../guide.rst:766 +#: ../../guide.rst:767 msgid "" "PyWebIO uses the WebSocket protocol to communicate with the browser in Tornado. If your Tornado application is behind a reverse proxy (such as " "Nginx), you may need to configure the reverse proxy to support the WebSocket protocol. :ref:`Here ` is an example of Nginx " @@ -1233,19 +1229,19 @@ msgstr "" "当使用Tornado后端时,PyWebIO使用WebSocket协议和浏览器进行通讯,如果你的Tornado应用处在反向代理(比如Nginx)之后,可能需要特别配置反向代理来支持" "WebSocket协议,:ref:`这里 ` 有一个Nginx配置WebSocket的例子。" -#: ../../guide.rst:768 +#: ../../guide.rst:769 msgid "Flask" msgstr "" -#: ../../guide.rst:772 +#: ../../guide.rst:773 msgid "**Flask**" msgstr "" -#: ../../guide.rst:774 +#: ../../guide.rst:775 msgid "One route need to be added to communicate with the browser through HTTP::" msgstr "需要添加一个PyWebIO相关的路由,用来和浏览器进行Http通讯::" -#: ../../guide.rst:776 +#: ../../guide.rst:777 msgid "" "from pywebio.platform.flask import webio_view\n" "from pywebio import STATIC_PATH\n" @@ -1260,7 +1256,7 @@ msgid "" "app.run(host='localhost', port=80)" msgstr "" -#: ../../guide.rst:789 +#: ../../guide.rst:790 msgid "" "In above code, we use `webio_view(task_func) ` to get the Flask view of the PyWebIO application, and bind it to " "``/tool`` path. After starting the Flask application, visit ``http://localhost/tool`` to open the PyWebIO application." @@ -1269,19 +1265,19 @@ msgstr "" "flask.palletsprojects.com/en/1.1.x/api/#flask.Flask.add_url_rule>`_ 将其绑定在 ``/tool`` 路径下。启动Flask应用后,访问 ``http://localhost/tool`` 即" "可打开PyWebIO应用。" -#: ../../guide.rst:791 +#: ../../guide.rst:792 msgid "Django" msgstr "" -#: ../../guide.rst:795 +#: ../../guide.rst:796 msgid "**Django**" msgstr "" -#: ../../guide.rst:797 +#: ../../guide.rst:798 msgid "Need to add a route in ``urls.py``::" msgstr "在django的路由配置文件 ``urls.py`` 中加入PyWebIO相关的路由即可::" -#: ../../guide.rst:799 +#: ../../guide.rst:800 msgid "" "# urls.py\n" "\n" @@ -1299,7 +1295,7 @@ msgid "" "]" msgstr "" -#: ../../guide.rst:815 +#: ../../guide.rst:816 msgid "" "In above code, we add a routing rule to bind the view function of the PyWebIO application to the ``/tool`` path After starting the Django server, " "visit ``http://localhost/tool`` to open the PyWebIO application" @@ -1307,19 +1303,19 @@ msgstr "" "以上代码使用添加了一条路由规则将PyWebIO应用的视图函数绑定到 ``/tool`` 路径下。\n" "启动Django应用后,访问 ``http://localhost/tool`` 即可打开PyWebIO应用" -#: ../../guide.rst:818 +#: ../../guide.rst:819 msgid "aiohttp" msgstr "" -#: ../../guide.rst:822 +#: ../../guide.rst:823 msgid "**aiohttp**" msgstr "" -#: ../../guide.rst:824 -msgid "One route need to be added to communicate with the browser through WebSocket:::" +#: ../../guide.rst:825 +msgid "One route need to be added to communicate with the browser through WebSocket::" msgstr "需要添加一个PyWebIO相关的路由,用来和浏览器进行WebSocket通讯::" -#: ../../guide.rst:826 +#: ../../guide.rst:827 msgid "" "from aiohttp import web\n" "from pywebio.platform.aiohttp import static_routes, webio_handler\n" @@ -1331,11 +1327,11 @@ msgid "" "web.run_app(app, host='localhost', port=80)" msgstr "" -#: ../../guide.rst:835 +#: ../../guide.rst:836 msgid "After starting the aiohttp server, visit ``http://localhost/tool`` to open the PyWebIO application" msgstr "启动aiohttp应用后,访问 ``http://localhost/tool`` 即可打开PyWebIO应用" -#: ../../guide.rst:839 +#: ../../guide.rst:840 msgid "" "PyWebIO uses the WebSocket protocol to communicate with the browser in aiohttp. If your aiohttp server is behind a reverse proxy (such as Nginx), " "you may need to configure the reverse proxy to support the WebSocket protocol. :ref:`Here ` is an example of Nginx WebSocket " @@ -1344,15 +1340,15 @@ msgstr "" "当使用aiohttp后端时,PyWebIO使用WebSocket协议和浏览器进行通讯,如果你的aiohttp应用处在反向代理(比如Nginx)之后,\n" "可能需要特别配置反向代理来支持WebSocket协议,:ref:`这里 ` 有一个Nginx配置WebSocket的例子。" -#: ../../guide.rst:844 +#: ../../guide.rst:845 msgid "Notes" msgstr "" -#: ../../guide.rst:845 +#: ../../guide.rst:846 msgid "**Static resources Hosting**" msgstr "**PyWebIO静态资源的托管**" -#: ../../guide.rst:847 +#: ../../guide.rst:848 msgid "" "By default, the front-end of PyWebIO gets required static resources from CDN. If you want to deploy PyWebIO applications in an offline environment, " "you need to host static files by yourself, and set the ``cdn`` parameter of ``webio_view()`` or ``webio_handler()`` to ``False``." @@ -1360,7 +1356,7 @@ msgstr "" "PyWebIO默认使用CDN来获取前端的静态资源,如果要将PyWebIO应用部署到离线环境中,需要自行托管静态文件,\n" "并将 ``webio_view()`` 或 ``webio_handler()`` 的 ``cdn`` 参数设置为 ``False`` 。" -#: ../../guide.rst:849 +#: ../../guide.rst:850 msgid "" "When setting ``cdn=False`` , you need to host the static resources in the same directory as the PyWebIO application. In addition, you can also pass " "a string to ``cdn`` parameter to directly set the deployment directory of PyWebIO static resources." @@ -1368,30 +1364,30 @@ msgstr "" "``cdn=False`` 时需要将静态资源托管在和PyWebIO应用同级的目录下。\n" "同时,也可以通过 ``cdn`` 参数直接设置PyWebIO静态资源的部署目录。" -#: ../../guide.rst:852 +#: ../../guide.rst:853 msgid "" "The path of the static file of PyWebIO is stored in ``pywebio.STATIC_PATH``, you can use the command ``python3 -c \"import pywebio; print(pywebio." "STATIC_PATH)\"`` to print it out." msgstr "" "PyWebIO的静态文件的路径保存在 ``pywebio.STATIC_PATH`` 中,可使用命令 ``python3 -c \"import pywebio; print(pywebio.STATIC_PATH)\"`` 将其打印出来。" -#: ../../guide.rst:854 +#: ../../guide.rst:855 msgid "" -"``start_server()`` also support ``cdn`` parameter, if it is set to ``False``, the static resource will be hosted in local server automatically, " -"without manual hosting." +"``start_server()`` and ``path_deploy()`` also support ``cdn`` parameter, if it is set to ``False``, the static resource will be hosted in local " +"server automatically, without manual hosting." msgstr "使用 ``start_server()`` 启动的应用,如果将 ``cdn`` 参数设置为 ``False`` ,会自动启动一个本地的静态资源托管服务,无需手动托管。" -#: ../../guide.rst:860 +#: ../../guide.rst:861 msgid "Coroutine-based session" msgstr "基于协程的会话" -#: ../../guide.rst:862 +#: ../../guide.rst:863 msgid "" "This section will introduce the advanced features of PyWebIO --- coroutine-based session. In most cases, you don’t need it. All functions or " "methods in PyWebIO that are only used for coroutine sessions are specifically noted in the document." msgstr "关于协程内容属于高级特性,您不必使用此部分也可以实现PyWebIO支持的全部功能。PyWebIO中所有仅用于协程会话的函数或方法都在文档中有特别说明。" -#: ../../guide.rst:864 +#: ../../guide.rst:865 msgid "" "PyWebIO's session is based on thread by default. Each time a user opens a session connection to the server, PyWebIO will start a thread to run the " "task function. In addition to thread-based sessions, PyWebIO also provides coroutine-based sessions. Coroutine-based sessions accept coroutine " @@ -1400,7 +1396,7 @@ msgstr "" "PyWebIO的会话实现默认是基于线程的,用户每打开一个和服务端的会话连接,PyWebIO会启动一个线程来运行任务函数。\n" "除了基于线程的会话,PyWebIO还提供了基于协程的会话。基于协程的会话接受协程函数作为任务函数。" -#: ../../guide.rst:866 +#: ../../guide.rst:867 msgid "" "The session based on the coroutine is a single-thread model, which means that all sessions run in a single thread. For IO-bound tasks, coroutines " "take up fewer resources than threads and have performance comparable to threads. In addition, the context switching of the coroutine is " @@ -1409,17 +1405,17 @@ msgstr "" "基于协程的会话为单线程模型,所有会话都运行在一个线程内。对于IO密集型的任务,协程比线程占用更少的资源同时又拥有媲美于线程的性能。\n" "另外,协程的上下文切换具有可预测性,能够减少程序同步与加锁的需要,可以有效避免大多数临界区问题。" -#: ../../guide.rst:869 +#: ../../guide.rst:870 msgid "Using coroutine session" msgstr "使用协程会话" -#: ../../guide.rst:871 +#: ../../guide.rst:872 msgid "" "To use coroutine-based session, you need to use the ``async`` keyword to declare the task function as a coroutine function, and use the ``await`` " "syntax to call the PyWebIO input function:" msgstr "要使用基于协程的会话,需要使用 ``async`` 关键字将任务函数声明为协程函数,并使用 ``await`` 语法调用PyWebIO输入函数:" -#: ../../guide.rst:873 +#: ../../guide.rst:874 #, python-format msgid "" " from pywebio.input import *\n" @@ -1433,7 +1429,7 @@ msgid "" " start_server(say_hello, auto_open_webbrowser=True)" msgstr "" -#: ../../guide.rst:887 +#: ../../guide.rst:888 msgid "" "In the coroutine task function, you can also use ``await`` to call other coroutines or ( `awaitable objects `_ ) in the standard library `asyncio `_:" @@ -1441,7 +1437,7 @@ msgstr "" "在协程任务函数中,也可以使用 ``await`` 调用其他协程或标准库 `asyncio `_ 中的可等待对象( `awaitable " "objects `_ ):" -#: ../../guide.rst:889 +#: ../../guide.rst:890 msgid "" " import asyncio\n" " from pywebio import start_server\n" @@ -1458,7 +1454,7 @@ msgid "" " start_server(main, auto_open_webbrowser=True)" msgstr "" -#: ../../guide.rst:908 +#: ../../guide.rst:909 msgid "" "In coroutine-based session, all input functions defined in the :doc:`pywebio.input ` module need to use ``await`` syntax to get the return " "value. Forgetting to use ``await`` will be a common error when using coroutine-based session." @@ -1466,47 +1462,47 @@ msgstr "" "在基于协程的会话中, :doc:`pywebio.input ` 模块中的定义输入函数都需要使用 ``await`` 语法来获取返回值,忘记使用 ``await`` 将会是在使用基于协" "程的会话时常出现的错误。" -#: ../../guide.rst:910 +#: ../../guide.rst:911 msgid "Other functions that need to use ``await`` syntax in the coroutine session are:" msgstr "其他在协程会话中也需要使用 ``await`` 语法来进行调用函数有:" -#: ../../guide.rst:912 +#: ../../guide.rst:913 msgid "`pywebio.session.run_asyncio_coroutine(coro_obj) `" msgstr "" -#: ../../guide.rst:913 +#: ../../guide.rst:914 msgid "`pywebio.session.eval_js(expression) `" msgstr "" -#: ../../guide.rst:914 +#: ../../guide.rst:915 msgid "`pywebio.session.hold() `" msgstr "" -#: ../../guide.rst:918 +#: ../../guide.rst:919 msgid "" "Although the PyWebIO coroutine session is compatible with the ``awaitable objects`` in the standard library ``asyncio``, the ``asyncio`` library is " "not compatible with the ``awaitable objects`` in the PyWebIO coroutine session." msgstr "虽然PyWebIO的协程会话兼容标准库 ``asyncio`` 中的 ``awaitable objects`` ,但 ``asyncio`` 库不兼容PyWebIO协程会话中的 ``awaitable objects`` ." -#: ../../guide.rst:920 +#: ../../guide.rst:921 msgid "" -"That is to say, you can't pass PyWebIO ``awaitable objects`` to the `asyncio`` functions that accept ``awaitable objects``. For example, the " +"That is to say, you can't pass PyWebIO ``awaitable objects`` to the ``asyncio`` functions that accept ``awaitable objects``. For example, the " "following calls are **not supported** ::" msgstr "" "也就是说,无法将PyWebIO中的 ``awaitable objects`` 传入 ``asyncio`` 中的接受 ``awaitable objects`` 作为参数的函数中,比如如下调用是 **不被支持的** ::" -#: ../../guide.rst:922 +#: ../../guide.rst:923 msgid "" "await asyncio.shield(pywebio.input())\n" "await asyncio.gather(asyncio.sleep(1), pywebio.session.eval_js('1+1'))\n" "task = asyncio.create_task(pywebio.input())" msgstr "" -#: ../../guide.rst:929 +#: ../../guide.rst:930 msgid "Concurrency in coroutine-based sessions" msgstr "协程会话的并发" -#: ../../guide.rst:931 +#: ../../guide.rst:932 msgid "" "In coroutine-based session, you can start new thread, but you cannot call PyWebIO interactive functions in it (`register_thread() ` is not available in coroutine session). But you can use `run_async(coro) ` to execute a coroutine " @@ -1516,7 +1512,7 @@ msgstr "" "用)。\n" "但你可以使用 `run_async(coro) ` 来异步执行一个协程对象,新协程内可以使用PyWebIO交互函数:" -#: ../../guide.rst:933 +#: ../../guide.rst:934 msgid "" " from pywebio import start_server\n" " from pywebio.session import run_async\n" @@ -1534,7 +1530,7 @@ msgid "" " start_server(main, auto_open_webbrowser=True)" msgstr "" -#: ../../guide.rst:952 +#: ../../guide.rst:953 msgid "" "`run_async(coro) ` returns a `TaskHandler `, which can be used to query the " "running status of the coroutine or close the coroutine." @@ -1542,13 +1538,13 @@ msgstr "" "`run_async(coro) ` 返回一个 `TaskHandler ` ,通过该 `TaskHandler ` 可以查询协程运行状态和关闭协程。" -#: ../../guide.rst:957 +#: ../../guide.rst:958 msgid "" "Similar to thread-based session, in coroutine-based session, when the task function and the coroutine running through `run_async() ` in the session are all finished, the session is closed." msgstr "与基于线程的会话类似,在基于协程的会话中,当任务函数和在会话内通过 `run_async() ` 运行的协程全部结束后,会话关闭。" -#: ../../guide.rst:959 +#: ../../guide.rst:960 msgid "" "If the close of the session is caused by the user closing the browser, the behavior of PyWebIO is the same as :ref:`Thread-based session " "`: After the browser page closed, PyWebIO input function calls that have not yet returned in the current session will cause " @@ -1560,23 +1556,23 @@ msgstr "" "的调用将会产生 `SessionNotFoundException ` 或 `SessionClosedException ` 异常。" -#: ../../guide.rst:961 +#: ../../guide.rst:962 msgid "`defer_call(func) ` also available in coroutine session." msgstr "协程会话也同样支持使用 `defer_call(func) ` 来设置会话结束时需要调用的函数。" -#: ../../guide.rst:966 +#: ../../guide.rst:967 msgid "Integration with Web Framework" msgstr "协程会话与Web框架集成" -#: ../../guide.rst:968 +#: ../../guide.rst:969 msgid "The PyWebIO application that using coroutine-based session can also be integrated to the web framework." msgstr "基于协程的会话同样可以与Web框架进行集成,只需要在原来传入任务函数的地方改为传入协程函数即可。" -#: ../../guide.rst:970 +#: ../../guide.rst:971 msgid "However, there are some limitations when using coroutine-based sessions to integrate into Flask or Django:" msgstr "但当前在使用基于协程的会话集成进Flask或Django时,存在一些限制:" -#: ../../guide.rst:972 +#: ../../guide.rst:973 msgid "" "First, when ``await`` the coroutine objects/awaitable objects in the ``asyncio`` module, you need to use `run_asyncio_coroutine() ` to wrap the coroutine object." @@ -1584,15 +1580,15 @@ msgstr "" "一是协程函数内还无法直接通过 ``await`` 直接等待asyncio库中的协程对象,目前需要使用 `run_asyncio_coroutine() ` 进行包装。" -#: ../../guide.rst:974 +#: ../../guide.rst:975 msgid "Secondly, you need to start a new thread to run the event loop before starting a Flask/Django server." msgstr "二是,在启动Flask/Django这类基于线程的服务器之前需要启动一个单独的线程来运行事件循环。" -#: ../../guide.rst:976 +#: ../../guide.rst:977 msgid "Example of coroutine-based session integration into Flask:" msgstr "使用基于协程的会话集成进Flask的示例:" -#: ../../guide.rst:978 +#: ../../guide.rst:979 msgid "" " import asyncio\n" " import threading\n" @@ -1617,21 +1613,21 @@ msgid "" " app.run(host='localhost', port=80)" msgstr "" -#: ../../guide.rst:1003 +#: ../../guide.rst:1004 msgid "" -"Finally, coroutine-based session is not available in the Script mode. You always need to use ``start_server()`` to run coroutine task function or " +"Finally, coroutine-based session is not available in the script mode. You always need to use ``start_server()`` to run coroutine task function or " "integrate it to a web framework." msgstr "最后,使用PyWebIO编写的协程函数不支持Script模式,总是需要使用 ``start_server`` 来启动一个服务或者集成进Web框架来调用。" -#: ../../guide.rst:1006 +#: ../../guide.rst:1007 msgid "Last but not least" msgstr "" -#: ../../guide.rst:1008 +#: ../../guide.rst:1009 msgid "This is all features of PyWebIO, you can continue to read the rest of the documents, or start writing your PyWebIO applications now." msgstr "以上就是PyWebIO的全部功能了,你可以继续阅读接下来的文档,或者立即开始PyWebIO应用的编写了。" -#: ../../guide.rst:1010 +#: ../../guide.rst:1011 msgid "" "Finally, please allow me to provide one more suggestion. When you encounter a design problem when using PyWebIO, you can ask yourself a question: " "What would I do if it is in a terminal program? If you already have the answer, it can be done in the same way with PyWebIO. If the problem " @@ -1641,7 +1637,7 @@ msgstr "" "如果你已经有答案了,那么在PyWebIO中一样可以使用这样的方式完成。如果问题依然存在或者觉得解决方案不够好,\n" "你可以考虑使用 `put_buttons() ` 提供的回调机制。" -#: ../../guide.rst:1013 +#: ../../guide.rst:1014 msgid "OK, Have fun with PyWebIO!" msgstr "" @@ -1660,3 +1656,11 @@ msgstr "" #~ "其他接受 ``put_xxx()`` 调用作为参数的输出函数还有 `put_collapse() ` 、 `put_scrollable() ` 、`put_row() ` 等,此外,还可以通过 `put_widget() ` 自定义可接收 " #~ "``put_xxx()`` 调用的输出组件,具体用法请参考函数文档。" + +#~ msgid "" +#~ "In general, using the various output functions introduced above is enough to output what you want, but these outputs are arranged vertically. If " +#~ "you want to make a more complex layout (such as displaying a code block on the left side of the page and an image on the right), you need to use " +#~ "layout functions." +#~ msgstr "" +#~ "一般情况下,使用上文介绍的各种输出函数足以完成各种内容的展示,但直接调用输出函数产生的输出之间都是竖直排列的,如果想实现更复杂的布局(比如在页面" +#~ "左侧显示一个代码块,在右侧显示一个图像),就需要借助布局函数。" diff --git a/docs/locales/zh_CN/LC_MESSAGES/input.po b/docs/locales/zh_CN/LC_MESSAGES/input.po index 5d1eb5c2..ad45d140 100644 --- a/docs/locales/zh_CN/LC_MESSAGES/input.po +++ b/docs/locales/zh_CN/LC_MESSAGES/input.po @@ -7,8 +7,8 @@ msgid "" msgstr "" "Project-Id-Version: PyWebIO 1.1.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2021-03-18 19:30+0800\n" -"PO-Revision-Date: 2021-03-19 22:07+0800\n" +"POT-Creation-Date: 2021-03-23 20:40+0800\n" +"PO-Revision-Date: 2021-03-23 20:40+0800\n" "Last-Translator: WangWeimin \n" "Language: zh_CN\n" "Language-Team: \n" @@ -24,7 +24,7 @@ msgid "``pywebio.input`` --- Get input from web browser" msgstr "``pywebio.input`` — 输入模块" #: of pywebio.input:1 -msgid "This module provides many functions to get all kinds of input of user from the browser" +msgid "This module provides functions to get all kinds of input of user from the browser" msgstr "本模块提供了一系列函数来从浏览器接收用户不同的形式的输入" #: of pywebio.input:3 @@ -72,9 +72,9 @@ msgstr "" #: of pywebio.input:22 msgid "" -"By default, the user can submit an input of empty value. If the user must provide a non-empty " -"input value, you need to pass ``required=True`` to the input function (some input functions " -"do not support the ``required`` parameter)" +"By default, the user can submit empty input value. If the user must provide a non-empty input " +"value, you need to pass ``required=True`` to the input function (some input functions do not " +"support the ``required`` parameter)" msgstr "" "输入默认可以为空,如果需要用户必须提供值,则需要在输入函数中传入 ``required=True`` (部分输入函" "数不支持 ``required`` 参数)" @@ -193,9 +193,9 @@ msgstr "" #: of pywebio.input.input:7 msgid "" -"Input value validation function. If provided, the validation function will be called when the " -"user completes input or submits the form. ``validate`` receives the input value as a " -"parameter. When the input value is valid, it returns ``None``. When the input value is " +"Input value validation function. If provided, the validation function will be called when " +"user completes the input field or submits the form. ``validate`` receives the input value as " +"a parameter. When the input value is valid, it returns ``None``. When the input value is " "invalid, it returns an error message string. For example: .. exportable-codeblock:: :" "name: input-valid-func :summary: `input()` validation def check_age(age): if " "age>30: return 'Too old' elif age<10: return 'Too young' " @@ -204,9 +204,9 @@ msgstr "" #: of pywebio.input.input:7 msgid "" -"Input value validation function. If provided, the validation function will be called when the " -"user completes input or submits the form." -msgstr "输入值校验函数. 如果提供,当用户输入完毕或提交表单后校验函数将被调用." +"Input value validation function. If provided, the validation function will be called when " +"user completes the input field or submits the form." +msgstr "输入值校验函数。 如果提供,当用户输入完毕或提交表单后校验函数将被调用。" #: of pywebio.input.input:9 msgid "" @@ -242,7 +242,7 @@ msgstr "输入框的初始值" #: of pywebio.input.input:25 msgid "" -"Put a button on the right side of the input field, and you can click the button to set the " +"Put a button on the right side of the input field, and user can click the button to set the " "value for the input. ``label`` is the label of the button, and ``callback`` is the callback " "function to set the input value when clicked. The callback is invoked with one argument, the " "``set_value``. ``set_value`` is a callable object, which is invoked with one or two " @@ -271,9 +271,9 @@ msgstr "" #: of pywebio.input.input:25 msgid "" -"Put a button on the right side of the input field, and you can click the button to set the " +"Put a button on the right side of the input field, and user can click the button to set the " "value for the input." -msgstr "在输入框右侧显示一个按钮,可通过点击按钮为输入框设置值。" +msgstr "在输入框右侧显示一个按钮,用户可通过点击按钮为输入框设置值。" #: of pywebio.input.input:27 msgid "" @@ -370,8 +370,8 @@ msgid "" msgstr "输入框的提示内容。提示内容会在输入框未输入值时以浅色字体显示在输入框中" #: of pywebio.input.input:67 -msgid "Whether a value is required for the input to be submittable" -msgstr "当前输入是否为必填项" +msgid "Whether a value is required for the input to be submittable, default is ``False``" +msgstr "当前输入是否为必填项,默认为 ``False``" #: of pywebio.input.input:68 msgid "Whether the value is readonly(not editable)" @@ -387,7 +387,7 @@ msgstr "" #: of pywebio.input.input:70 msgid "" -"Help text for the input. The text will be displayed below the input field in a small font" +"Help text for the input. The text will be displayed below the input field with small font" msgstr "输入框的帮助文本。帮助文本会以小号字体显示在输入框下方" #: of pywebio.input.input:71 @@ -571,7 +571,7 @@ msgid "" msgstr "可选项列表。格式与同 `select()` 函数的 ``options`` 参数" #: of pywebio.input.checkbox:4 pywebio.input.radio:4 -msgid "Whether to display the options on one line. Default is False" +msgid "Whether to display the options on one line. Default is ``False``" msgstr "是否将选项显示在一行上。默认每个选项单独占一行" #: of pywebio.input.checkbox:5 @@ -723,8 +723,8 @@ msgstr "实现简单的选择操作:" #: of pywebio.input.actions:40 #, python-format msgid "" -"confirm = actions('Confirm to delete file?', ['confirm', 'cancel'], help_text='Unrecoverable " -"after file deletion')\n" +"confirm = actions('Confirm to delete file?', ['confirm', 'cancel'],\n" +" help_text='Unrecoverable after file deletion')\n" "if confirm=='confirm': # ..doc-only\n" " ... # ..doc-only\n" "put_markdown('You clicked the `%s` button' % confirm) # ..demo-only" @@ -734,17 +734,17 @@ msgstr "" " … # ..doc-only\n" "put_markdown('点击了`%s`按钮' % confirm) # ..demo-only" -#: of pywebio.input.actions:49 +#: of pywebio.input.actions:50 msgid "" "Compared with other input items, when using `actions()`, the user only needs to click once to " "complete the submission." msgstr "相比于其他输入项,使用 `actions()` 用户只需要点击一次就可完成提交。" -#: of pywebio.input.actions:51 +#: of pywebio.input.actions:52 msgid "Replace the default submit button:" msgstr "替换默认的提交按钮:" -#: of pywebio.input.actions:53 +#: of pywebio.input.actions:54 msgid "" "import json # ..demo-only\n" " # ..demo-only\n" @@ -845,7 +845,7 @@ msgstr "" "大小。 格式同 ``max_size`` 参数" #: of pywebio.input.file_upload:19 -msgid "Indicates whether the user must specify a file for the input. Default is `False`." +msgid "Indicates whether the user must specify a file for the input. Default is ``False``." msgstr "是否必须要上传文件。默认为 `False`" #: of pywebio.input.file_upload:21 @@ -960,16 +960,17 @@ msgstr "" #: of pywebio.input.input_group:28 msgid "" -"Whether the form can be cancelled. Default is False. If ``cancelable=True``, a \"Cancel\" " +"Whether the form can be cancelled. Default is ``False``. If ``cancelable=True``, a \"Cancel\" " "button will be displayed at the bottom of the form. Note: If the last input item in the " "group is `actions()`, ``cancelable`` will be ignored." msgstr "" #: of pywebio.input.input_group:28 msgid "" -"Whether the form can be cancelled. Default is False. If ``cancelable=True``, a \"Cancel\" " +"Whether the form can be cancelled. Default is ``False``. If ``cancelable=True``, a \"Cancel\" " "button will be displayed at the bottom of the form." -msgstr "表单是否可以取消。若 ``cancelable=True`` 则会在表单底部显示一个“取消”按钮。" +msgstr "" +"表单是否可以取消。若 ``cancelable=True`` 则会在表单底部显示一个“取消”按钮,默认为 ``False`` 。" #: of pywebio.input.input_group:30 msgid "" diff --git a/docs/locales/zh_CN/LC_MESSAGES/output.po b/docs/locales/zh_CN/LC_MESSAGES/output.po index 2af16678..59af6b1d 100644 --- a/docs/locales/zh_CN/LC_MESSAGES/output.po +++ b/docs/locales/zh_CN/LC_MESSAGES/output.po @@ -7,8 +7,8 @@ msgid "" msgstr "" "Project-Id-Version: PyWebIO 1.1.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2021-03-18 14:41+0800\n" -"PO-Revision-Date: 2021-03-19 22:04+0800\n" +"POT-Creation-Date: 2021-03-23 20:35+0800\n" +"PO-Revision-Date: 2021-03-23 20:37+0800\n" "Last-Translator: WangWeimin \n" "Language: zh_CN\n" "Language-Team: \n" @@ -25,7 +25,7 @@ msgstr "``pywebio.output`` — 输出模块" #: of pywebio.output:1 msgid "" -"This module provides many functions to output all kinds of content to the user's " +"This module provides functions to output all kinds of content to the user's " "browser, and supply flexible output control." msgstr "" "本模块提供了一系列函数来输出不同形式的内容到用户浏览器,并支持灵活的输出控制。" @@ -45,8 +45,7 @@ msgid "" msgstr "其中标记有 ``*`` 的函数表示其支持接收 ``put_xxx`` 调用作为参数。" #: of pywebio.output:14 -msgid "" -"The functions marked with ``†`` indicate that they can use as context manager." +msgid "The functions marked with ``†`` indicate that they can use as context manager." msgstr "标记有 ``†`` 的函数表示其支持作为上下文管理器使用。" #: of pywebio.output:17 @@ -145,7 +144,7 @@ msgstr "" msgid "`put_error`:sup:`*†`" msgstr "" -#: of pywebio.output:35 +#: of pywebio.output:35 pywebio.output:106 msgid "Output Messages." msgstr "输出通知消息" @@ -243,15 +242,15 @@ msgstr "" #: of pywebio.output msgid "Output a fixed height content area," -msgstr "固定高度内容输出区域,内容超出则显示滚动条" +msgstr "固定高度内容输出区域" #: of pywebio.output msgid "scroll bar is displayed when the content" -msgstr "" +msgstr "内容超出则显示滚动条" #: of pywebio.output msgid "exceeds the limit" -msgstr "" +msgstr "." #: of pywebio.output:66 msgid "`put_widget`:sup:`*`" @@ -261,7 +260,7 @@ msgstr "" msgid "Output your own widget" msgstr "输出自定义的控件" -#: of pywebio.output:68 pywebio.output:129 +#: of pywebio.output:68 pywebio.output:131 msgid "Other Interactions" msgstr "其他交互" @@ -289,7 +288,7 @@ msgstr "" msgid "Close the current popup window." msgstr "关闭正在显示的弹窗" -#: of pywebio.output:74 pywebio.output:137 +#: of pywebio.output:74 pywebio.output:139 msgid "Layout and Style" msgstr "布局与样式" @@ -333,7 +332,7 @@ msgstr "" msgid "Customize the css style of output content" msgstr "自定义输出内容的css样式" -#: of pywebio.output:84 pywebio.output:144 +#: of pywebio.output:84 pywebio.output:146 msgid "Other" msgstr "其他" @@ -368,19 +367,19 @@ msgstr "scope名" #: of pywebio.output.set_scope:4 msgid "" -"Specify the parent scope of this scope. You can use the scope name or use a " -"integer to index the runtime scope stack (see :ref:`User Guide `). " -"When the scope does not exist, no operation is performed." +"Specify the parent scope of this scope. You can use the scope name or use a integer " +"to index the runtime scope stack (see :ref:`User Guide `). When the " +"scope does not exist, no operation is performed." msgstr "" -"指定此scope的父scope. 可以直接指定父scope名或使用int索引运行时scope栈(参见 :ref:`" -"输出函数的scope相关参数 `). scope不存在时,不进行任何操作." +"指定此scope的父scope. 可以直接指定父scope名或使用int索引运行时scope栈(参见 :ref:`输" +"出函数的scope相关参数 `). scope不存在时,不进行任何操作." #: of pywebio.output.set_scope:5 msgid "" "The location where this scope is created in the parent scope. Available values: " "`OutputPosition.TOP`: created at the top of the parent scope, `OutputPosition." -"BOTTOM`: created at the bottom of the parent scope. You can also use a integer " -"to index the position (see :ref:`User Guide `)" +"BOTTOM`: created at the bottom of the parent scope. You can also use a integer to " +"index the position (see :ref:`User Guide `)" msgstr "" "在父scope中创建此scope的位置.\n" "可选值: `OutputPosition.TOP` : 在父scope的顶部创建, `OutputPosition.BOTTOM`: 在父" @@ -390,9 +389,8 @@ msgstr "" #: of pywebio.output.set_scope:8 msgid "" "What to do when the specified scope already exists: - `None`: Do nothing - " -"`'remove'`: Remove the old scope first and then create a new one - `'clear'`: " -"Just clear the contents of the old scope, but don't create a new scope Default " -"is `None`" +"`'remove'`: Remove the old scope first and then create a new one - `'clear'`: Just " +"clear the contents of the old scope, but don't create a new scope Default is `None`" msgstr "" #: of pywebio.output.set_scope:8 @@ -423,8 +421,8 @@ msgstr "获取当前运行时scope栈中的scope名" #: of pywebio.output.get_scope:3 msgid "" "The index of the runtime scope stack. Default is -1. 0 means the top level " -"scope(the ROOT Scope), -1 means the current Scope, -2 means the scope used " -"before entering the current scope, …" +"scope(the ROOT Scope), -1 means the current Scope, -2 means the scope used before " +"entering the current scope, …" msgstr "" #: of pywebio.output.get_scope:3 @@ -433,10 +431,9 @@ msgstr "需要获取的scope在scope栈中的索引值。默认返回当前scope #: of pywebio.output.get_scope:5 msgid "" -"0 means the top level scope(the ROOT Scope), -1 means the current Scope, -2 " -"means the scope used before entering the current scope, …" -msgstr "" -"-1表示当前scope,-2表示进入当前scope前的scope,依次类推;0表示 `ROOT` scope" +"0 means the top level scope(the ROOT Scope), -1 means the current Scope, -2 means " +"the scope used before entering the current scope, …" +msgstr "-1表示当前scope,-2表示进入当前scope前的scope,依次类推;0表示 `ROOT` scope" #: of pywebio.output.get_scope pywebio.output.output pywebio.output.style msgid "Returns" @@ -444,8 +441,7 @@ msgstr "" #: of pywebio.output.get_scope:8 msgid "" -"Returns the scope name with the index, and returns ``None`` when occurs index " -"error" +"Returns the scope name with the index, and returns ``None`` when occurs index error" msgstr "返回Scope栈中对应索引的scope名,索引错误时返回None" #: of pywebio.output.clear:1 @@ -454,8 +450,8 @@ msgstr "清空scope内容" #: of pywebio.output.clear:3 pywebio.output.remove:3 msgid "" -"Can specify the scope name or use a integer to index the runtime scope stack " -"(see :ref:`User Guide `)" +"Can specify the scope name or use a integer to index the runtime scope stack (see :" +"ref:`User Guide `)" msgstr "" "可以直接指定scope名或使用int索引运行时scope栈(参见 :ref:`输出函数的scope相关参数 " "`)" @@ -473,8 +469,8 @@ msgid "" "Target scope. Can specify the scope name or use a integer to index the runtime " "scope stack (see :ref:`User Guide `)" msgstr "" -"目标scope。可以直接指定scope名或使用int索引运行时scope栈(参见 :ref:`输出函数的" -"scope相关参数 `)" +"目标scope。可以直接指定scope名或使用int索引运行时scope栈(参见 :ref:`输出函数的scope" +"相关参数 `)" #: of pywebio.output.scroll_to:4 msgid "" @@ -503,8 +499,8 @@ msgstr "``'bottom'`` : 滚动页面,让Scope位于屏幕可视区域底部" #: of pywebio.output.use_scope:1 msgid "Open or enter a scope. Can be used as context manager and decorator." msgstr "" -"scope的上下文管理器和装饰器。用于创建一个新的输出域并进入,或进入一个已经存在的输" -"出域。" +"scope的上下文管理器和装饰器。用于创建一个新的输出域并进入,或进入一个已经存在的输出" +"域。" #: of pywebio.output.use_scope:3 msgid "See :ref:`User manual - use_scope() `" @@ -512,11 +508,11 @@ msgstr "参见 :ref:`用户手册-use_scope() `" #: of pywebio.output.use_scope:5 msgid "" -"Scope name. If it is None, a globally unique scope name is generated. (When used " -"as context manager, the context manager will return the scope name)" +"Scope name. If it is None, a globally unique scope name is generated. (When used as " +"context manager, the context manager will return the scope name)" msgstr "" -"scope名. 若为None则生成一个全局唯一的scope名.(以上下文管理器形式的调用时,上下文" -"管理器会返回scope名)" +"scope名. 若为None则生成一个全局唯一的scope名.(以上下文管理器形式的调用时,上下文管" +"理器会返回scope名)" #: of pywebio.output.use_scope:6 msgid "Whether to clear the contents of the scope before entering the scope." @@ -528,10 +524,9 @@ msgstr "scope不存在时是否创建scope" #: of pywebio.output.use_scope:8 msgid "" -"Extra parameters passed to `set_scope()` when need to create scope. Only " -"available when ``create_scope=True``." -msgstr "" -"创建scope时传入 `set_scope()` 的额外的参数. 仅在 `create_scope=True` 时有效." +"Extra parameters passed to `set_scope()` when need to create scope. Only available " +"when ``create_scope=True``." +msgstr "创建scope时传入 `set_scope()` 的额外的参数. 仅在 `create_scope=True` 时有效." #: of pywebio.output.use_scope msgid "Usage" @@ -549,8 +544,8 @@ msgstr "" #: of pywebio.output.put_text:3 msgid "" -"Texts need to output. The type can be any object, and the `str()` function will " -"be used for non-string objects." +"Texts need to output. The type can be any object, and the `str()` function will be " +"used for non-string objects." msgstr "" "要输出的内容。类型可以为任意对象,对非字符串对象会应用 `str()` 函数作为输出值。" @@ -563,14 +558,14 @@ msgid "" "Use text as an inline element (no line break at the end of the text). Default is " "``False``" msgstr "" -"将文本作为行内元素(连续输出的文本显示在相同的段落中)。默认每次输出的文本都作为一" -"个独立的段落" +"将文本作为行内元素(连续输出的文本显示在相同的段落中)。默认每次输出的文本都作为一个独" +"立的段落" #: of pywebio.output.put_text:6 msgid "" "The target scope to output. If the scope does not exist, no operation will be " -"performed. Can specify the scope name or use a integer to index the runtime " -"scope stack." +"performed. Can specify the scope name or use a integer to index the runtime scope " +"stack." msgstr "" #: of pywebio.output.put_text:6 @@ -580,8 +575,7 @@ msgid "" msgstr "内容输出的目标scope,若scope不存在,则不进行任何输出操作。" #: of pywebio.output.put_text:8 -msgid "" -"Can specify the scope name or use a integer to index the runtime scope stack." +msgid "Can specify the scope name or use a integer to index the runtime scope stack." msgstr "可以直接指定目标Scope名,或者使用int通过索引Scope栈来确定Scope" #: of pywebio.output.put_text:9 @@ -590,10 +584,9 @@ msgstr "在scope中输出的位置。" #: of pywebio.output.put_text:11 msgid "" -"For more information about ``scope`` and ``position`` parameter, please refer " -"to :ref:`User Manual `" -msgstr "" -"参数 `scope` 和 `position` 的更多使用说明参见 :ref:`用户手册 `" +"For more information about ``scope`` and ``position`` parameter, please refer to :" +"ref:`User Manual `" +msgstr "参数 `scope` 和 `position` 的更多使用说明参见 :ref:`用户手册 `" #: of pywebio.output.put_markdown:3 msgid "Markdown string" @@ -617,39 +610,38 @@ msgid "" "using_advanced#options (Only supports members of string and boolean type)" msgstr "" "解析Markdown时的配置参数。\n" -"PyWebIO使用 `marked `_ 解析Markdown, 可配置项参见: " -"https://marked.js.org/using_advanced#options (仅支持配置string和boolean类型的项)" +"PyWebIO使用 `marked `_ 解析Markdown, 可配置项参见: https://" +"marked.js.org/using_advanced#options (仅支持配置string和boolean类型的项)" #: of pywebio.output.put_html:4 pywebio.output.put_markdown:8 msgid "" "Whether to use `DOMPurify `_ to filter the " "content to prevent XSS attacks." msgstr "" -"是否使用 `DOMPurify `_ 对内容进行过滤来防止" -"XSS攻击。" - -#: of pywebio.output:109 pywebio.output.put_buttons:36 pywebio.output.put_code:6 -#: pywebio.output.put_collapse:7 pywebio.output.put_column:6 -#: pywebio.output.put_file:8 pywebio.output.put_grid:17 pywebio.output.put_html:5 -#: pywebio.output.put_image:9 pywebio.output.put_link:7 -#: pywebio.output.put_loading:6 pywebio.output.put_markdown:9 -#: pywebio.output.put_processbar:7 pywebio.output.put_row:18 -#: pywebio.output.put_scrollable:9 pywebio.output.put_table:11 -#: pywebio.output.put_widget:9 +"是否使用 `DOMPurify `_ 对内容进行过滤来防止XSS" +"攻击。" + +#: of pywebio.output:111 pywebio.output.put_buttons:36 pywebio.output.put_code:6 +#: pywebio.output.put_collapse:7 pywebio.output.put_column:6 pywebio.output.put_file:8 +#: pywebio.output.put_grid:17 pywebio.output.put_html:5 pywebio.output.put_image:9 +#: pywebio.output.put_link:7 pywebio.output.put_loading:6 +#: pywebio.output.put_markdown:9 pywebio.output.put_processbar:7 +#: pywebio.output.put_row:18 pywebio.output.put_scrollable:9 +#: pywebio.output.put_table:11 pywebio.output.put_widget:9 msgid "Those arguments have the same meaning as for `put_text()`" msgstr "与 `put_text` 函数的同名参数含义一致" #: of pywebio.output.put_markdown:11 msgid "" -"When using Python triple quotes syntax to output multi-line Markdown in a " -"function, if you indent the Markdown text, you can use ``strip_indent`` or " -"``lstrip`` to prevent Markdown from parsing errors (But do not use " -"``strip_indent`` and ``lstrip`` at the same time)::" +"When using Python triple quotes syntax to output multi-line Markdown in a function, " +"if you indent the Markdown text, you can use ``strip_indent`` or ``lstrip`` to " +"prevent Markdown from parsing errors (But do not use ``strip_indent`` and " +"``lstrip`` at the same time)::" msgstr "" -"当在函数中使用Python的三引号语法输出多行内容时,为了排版美观可能会对Markdown文本" -"进行缩进,\n" -"这时候,可以设置 ``strip_indent`` 或 ``lstrip`` 来防止Markdown错误解析(但不要同时" -"使用 ``strip_indent`` 和 ``lstrip`` )::" +"当在函数中使用Python的三引号语法输出多行内容时,为了排版美观可能会对Markdown文本进行" +"缩进,\n" +"这时候,可以设置 ``strip_indent`` 或 ``lstrip`` 来防止Markdown错误解析(但不要同时使" +"用 ``strip_indent`` 和 ``lstrip`` )::" #: of pywebio.output.put_markdown:13 msgid "" @@ -672,14 +664,13 @@ msgid "" " \"\"\", strip_indent=4)" msgstr "" -#: of pywebio.output:106 +#: of pywebio.output:108 msgid "" "Message contents. The item is ``put_xxx()`` call, and any other type will be " "coverted to ``put_text(content)``." -msgstr "" -"消息内容. 元素为 ``put_xxx()`` 调用,其他类型会被转换成 ``put_text(content)``" +msgstr "消息内容. 元素为 ``put_xxx()`` 调用,其他类型会被转换成 ``put_text(content)``" -#: of pywebio.output:108 +#: of pywebio.output:110 msgid "Whether to show a dismiss button on the right of the message." msgstr "" @@ -723,8 +714,7 @@ msgid "" msgstr "进度条名称,为进度条的唯一标识" #: of pywebio.output.put_processbar:4 -msgid "" -"The initial progress value of the progress bar. The value is between 0 and 1" +msgid "The initial progress value of the progress bar. The value is between 0 and 1" msgstr "进度条初始值. 进度条的值在 0 ~ 1 之间" #: of pywebio.output.put_processbar:5 pywebio.output.set_processbar:5 @@ -790,8 +780,8 @@ msgstr "`put_loading()` 支持直接调用和上下文管理器:" #: of pywebio.output.put_loading:10 msgid "" "for shape in ('border', 'grow'):\n" -" for color in ('primary', 'secondary', 'success', 'danger', 'warning', " -"'info', 'light', 'dark'):\n" +" for color in ('primary', 'secondary', 'success', 'danger', 'warning', 'info', " +"'light', 'dark'):\n" " put_text(shape, color)\n" " put_loading(shape=shape, color=color)\n" "\n" @@ -816,15 +806,15 @@ msgstr "代码语言" #: of pywebio.output.put_code:5 msgid "" -"The max lines of code can be displayed, no limit by default. The scroll bar will " -"be displayed when the content exceeds." +"The max lines of code can be displayed, no limit by default. The scroll bar will be " +"displayed when the content exceeds." msgstr "代码块最多可显示的文本行数,默认不限制。内容超出时会使用滚动条。" #: of pywebio.output.put_table:3 msgid "" -"Table data, which can be a two-dimensional list or a list of dict. The table " -"cell can be a string or ``put_xxx()`` call. The cell can use the :func:`span()` " -"to set the cell span." +"Table data, which can be a two-dimensional list or a list of dict. The table cell " +"can be a string or ``put_xxx()`` call. The cell can use the :func:`span()` to set " +"the cell span." msgstr "" "表格数据。列表项可以为 ``list`` 或者 ``dict`` , 单元格的内容可以为字符串或 " "``put_xxx`` 类型的输出函数。\n" @@ -833,9 +823,9 @@ msgstr "" #: of pywebio.output.put_table:5 msgid "" "Table header. When the item of ``tdata`` is of type ``list``, if the ``header`` " -"parameter is omitted, the first item of ``tdata`` will be used as the header. " -"The header item can also use the :func:`span()` function to set the cell span. " -"When ``tdata`` is list of dict, ``header`` is used to specify the order of table " +"parameter is omitted, the first item of ``tdata`` will be used as the header. The " +"header item can also use the :func:`span()` function to set the cell span. When " +"``tdata`` is list of dict, ``header`` is used to specify the order of table " "headers, which cannot be omitted. In this case, the ``header`` can be a list of " "dict key or a list of ``(