handle graph export with empty data (#239); closes #233
All checks were successful
Build AppImage / Explore-Gitea-Actions (push) Successful in 1m45s
All checks were successful
Build AppImage / Explore-Gitea-Actions (push) Successful in 1m45s
Co-authored-by: Dominik Demuth <dominik.demuth@physik.tu-darmstadt.de> Reviewed-on: #239
This commit is contained in:
@ -670,11 +670,14 @@ class QGraphWindow(QtWidgets.QGraphicsView, Ui_GraphWindow):
|
||||
|
||||
else:
|
||||
if os.path.exists(outfile):
|
||||
if QtWidgets.QMessageBox.warning(self, 'Export graphic',
|
||||
f'{os.path.split(outfile)[1]} already exists.\n'
|
||||
f'Do you REALLY want to replace it?',
|
||||
QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No,
|
||||
QtWidgets.QMessageBox.No) == QtWidgets.QMessageBox.No:
|
||||
if QtWidgets.QMessageBox.warning(
|
||||
self,
|
||||
'Export graphic',
|
||||
f'{os.path.split(outfile)[1]} already exists.\n'
|
||||
f'Do you REALLY want to replace it?',
|
||||
QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No,
|
||||
QtWidgets.QMessageBox.No
|
||||
) == QtWidgets.QMessageBox.No:
|
||||
return
|
||||
|
||||
bg_color = self._bgcolor
|
||||
@ -716,16 +719,20 @@ class QGraphWindow(QtWidgets.QGraphicsView, Ui_GraphWindow):
|
||||
logger.exception(f'{item} could not exported because {e.args}')
|
||||
continue
|
||||
|
||||
if len(item) == 2:
|
||||
# plot can show errorbars
|
||||
item_dic['yerr'] = item[1].opts['topData']
|
||||
|
||||
if item_dic:
|
||||
if len(item) == 2:
|
||||
# plot can show errorbars
|
||||
if len(item_dic['x']):
|
||||
item_dic['yerr'] = item[1].opts['topData']
|
||||
else:
|
||||
item_dic['yerr'] = []
|
||||
dic['items'].append(item_dic)
|
||||
|
||||
for item in self._external_items:
|
||||
try:
|
||||
dic['items'].append(item.get_data_opts())
|
||||
item_dic = item.get_data_opts()
|
||||
if item_dic:
|
||||
dic['items'].append(item_dic)
|
||||
except Exception as e:
|
||||
logger.exception(f'{item} could not be exported because {e.args}')
|
||||
continue
|
||||
|
Reference in New Issue
Block a user