You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
put_markdown(t("In fact, all output can be bound to click events, not just buttons. You can call `onclick()` method after the output function (function name like `put_xxx()`) call:", "事实上,不仅是按钮,所有的输出都可以绑定点击事件。你可以在输出函数之后调用 `onclick()` 方法来绑定点击事件:")+r"""
193
+
```python
194
+
put_image('some-image.png').onclick(lambda: toast('You click the image'))
195
+
196
+
# set onclick in combined output
197
+
put_table([
198
+
['Commodity', 'Price'],
199
+
['Apple', put_text('5.5').onclick(lambda: toast('You click the text'))],
200
+
])
201
+
```
202
+
""", strip_indent=4)
203
+
204
+
put_image('https://www.python.org/static/img/python-logo.png').onclick(lambda: toast('You click the image'))
205
+
# set onclick in combined output
206
+
put_table([
207
+
['Commodity', 'Price'],
208
+
['Apple', put_text('5.5').onclick(lambda: toast('You click the text'))],
209
+
])
210
+
211
+
put_markdown(t("The return value of `onclick()` method is the object itself so it can be used in combined output.",
212
+
"`onclick()` 方法的返回值为对象本身,所以可以继续用于组合输出中。"))
213
+
214
+
189
215
put_markdown(t(r"""### Output Scope
190
216
191
217
PyWebIO uses the scope model to give more control to the location of content output. The output area of PyWebIO can be divided into different output domains. The output domain is called Scope in PyWebIO.
@@ -307,40 +333,25 @@ def btn_click(btn_val):
307
333
"""%t('None represents the space between the output', 'None 表示输出之间的空白'))
308
334
309
335
put_markdown(t(r"""### Style
310
-
If you are familiar with CSS styles, you can use the `style()` function to set a custom style for the output.
336
+
If you are familiar with CSS styles, you can use the `style()` method to set a custom style for the output.
311
337
312
338
You can set the CSS style for a single `put_xxx()` output:
313
339
""", r"""### 样式
314
340
315
-
如果你熟悉 CSS样式 ,你还可以使用 `style()` 函数给输出设定自定义样式。
341
+
如果你熟悉 CSS样式 ,你还可以使用 `style()` 方法给输出设定自定义样式。
316
342
317
343
可以给单个的 `put_xxx()` 输出设定CSS样式,也可以配合组合输出使用:
318
344
"""), strip_indent=4)
319
345
320
346
code_block(r"""
321
-
style(put_text('Red'), 'color: red')
347
+
put_text('Red').style('color: red')
322
348
323
349
put_table([
324
350
['A', 'B'],
325
-
['C', style(put_text('Red'), 'color: red')],
351
+
['C', put_text('Red').style('color: red')],
326
352
])
327
353
""", strip_indent=4)
328
354
329
-
put_markdown(t(r"`style()` also accepts a list of output calls:", r"`style()` 也接受列表作为输入:"))
330
-
331
-
code_block(r"""
332
-
style([
333
-
put_text('Red'),
334
-
put_markdown('~~del~~')
335
-
], 'color: red')
336
-
337
-
put_collapse('title', style([
338
-
put_text('text'),
339
-
put_markdown('~~del~~'),
340
-
], 'margin-left: 20px'))
341
-
342
-
""", strip_indent=4)
343
-
344
355
put_markdown(t("""----
345
356
For more information about output of PyWebIO, please visit PyWebIO [User Guide](https://pywebio.readthedocs.io/zh_CN/latest/guide.html) and [output module documentation](https://pywebio.readthedocs.io/zh_CN/latest/output.html).
0 commit comments