Giter Club home page Giter Club logo

xerox's Introduction

Xerox: Copy + Paste clipboard access for Python

Upstream slow to to respond to PRs. Also consider https://github.com/asweigart/pyperclip where there is a PR for Wayland support (note as of 2021-08-13 it also has a backlog of PRs, also see https://github.com/clach04/pyperclip/tree/html_linux_win32). Differences to upstream:

  1. Doesn't crash when clipboard empty or contains non-text data (like bitmaps)
  2. Html formatted intent for both copy and paste (windows only)

Xerox is a copy + paste module for python. It's aim is simple: to be as incredibly simple as possible.

Supported platforms are currently OS X, X11 (Linux, BSD, etc.), and Windows.

If you can make it simpler, please fork.

Usage

Usage is as follows:

xerox.copy(u'some string')

And to paste:

>>> xerox.paste()
u'some string'

On Linux you can optionally also copy into the X selection clipboard for middle-click-paste capability:

xerox.copy(u'Some string', xsel=True)

And you can choose to paste from the X selection rather than the system clipboard:

xerox.paste(xsel=True)

On Windows you can optionally copy into the clipboard in html mode:

xerox.copy(u'<p>Writing to the clipboard is <strong>easy</strong> with this code.</p>', html=True)

This will also paste the html into the text clipboard for applications that do not support html mode. HTML paste from the clipboard is not implemented. Unlike xsel support, there is no silent failure if html mode is requested with a backend that does not support it.

And, that's it.

Command Line

To copy:

$ xerox some string

or:

$ echo some string | xerox

To paste:

>>> xerox
some string

Installation

To install Xerox, simply:

$ pip install xerox

Note: If you are installing xerox on Windows, you will also need to install the pywin32 module. FIXME see https://github.com/mu-editor/mu/blob/0203b6e850c16cbb95442026193f1f5bef33a3d4/setup.py#L77 for how to handle this in setup.py.

Note: On X11 systems, Xerox requires Xclip, which can be found through your system package manager (e.g. apt-get install xclip) or at https://github.com/astrand/xclip

To Do Items

Legal Stuff

MIT License.

(c) 2016 Kenneth Reitz.

xerox's People

Contributors

kennethreitz avatar clach04 avatar r4vi avatar bcj avatar ur1katz avatar werkshy avatar anne-decusatis avatar aisipos avatar valpackett avatar jnrowe avatar catch22 avatar jldiaz avatar

Watchers

 avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.