MCPcopy Index your code
hub / github.com/pywebio/PyWebIO / page

Function page

demos/theme.py:333–384  ·  view source on GitHub ↗

PyWebIO Theme Preview

()

Source from the content-addressed store, hash-verified

331
332@config(css_style=style)
333def 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&#x27;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

Callers

nothing calls this directly

Calls 11

eval_jsFunction · 0.85
put_htmlFunction · 0.85
put_markdownFunction · 0.85
put_imageFunction · 0.85
put_tableFunction · 0.85
set_envFunction · 0.85
output_widgetsFunction · 0.85
pin_widgetsFunction · 0.85
formFunction · 0.85
onclickMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…