PyWebIO Theme Preview
()
| 331 | |
| 332 | @config(css_style=style) |
| 333 | def page(): |
| 334 | """PyWebIO Theme Preview""" |
| 335 | |
| 336 | theme = eval_js("new URLSearchParams(window.location.search).get('app')") |
| 337 | if theme not in ALL_THEME: |
| 338 | theme = 'default' |
| 339 | |
| 340 | put_html(f""" |
| 341 | <div class="page-header"> |
| 342 | <div style="text-align: center"> |
| 343 | <h1>{theme[0].upper() + theme[1:]}</h1> |
| 344 | <p class="lead">{THEME_SUMMARY.get(theme, '')}</p> |
| 345 | </div> |
| 346 | </div> |
| 347 | """) |
| 348 | |
| 349 | put_markdown('# Switch Theme') |
| 350 | themes = [ |
| 351 | put_image(f"https://fastly.jsdelivr.net/gh/wang0618/PyWebIO@dev/docs/assets/theme/{name}.png").onclick( |
| 352 | partial(go_app, name=name, new_window=False)) |
| 353 | for name in ALL_THEME if name != theme |
| 354 | ] |
| 355 | if info.user_agent.is_mobile: |
| 356 | put_table([themes[:2], themes[2:]]) |
| 357 | else: |
| 358 | put_table([themes]) |
| 359 | |
| 360 | if theme != 'default': |
| 361 | put_markdown(f""" |
| 362 | ### Usage |
| 363 | Use `pywebio.config()` to apply this theme: |
| 364 | |
| 365 | ```python |
| 366 | @config(theme="{theme}") |
| 367 | def main(): |
| 368 | put_text("hello world") |
| 369 | |
| 370 | start_server(main, port=8080) |
| 371 | ``` |
| 372 | """) |
| 373 | |
| 374 | put_markdown(""" |
| 375 | ### Credits |
| 376 | |
| 377 | The dark theme is modified from ForEvolve's [bootstrap-dark](https://github.com/ForEvolve/bootstrap-dark). |
| 378 | The sketchy, minty and yeti theme are from [bootswatch](https://bootswatch.com/4/). |
| 379 | """) |
| 380 | |
| 381 | set_env(input_panel_min_height=100, input_panel_init_height=190) |
| 382 | output_widgets() |
| 383 | pin_widgets() |
| 384 | form() |
| 385 | |
| 386 | |
| 387 | # bind each theme to the app |
nothing calls this directly
no test coverage detected
searching dependent graphs…