run_documentation.py 2.6 KB

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