ARTICLE AD BOX
Is there a more accurate way to screenshot like a specific tkinter widget besides just calculating their coordinates, because it sometimes screenshots outside the window itself.
Heres my code:
def screenshotWidget(widgetID, root): """ Grabs the widgets locating and size, then screenshots it. """ date = datetime.datetime.now() time = date.strftime("%Y%m%d%H%M%S") root.update_idletasks() root.update() x0 = widgetID.winfo_rootx() y0 = widgetID.winfo_rooty() x1 = x0 + widgetID.winfo_width() y1 = y0 + widgetID.winfo_height() Img = ImageGrab.grab(bbox=(x0, y0, x1, y1)) Img.save(f"screenshots/screenshot{time}.png") Img.show()