crossclip package

Submodules

crossclip.absbackend module

class crossclip.absbackend.AbstractBackend[source]

Bases: abc.ABC

Interface for all clipboard backends

This class is an interface for all clipboard backends to be registered into.

get_image(form)[source]

Synchronously gets image from clipboard :returns: Image from clipboard :rtype:

get_text()[source]

Synchronously gets text from clipboard :returns: Text from clipboard :rtype: str

set_image(img)[source]

Sets image to clipboard :param img: Image to set to clipboard :type img:

set_text(text)[source]

Sets text to the clipboard :param text: Text to add :type text: str

class crossclip.absbackend.AbstractImageConverter[source]

Bases: abc.ABC

Converts an image between a Pillow Image and a native clipboard image

This interface is needed to convert native images to pillow images and vice versa.

from_pillow(pil)[source]

Converts a pillow image to native type

image_str

String representing image

image_type

The type of native image

to_pillow(native_image)[source]

Converts a native image to Pillow iamge

crossclip.clipboard module

crossclip.gtkbackend module

class crossclip.gtkbackend.GtkBackend(display=None)[source]

Bases: crossclip.absbackend.AbstractBackend

Gtk Clipboard backend

This clipboard backends the Gtk.Clipboard class. It inherits from it and the base backend class. This way, it has all of the Gtk’s properties, but it can operate through the BaseBackend interface.

get_image(format='pil', converter=None)[source]

Synchronously gets image from clipboard. The image is either a pillow image, or a GdkPixbuf.Pixbuf.

Parameters:format – Format of image. ‘pil’ for pillow, ‘gdk-pixbuf’ for gdk pixbuf (default: ‘pil’)
Returns PIL.Image or GdkPixbuf.Pixbuf:
 Image in chosen format
Raises:RuntimeWarning – If format is invalid format
get_text()[source]

Synchronously gets text from clipboard.

Return str:Text from clipboard
image_converter = <crossclip.gtkbackend.GtkImageConverter object>
raw_clipboard = None
set_image(image, converter=None)[source]

Synchronously sets image to clipboard.

Parameters:
  • image – Some image object
  • format – format of image
Raises:

RuntimeWarning – If format is invalid

set_text(text, num=-1)[source]

Synchronously sets text to clipboard

Parameters:
  • text – text to set to clipboard
  • num – length of text to set. If -1, all text is copied (default: -1)
class crossclip.gtkbackend.GtkImageConverter[source]

Bases: crossclip.absbackend.AbstractImageConverter

from_pillow(image)[source]

Converts a PIL.Image to a GdkPixbuf.Pixbuf.

Parameters:imagePIL.Image to be convered
Returns GdkPixbuf.Pixbuf:
 Converted pixbuf
image_str

Returns a string representation of what the object is.

Returns str:‘gdk-pixbuf’
image_type

Returns the type of image that this converter uses.

Returns:GdkPixbuf.Pixbuf type (not object!)
to_pillow(pixbuf)[source]

Converts and image of self.image_type to a PIL.Image.

Parameters:pixbuf – GdkPixbuf.Pixbuf image
Returns PIL.Image:
 Converted Pillow Image

crossclip.qtbackend module

crossclip.winbackend module

Module contents