Screenshot of tkinter python working window

Question:

How do I take a screenshot of the workspace that was generated using the tkinter library?

Answer:

pip3 install pyscreenshot

from pyscreenshot import grab

im = grab(bbox=(100, 200, 300, 400))
im.show()

pip3 install pillow

from PIL import ImageGrab
snapshot = ImageGrab.grab()
save_path = "your/save/path"
snapshot.save(save_path)

pip3 install pyautogui

import pyautogui
screenshot = pyautogui.screenshot('path/to/file.png')
Scroll to Top