MCPcopy Index your code
hub / github.com/PySimpleGUI/PySimpleGUI / save_element_as_file

Function save_element_as_file

DemoPrograms/Demo_Save_Window_As_Image.py:20–29  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

18"""
19
20def 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
32def main():

Callers 1

mainFunction · 0.70

Calls 1

saveMethod · 0.80

Tested by

no test coverage detected