download_documentation.py 570 B

12345678910111213141516
  1. from nicegui import ui
  2. from ...model import UiElementDocumentation
  3. class DownloadDocumentation(UiElementDocumentation, element=ui.download):
  4. def main_demo(self) -> None:
  5. ui.button('Logo', on_click=lambda: ui.download('https://nicegui.io/logo.png'))
  6. def more(self) -> None:
  7. @self.demo('Download raw bytes from memory', '''
  8. The `download` function can also be used to download raw bytes from memory.
  9. ''')
  10. def raw_bytes():
  11. ui.button('Download', on_click=lambda: ui.download(b'Hello World', 'hello.txt'))