Skip to main content

pytwain

This library allows acquiring images from various sources that support TWAIN protocol, e.g. scanners.

To install this library run:

pip install pytwain

Once installed you can run following sample Python script to acquire an image:

import twain
import tkinter
import logging

logging.basicConfig(level=logging.DEBUG)
root = tkinter.Tk()
root.title('scan.py')
with twain.SourceManager(root) as sm:
    # this will show UI to allow user to select source
    src = sm.open_source()
    if src:
        src.request_acquire(show_ui=False, modal_ui=False)
        (handle, remaining_count) = src.xfer_image_natively()
        twain.dib_to_bm_file(handle, 'testscan.bmp')
    else:
        print("User clicked cancel")

Full documentation for the library located here.

This library uses ctypes to access TWAIN API, therefore it does not require compilation and can work with Pypi.

References

Metadata

Release files for pytwain 2.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pytwain 2.2.2
File Size Uploaded Provenance Actions
pytwain-2.2.2.tar.gz 26.6 kB Without provenance Details for pytwain-2.2.2.tar.gz

Release files / pytwain-2.2.2.tar.gz

Download URL pytwain-2.2.2.tar.gz
Size 26.6 kB
Tags Source
SHA-256 checksum
How to use checksums
93f8edd371903b9eeddf731bce724d28499119ed82496bc2f2f7a4867c7df1d4
BLAKE2b-256 checksum
How to use checksums
7722835d85c3e7f8d8d90475bc1fbadb55c68c783087609f4ec3cf18b2acfbbb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.5

Security for pytwain 2.2.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page