pasteboard

Item Provider

An Item Provider is an object holding data that can be loaded as multiple file types. It can be returned from item_provider() or from shortcuts_attachments(). When you copy text for example, it may have formatting. So an ItemProvider object can in this case retrieve the clipboard as plain text or as an rtf file containing the text format.

class pasteboard.ItemProvider(foundation_item_provider: None)

A bridge to Foundation’s NSItemProvider class. An ItemProvider object can load data as one or more type of data. Instances of this class are returned by item_provider() and shortcuts_attachments().

pasteboard.item_provider() → pasteboard.ItemProvider

Returns an ItemProvider instance storing the data from the pasteboard, if there is any.

Strings

Functions for working with strings.

pasteboard.string() → str

Returns the text contained in the pasteboard.

pasteboard.strings() → List[str]

Returns all strings contained in the pasteboard.

pasteboard.set_string(text: Union[str, List[str]])

Copies the given text to the pasteboard.

Parameters:text – A string or a list of strings.

Images

Functions for working with images (as PIL images).

pasteboard.image() → PIL.Image.Image

Returns the image contained in the pasteboard as PIL images.

pasteboard.images() → List[PIL.Image.Image]

Returns all images contained in the pasteboard as PIL images.

pasteboard.set_image(image: Union[PIL.Image.Image, List[PIL.Image.Image]])

Copies the given image to the pasteboard.

Parameters:image – A PIL image or a list of PIL images.

URLs

Functions for working with URLs.

pasteboard.url() → str

Returns the URL contained in the pasteboard as a string.

pasteboard.urls() → List[str]

Returns all URLs contained in the pasteboard as strings.

pasteboard.set_url(url: Union[str, List[str]])

Copies the given URL to the pasteboard.

Parameters:url – A string or a list of strings.