pywebio_battery --- PyWebIO battery¶
Utilities that help write PyWebIO apps quickly and easily.
توجه
pywebio_battery is an extension package of PyWebIO, you must install it before using it.
To install this package, run pip3 install -U pywebio-battery
Functions list¶
Interaction related¶
Function name |
Description |
Confirmation modal |
|
Show a form in popup window |
|
redirecting stdout to pywebio |
|
Run command in shell |
|
Logbox widget |
Web application related¶
Function name |
Description |
Get URL parameter |
|
User browser storage |
|
Web Cookie |
|
|
Authentication |
-
pywebio_battery.confirm(title, content=None, *, timeout=None)[source]¶ Show a confirmation modal.
- پارامترها
title (str) -- Model title.
content (list/put_xxx()) -- Model content.
timeout (None/float) -- Seconds for operation time out.
- Returns
Return
Truewhen the "CONFIRM" button is clicked, returnFalsewhen the "CANCEL" button is clicked, returnNonewhen a timeout is given and the operation times out.
-
pywebio_battery.popup_input(pins, title='Please fill out the form below')[source]¶ Show a form in popup window.
- پارامترها
pins (list) -- pin output list.
title (str) -- model title.
- Returns
return the form value as dict, return None when user cancel the form.
-
pywebio_battery.redirect_stdout(output_func=functools.partial(<function put_text>, inline=True))[source]¶ Context manager for temporarily redirecting stdout to pywebio.
with redirect_stdout(): print("Hello world.")
-
pywebio_battery.run_shell(cmd, output_func=functools.partial(<function put_text>, inline=True))[source]¶ Run command in shell and output the result to pywebio
-
pywebio_battery.put_logbox(name, height=400, keep_bottom=True) → pywebio.io_ctrl.Output[source]¶ Output a logbox widget
import time put_logbox("log") while True: logbox_append("log", f"{time.time()}\n") time.sleep(0.2)
- پارامترها
name (str) -- the name of the widget, must unique in session-wide.
height (int) -- the height of the widget in pixel
keep_bottom (bool) -- Whether to scroll to bottom when new content is appended (via
logbox_append()).
تغییر داده شده در نسخه 0.3: add
keep_bottomparameter
-
pywebio_battery.get_all_query()[source]¶ Get URL parameter (also known as "query strings" or "URL query parameters") as a dict
-
pywebio_battery.set_localstorage(key, value)[source]¶ Save data to user's web browser
The data is specific to the origin (protocol+domain+port) of the app. Different origins use different web browser local storage.
- پارامترها
key (str) -- the key you want to create/update.
value (str) -- the value you want to give the key you are creating/updating.
You can read the value by using
get_localstorage(key)