Skip to main content

Grabs screenshot of a tkinter window

Project description

   __      __
  /  |    /  |
 _$$ |_   $$ |   __   _______   ______    ______
/ $$   |  $$ |  /  | /       | /      \  /      \
$$$$$$/   $$ |_/$$/ /$$$$$$$/  $$$$$$  |/$$$$$$  |
  $$ | __ $$   $$<  $$ |       /    $$ |$$ |  $$ |
  $$ |/  |$$$$$$  \ $$ \_____ /$$$$$$$ |$$ |__$$ |
  $$  $$/ $$ | $$  |$$       |$$    $$ |$$    $$/
   $$$$/  $$/   $$/  $$$$$$$/  $$$$$$$/ $$$$$$$/
                                        $$ |
                                        $$ |
                                        $$/

Welcome to my Github page! I am happy to present to you my personal project, tkcap. This is a Python script that lets you take screenshots of a Tkinter window.

Tkinter is a popular GUI toolkit for Python, and it's often used to develop desktop applications. Sometimes, you may need to take a screenshot of a Tkinter window for documentation or debugging purposes. This is where tkcap comes in handy. With just a few lines of code, you can capture a screenshot of your Tkinter window and save it as an image file.

tkcap is easy to use, and the script is designed to be lightweight and efficient. You simply import the tkcap module, create an instance of the CAP class, and call the capture method to take a screenshot. The captured screenshot can be saved in various image formats, including PNG, JPEG, and BMP.

I have thoroughly tested tkcap on different operating systems and with different versions of Python, and I am confident that it will work seamlessly for you. If you encounter any issues or have suggestions for improvement, please don't hesitate to open an issue on Github or reach out to me directly.

I hope that tkcap can be a useful tool for your Tkinter projects, and I look forward to hearing your feedback. Happy coding!

Ghanteyyy http://github.com/ghanteyyy MIT License

Requirements and Tested Platforms

  • Python:

    • 3.x
  • Windows:

    • Windows 10 & 11

Installation

tkcap is available on PyPI. You can install it through pip:

pip install tkcap

Usage

  import tkcap

  cap = tkcap.CAP(master)  # 'master' is a tkinter window instance, passed to create a capture object
  cap.capture(FileName)    # Captures a screenshot of the tkinter window and saves it as provided FileName

  # To retrieve the x, y coordinates, width, and height of the tkinter window
  region = cap.get_region()

  # Bind a key (in this case, 'Control + g') to trigger a screenshot capture when pressed
  # Each time 'Control + g' is pressed, the screenshot will be saved as provided FileName
  master.bind('<Control-g>', lambda: cap.capture(FileName))

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tkcap-0.0.4.tar.gz (4.6 kB view details)

Uploaded Source

File details

Details for the file tkcap-0.0.4.tar.gz.

File metadata

  • Download URL: tkcap-0.0.4.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.6

File hashes

Hashes for tkcap-0.0.4.tar.gz
Algorithm Hash digest
SHA256 165e04828c143536077dfc120d44e10ed2d1f100b5b971b3469cb8eab4f570db
MD5 fdd9044a64897a889126f70b48a7e5dd
BLAKE2b-256 6ead1c695117e831f7b6803b9d18ff5ed21d42295866a0d96e7e2bf9389d6457

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page