Saves any element as an image file. Element needs to have an underlyiong Widget available (almost if not all of them do) :param element: The element to save :param filename: The filename to save to. The extension of the filename determines the format (jpg, png, gif, ?)
(element, filename)
| 18 | """ |
| 19 | |
| 20 | def save_element_as_file(element, filename): |
| 21 | """ |
| 22 | Saves any element as an image file. Element needs to have an underlyiong Widget available (almost if not all of them do) |
| 23 | :param element: The element to save |
| 24 | :param filename: The filename to save to. The extension of the filename determines the format (jpg, png, gif, ?) |
| 25 | """ |
| 26 | widget = element.Widget |
| 27 | box = (widget.winfo_rootx(), widget.winfo_rooty(), widget.winfo_rootx() + widget.winfo_width(), widget.winfo_rooty() + widget.winfo_height()) |
| 28 | grab = ImageGrab.grab(bbox=box) |
| 29 | grab.save(filename) |
| 30 | |
| 31 | |
| 32 | def main(): |