main.py 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #!/usr/bin/env python3
  2. from pathlib import Path
  3. import docutils.core
  4. import website.api_docs_and_examples as api_docs_and_examples
  5. from nicegui import Client, ui
  6. ACCENT_COLOR = '#428BF5'
  7. HEADER_HEIGHT = '70px'
  8. @ui.page('/')
  9. async def index(client: Client):
  10. ui.add_head_html('<meta name="viewport" content="width=device-width, initial-scale=1" />')
  11. ui.add_head_html(docutils.core.publish_parts('', writer_name='html')['stylesheet'])
  12. client.content.classes(remove='q-pa-md gap-4').style('background: #f8f8f8')
  13. with ui.header() \
  14. .classes('justify-between items-center') \
  15. .style(f'background-color: {ACCENT_COLOR}; height: {HEADER_HEIGHT}') \
  16. .props('elevated'):
  17. ui.label('NiceGUI').classes('text-3xl')
  18. with ui.row().classes('items-center'):
  19. ui.link('Features').classes('text-lg').style('color: white!important')
  20. ui.link('Installation').classes('text-lg').style('color: white!important')
  21. ui.link('Documentation').classes('text-lg').style('color: white!important')
  22. ui.link('API Reference').classes('text-lg').style('color: white!important')
  23. ui.link('Docker').classes('text-lg').style('color: white!important')
  24. ui.link('Deployment').classes('text-lg').style('color: white!important')
  25. with ui.link(target='https://github.com/zauberzeug/nicegui/'):
  26. ui.html(Path('static/github.svg').read_text()).classes('fill-white scale-125 m-1')
  27. with ui.row() \
  28. .classes('w-full q-pa-md items-center gap-8') \
  29. .style(f'height: calc(100vh - {HEADER_HEIGHT}); transform: translateX(-375px)'):
  30. ui.icon('face').style('font-size: 5000%')
  31. with ui.column().classes('gap-8'):
  32. ui.markdown('The NiceGUI you really\n\nneed in your life.') \
  33. .style('font-size: 400%; line-height: 0.9; font-weight: 500')
  34. ui.markdown('An easy-to-use Python-based UI framework\n\nwhich shows up in your web browser.') \
  35. .style('font-size: 200%; line-height: 0.9')
  36. with ui.row() \
  37. .classes('w-full q-pa-md items-center gap-32 p-32 no-wrap') \
  38. .style(f'height: calc(100vh - {HEADER_HEIGHT}); background: {ACCENT_COLOR}'):
  39. with ui.column().classes('gap-8'):
  40. ui.markdown('Create buttons, dialogs, markdown,\n\n3D scenes, plots and much more at ease.') \
  41. .style('font-size: 300%; color: white; line-height: 0.9; font-weight: 500')
  42. ui.label('''
  43. It is great for micro web apps, dashboards, robotics projects, smart home solutions
  44. and similar use cases. You can also use it in development, for example when
  45. tweaking/configuring a machine learning algorithm or tuning motor controllers.
  46. NiceGUl is available as PyPl package, Docker image and on GitHub
  47. ''') \
  48. .style('font-size: 150%; color: white')
  49. with ui.card().style('min-width: 350px; height: 500px'):
  50. ui.label('Demo')
  51. with ui.row().classes('w-full q-pa-md'):
  52. api_docs_and_examples.create_intro()
  53. @ui.page('/reference')
  54. def reference():
  55. ui.add_head_html('<meta name="viewport" content="width=device-width, initial-scale=1" />')
  56. api_docs_and_examples.create_full()
  57. ui.run()