def save_png(self, filename):
"""Save the diagram to a PNG file.
The widget must be displayed first before the PNG data is available. To
display the widget and save an image at the same time, use
`auto_save_png`.
Parameters
----------
filename : string
"""
if self.png:
data = base64.decodebytes(bytes(self.png, 'ascii'))
with open(filename, 'wb') as f:
f.write(data)
else:
warnings.warn('No png image available! Try auto_save_png() instead?')
评论列表
文章目录