run_documentation.py 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. from nicegui import ui
  2. from ..tools import text_demo
  3. def main_demo() -> None:
  4. ui.label('page with custom title')
  5. # ui.run(title='My App')
  6. main_demo.tab = 'My App'
  7. def more() -> None:
  8. @text_demo('Emoji favicon', '''
  9. You can use an emoji as favicon.
  10. This works in Chrome, Firefox and Safari.
  11. ''', tab=lambda: ui.markdown('🚀  NiceGUI'))
  12. def emoji_favicon():
  13. ui.label('NiceGUI Rocks!')
  14. # ui.run(favicon='🚀')
  15. @text_demo(
  16. 'Base64 favicon', '''
  17. You can also use an base64-encoded image as favicon.
  18. ''', tab=lambda: (
  19. ui.image('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==')
  20. .classes('w-4 h-4'),
  21. ui.label('NiceGUI'),
  22. ),
  23. )
  24. def base64_favicon():
  25. ui.label('NiceGUI with a red dot!')
  26. icon = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg=='
  27. # ui.run(favicon=icon)
  28. @text_demo('SVG favicon', '''
  29. And directly use an SVG as favicon.
  30. Works in Chrome, Firefox and Safari.
  31. ''', tab=lambda: (
  32. ui.html('''
  33. <svg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg">
  34. <circle cx="100" cy="100" r="78" fill="#ffde34" stroke="black" stroke-width="3" />
  35. <circle cx="80" cy="85" r="8" />
  36. <circle cx="120" cy="85" r="8" />
  37. <path d="m60,120 C75,150 125,150 140,120" style="fill:none; stroke:black; stroke-width:8; stroke-linecap:round" />
  38. </svg>
  39. ''').classes('w-4 h-4'),
  40. ui.label('NiceGUI'),
  41. ))
  42. def svg_favicon():
  43. ui.label('NiceGUI makes you smile!')
  44. smiley = '''
  45. <svg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg">
  46. <circle cx="100" cy="100" r="78" fill="#ffde34" stroke="black" stroke-width="3" />
  47. <circle cx="80" cy="85" r="8" />
  48. <circle cx="120" cy="85" r="8" />
  49. <path d="m60,120 C75,150 125,150 140,120" style="fill:none; stroke:black; stroke-width:8; stroke-linecap:round" />
  50. </svg>
  51. '''
  52. # ui.run(favicon=smiley)