index.py 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. from config import charts_demo_host
  2. from pywebio.output import put_markdown, put_row, put_html
  3. from pywebio.session import info as session_info
  4. index_md = r"""### Basic demo
  5. - [BMI calculation](./bmi): Calculating Body Mass Index based on height and weight
  6. - [Online chat room](./chat_room): Chat with everyone currently online (using less than 90 lines of code)
  7. - [Markdown live preview](./markdown_previewer): The online markdown editor with live preview (using less than 40 lines of code)
  8. - [Online Gomoku game](./gomoku_game): An online shared Gomoku game (using less than 100 lines of code)
  9. - [Input demo](./input_usage): Demonstrate the usage of PyWebIO input module
  10. - [Output demo](./output_usage): Demonstrate the usage of PyWebIO output module
  11. - [Theme preview](./theme): Demo page with various themes supported by PyWebIO
  12. ### Data visualization demo
  13. PyWebIO supports for data visualization with the third-party libraries.
  14. - Use `bokeh` for data visualization [**demos**]({charts_demo_host}/?app=bokeh)
  15. - Use `plotly` for data visualization [**demos**]({charts_demo_host}/?app=plotly)
  16. - Use `pyecharts` to create Echarts-based charts in Python [**demos**]({charts_demo_host}/?app=pyecharts)
  17. - Use `pyg2plot` to create G2Plot-based charts in Python [**demos**]({charts_demo_host}/?app=pyg2plot)
  18. - Use `cutecharts.py` to create hand drawing style charts [**demos**]({charts_demo_host}/?app=cutecharts)
  19. **Screenshots**
  20. <a href="{charts_demo_host}/?app=bokeh">
  21. <img src="https://cdn.jsdelivr.net/gh/wang0618/pywebio-chart-gallery/assets/bokeh.png" alt="bokeh demo">
  22. </a>
  23. <a href="{charts_demo_host}/?app=plotly">
  24. <img src="https://cdn.jsdelivr.net/gh/wang0618/pywebio-chart-gallery/assets/plotly.png" alt="plotly demo">
  25. </a>
  26. <a href="{charts_demo_host}/?app=pyecharts">
  27. <img src="https://cdn.jsdelivr.net/gh/wang0618/pywebio-chart-gallery/assets/pyecharts.gif" alt="pyecharts demo">
  28. </a>
  29. <a href="{charts_demo_host}/?app=cutecharts">
  30. <img src="https://cdn.jsdelivr.net/gh/wang0618/pywebio-chart-gallery/assets/cutecharts.png" alt="cutecharts demo">
  31. </a>
  32. ### Links
  33. * PyWebIO Github [github.com/wang0618/PyWebIO](https://github.com/wang0618/PyWebIO)
  34. * Document [pywebio.readthedocs.io](https://pywebio.readthedocs.io)
  35. """.format(charts_demo_host=charts_demo_host)
  36. index_md_zh = r"""### 基本demo
  37. - [BMI计算](./bmi): 根据身高体重计算BMI指数
  38. - [聊天室](./chat_room): 和当前所有在线的人聊天 (不到90行代码实现)
  39. - [Markdown实时预览](./markdown_previewer): 可以实时预览的在线Markdown编辑器 (不到40行代码实现)
  40. - [在线五子棋游戏](./gomoku_game): 多人协作对战的五子棋游戏 (不到100行代码实现)
  41. - [输入演示](./input_usage): 演示PyWebIO输入模块的用法
  42. - [输出演示](./output_usage): 演示PyWebIO输出模块的用法
  43. - [主题预览](./theme): 展示PyWebIO支持的各种主题
  44. - 更多Demo请见[文档](https://pywebio.readthedocs.io)中示例代码的在线Demo
  45. ### 数据可视化demo
  46. PyWebIO还支持使用第三方库进行数据可视化
  47. - 使用`bokeh`进行数据可视化 [**demos**]({charts_demo_host}/?app=bokeh)
  48. - 使用`plotly`进行数据可视化 [**demos**]({charts_demo_host}/?app=plotly)
  49. - 使用`pyecharts`创建基于Echarts的图表 [**demos**]({charts_demo_host}/?app=pyecharts)
  50. - 使用`pyg2plot`创建基于G2Plot的图表 [**demos**]({charts_demo_host}/?app=pyg2plot)
  51. - 使用`cutecharts.py`创建卡通风格图表 [**demos**]({charts_demo_host}/?app=cutecharts)
  52. **数据可视化demo截图**
  53. <a href="{charts_demo_host}/?app=bokeh">
  54. <img src="https://cdn.jsdelivr.net/gh/wang0618/pywebio-chart-gallery/assets/bokeh.png" alt="bokeh demo">
  55. </a>
  56. <a href="{charts_demo_host}/?app=plotly">
  57. <img src="https://cdn.jsdelivr.net/gh/wang0618/pywebio-chart-gallery/assets/plotly.png" alt="plotly demo">
  58. </a>
  59. <a href="{charts_demo_host}/?app=pyecharts">
  60. <img src="https://cdn.jsdelivr.net/gh/wang0618/pywebio-chart-gallery/assets/pyecharts.gif" alt="pyecharts demo">
  61. </a>
  62. <a href="{charts_demo_host}/?app=cutecharts">
  63. <img src="https://cdn.jsdelivr.net/gh/wang0618/pywebio-chart-gallery/assets/cutecharts.png" alt="cutecharts demo">
  64. </a>
  65. ### Links
  66. * PyWebIO Github [github.com/wang0618/PyWebIO](https://github.com/wang0618/PyWebIO)
  67. * 使用手册和实现文档见 [pywebio.readthedocs.io](https://pywebio.readthedocs.io/zh_CN/latest/)
  68. """.format(charts_demo_host=charts_demo_host)
  69. def main():
  70. """PyWebIO demos
  71. Basic demo and data visualization demo of PyWebIO.
  72. PyWebIO的基本demo和数据可视化demo
  73. """
  74. put_row([
  75. put_markdown('# PyWebIO demos'),
  76. put_html(
  77. '<a class="github-button" data-size="large" href="https://github.com/wang0618/PyWebIO" data-show-count="true" aria-label="Star wang0618/PyWebIO on GitHub">Star</a>')
  78. ], size='1fr auto').style('align-items:center')
  79. put_html('<script async defer src="https://buttons.github.io/buttons.js"></script>')
  80. if 'zh' in session_info.user_language:
  81. put_markdown(index_md_zh)
  82. else:
  83. put_markdown(index_md)