Clipboard
Provides access to the system clipboard.
Inherits: Service
Methods
-
get
–
Retrieves data from the clipboard.
-
set
–
Stores the given clipboard data on the clipboard.
Examples
import flet as ft
async def main(page: ft.Page):
async def set_to_clipboard():
await ft.Clipboard().set(text_to_copy.value)
text_to_copy.value = ""
page.show_dialog(ft.SnackBar("Text copied to clipboard"))
async def get_from_clipboard():
contents = await ft.Clipboard().get()
page.add(ft.Text(f"Clipboard contents: {contents}"))
page.add(
ft.Column(
[
text_to_copy := ft.TextField(label="Text to copy"),
ft.Button("Set to clipboard", on_click=set_to_clipboard),
ft.Button("Get from clipboard", on_click=get_from_clipboard),
],
)
)
ft.run(main)
Methods
get
async
Retrieves data from the clipboard.
set
async
Stores the given clipboard data on the clipboard.