- Pasteboard Viewer Inspect the system pasteboards. Support; Check out my newsletter to follow updates to this app and other things I'm working on.
- Boardview is a type of files containing information about printed circuit boards, their components, used signals, test points and more. These files may have following.
Released:
Pasteboard - Python interface for reading from NSPasteboard (macOS clipboard)
Project description
I don't know of a way to reduce the size of the pasteboard. If you go to View menu and select Actual size, Fit page, or Fit Spread, you can resize the window to show less of the pasteboard. Generally, slowness is tied to several things and your machine's display RAM and cpu RAM. The more in each the better.
Pasteboard exposes Python bindings for reading and writing macOS' AppKit NSPasteboard. This allows retrieving different formats (HTML/RTF fragments, PDF/PNG/TIFF) and efficient polling of the pasteboard.
Now with type hints!
Installation
Obviously, this module will only compile on macOS:
Usage
Getting the contents
Unsurprisingly, get_contents
gets the contents of the pasteboard. This methodtakes two optional arguments:
type - The format to get. Defaults to pasteboard.String
, which correspondsto NSPasteboardTypeString. See the pasteboard
module members for otheroptions such as HTML fragment, RTF, PDF, PNG, and TIFF. Not all formats of NSPasteboardType are implemented.
diff - Defaults to False
. When True
, only get and return the contents if it has changed since the last call. Otherwise, None
is returned. This can be used to efficiently monitor the pasteboard for changes, which must be done by polling (there is no option to subscribe to changes).
get_contents
will return the appropriate type, so str for string types,and bytes for binary types. None
is returned when:
Pasteboard Viewer Free
- There is no data of the requested type (e.g. an image was copied but a string was requested)
- diff is
True
, and the contents has not changed since the last call - An error occurred
Setting the contents
Analogously, set_contents
sets the contents of the pasteboard. This methodtakes two arguments:
data - str or bytes-like object, required. There is no type checking. So if type
indicates a string type and data
is bytes-like but not UTF-8 encoded, the behaviour is undefined.
type - The format to set. Defaults to pasteboard.String
, which corresponds to NSPasteboardTypeString. See the pasteboard
module members for other options such as HTML fragment, RTF, PDF, PNG, and TIFF. Not all formats of NSPasteboardType are implemented.
set_contents
will return True
if the pasteboard was successfully set; otherwise, False
. It may also throw RuntimeError if data
can't be converted to an AppKit type.
Getting file URLs
Warning This API is new, and may change in future.
Returns a Tuple
of strings, or None
. Also supports the diff parameter analogue to get_contents
.
Development
You don't need to know this if you're not changing pasteboard.m
code. There are some integration tests in tests.py
to check the module works as designed (using pytest and hypothesis).
Pasteboard Viewer Download
This project uses pre-commit to run some linting hooks when committing. When you first clone the repo, please run:
You may also run the hooks at any time:
Dependencies are managed via poetry. To install all dependencies, use:
This will also install development dependencies (pytest
). To run the tests:
License
From version 0.3.0 and forwards, this library is licensed under the Mozilla Public License Version 2.0. For more information, see LICENSE
.
Release historyRelease notifications | RSS feed
0.3.3
0.3.2
Pasteboard Viewer Free
0.3.1
0.3.0
0.2.0
0.1.0
0.1.0.dev1 pre-release
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Filename, size | File type | Python version | Upload date | Hashes |
---|---|---|---|---|
Filename, size pasteboard-0.3.3-cp36-cp36m-macosx_10_15_x86_64.whl (18.5 kB) | File type Wheel | Python version cp36 | Upload date | Hashes |
Filename, size pasteboard-0.3.3-cp37-cp37m-macosx_10_15_x86_64.whl (18.5 kB) | File type Wheel | Python version cp37 | Upload date | Hashes |
Filename, size pasteboard-0.3.3-cp38-cp38-macosx_10_15_x86_64.whl (18.5 kB) | File type Wheel | Python version cp38 | Upload date | Hashes |
Filename, size pasteboard-0.3.3-cp39-cp39-macosx_10_15_x86_64.whl (18.5 kB) | File type Wheel | Python version cp39 | Upload date | Hashes |
Filename, size pasteboard-0.3.3.tar.gz (13.5 kB) | File type Source | Python version None | Upload date | Hashes |
Hashes for pasteboard-0.3.3-cp36-cp36m-macosx_10_15_x86_64.whl
Algorithm | Hash digest |
---|---|
SHA256 | afd171e200316f6b3d3da381476921ca57cb8f26d2fa418f779454913918dbb9 |
MD5 | 6b35620d9e9b766cb1bce9f5bc5ff82e |
BLAKE2-256 | c1812f4c032171c9420d3971bd26331dfb80abef1ca0c601d92076e7fe4a4f18 |
Hashes for pasteboard-0.3.3-cp37-cp37m-macosx_10_15_x86_64.whl
Algorithm | Hash digest |
---|---|
SHA256 | f99dd6c7039b755756b2068942c4c2487d6366e5a56eafd6db0ae7aa2a371a0e |
MD5 | 2851301be644d8da11c379a943e9d615 |
BLAKE2-256 | 5f02da1815dec5e8c661a2d1d7b00d9a187a4adc339fa8152bd703cccddc8f95 |
Hashes for pasteboard-0.3.3-cp38-cp38-macosx_10_15_x86_64.whl
Algorithm | Hash digest |
---|---|
SHA256 | 19229dfa28f41afb5e731ac81e52bbc4212f67d678c082d3e3621cec0628a773 |
MD5 | 405c46417732803c977deb6c0a64355e |
BLAKE2-256 | 74dc85955b080110bfc7716d77aca8f62a6e7d1d210c2eab03310dac18937b34 |
Hashes for pasteboard-0.3.3-cp39-cp39-macosx_10_15_x86_64.whl
Algorithm | Hash digest |
---|---|
SHA256 | 20a5c53bae8ac8186ecdd621020fb1b072d45a35f9f11a8e4cd5e82d76b485d0 |
MD5 | 8edf90a8fbab4522750d8ca6920001f1 |
BLAKE2-256 | 0e7a8ce2cf035b67f0aa57c71d8cdb1f522a8f0d6d2dd094d8c547c9fcbb6982 |
Hashes for pasteboard-0.3.3.tar.gz
Algorithm | Hash digest |
---|---|
SHA256 | d80275e76ff1eaaa5ca3d0e0fd8aecd5ea1298523dfd51f3774b5aaebdde02cf |
MD5 | 0849990178bf441b07968ef8d50e4b81 |
BLAKE2-256 | 0643adc39246de74e9c482c11fbe6a50e8bc7f9dc367fdc261f6f767de5b1419 |
#import<Foundation/Foundation.h> |
#import<AppKit/AppKit.h> |
intmain(int argc, char *argv[]) { |
@autoreleasepool { |
NSPasteboard *pasteboard = [NSPasteboardgeneralPasteboard]; |
NSLog(@'items: %@', pasteboard.pasteboardItems); |
for (NSPasteboardItem *item in pasteboard.pasteboardItems) { |
NSLog(@'types: %@', item.types); |
for (NSString *type in item.types) { |
NSData *data = [item dataForType:type]; |
NSString *string = [item stringForType:type]; |
NSLog(@'%@: %@', type, string); |
NSLog(@'%@: %@', type, data); |
NSString *writeOutPath = [NSStringstringWithFormat:@'~/Temp/%@', type]; |
writeOutPath = [writeOutPath stringByExpandingTildeInPath]; |
[data writeToFile:writeOutPath atomically:YES]; |
} |
} |
} |
} |
commented Feb 2, 2016
I recommend running this with CodeRunner |