def save_screenshot(self, filename, diagram=None):
"""
Take a screenshot containing only this diagram. The file type is inferred from the filename extension,
valid options are BMP, EMF, EWMF, JPG, PDF, PNG, SVG, WMF.
:param str filename: The filename under which the screenshot will be saved on the instrument.
:param Diagram diagram: The diagram to be captured. The whole screen will be captured if None.
:return: a File object representing the captured screenshot
:rtype: File
"""
_, filetype = ntpath.splitext(filename)
filetype = filetype[1:].upper()
if filetype not in self.HCOPy.DEVice.LANGuage.args:
raise ValueError("Invalid file extension for screenshot: " + filetype)
self.MMEMory.NAME().w(filename) # Define the filename
self.HCOPy.DESTination().w("MMEM") # Print to mass storage
self.HCOPy.DEVice.LANGuage().w(filetype) # Define the file type
if diagram is not None:
diagram.select_diagram()
self.HCOPy.PAGE.WINDow().w("ACTive") # Print only the active diagram
else:
self.HCOPy.PAGE.WINDow().w("HARDcopy")
self.HCOPy.IMMediate().w() # Perform the screen capture
return self.filesystem.file(filename)
评论列表
文章目录