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.1

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.1
File Size Uploaded Provenance Actions
pytwain-2.2.1.tar.gz 26.6 kB Without provenance Details for pytwain-2.2.1.tar.gz

Release files / pytwain-2.2.1.tar.gz

Download URL pytwain-2.2.1.tar.gz
Size 26.6 kB
Tags Source
SHA-256 checksum
How to use checksums
cc76426e7f9557b65e7de264bde3c078fe50587f493097d316b3ca3422e8825e
BLAKE2b-256 checksum
How to use checksums
ca482626a4b1388c63a0e14674f8c5a0bb428eee0a1792c91a9c7b27f2535b03
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.0

Security for pytwain 2.2.1

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