I created a class extended from QWebEngineView and declared a modeBar configuration as following code:
class Canvas(QWebEngineView):
def __init__(self, parent: QFrame = None):
super(QWebEngineView, self).__init__()
dir = Path(environ['USERPROFILE']) / 'Desktop'
self.mode_bar_config = {
'toImageButtonOptions': {
'format': 'jpeg', # one of png, svg, jpeg, webp
'filename': (dir / ('test_img_' +
datetime.now().strftime('%Y%m%d%H%M%S')))
.as_posix(),
'height': 400,
'width': 650,
'scale': 1,
'modeBarButtonsToRemove': ['toggleSpikelines']
}
}
self.parent = parent
self.update_canvas()
def update_canvas(self, list_of_data: list = None):
try:
if list_of_data is None:
list_of_data = []
self.fig1 = FftFigure('Time domain',
x_title='sample points',
y_title='dbm')
if len(list_of_data) > 0:
x = [index for index in range(len(list_of_data))]
self.fig1.update_data(x, y_data=list_of_data)
html = '<html><head><meta charset="utf-8" />'
html += '<script src="https://cdn.plot.ly/plotly-latest.min.js"></script></head>'
html += '<body style="width:650px;height:700px;">'
html += offline.plot(self.fig1, output_type='div',
include_plotlyjs=False,
config=self.mode_bar_config)
html += '</body></html>'
self.setHtml(html)
layout = QVBoxLayout()
layout.addWidget(self)
self.parent.setLayout(layout)
if len(list_of_data) > 0:
self.render(self)
except Exception as e:
print_exc()
but this is not work when i clicked the download plot icon, i canβt find the saved image on my Desktop
How can i resolve the problem.