replaced exception with warning if maximum number of colors is reached; fixes T250

This commit is contained in:
Dominik Demuth 2023-01-05 17:23:30 +01:00
parent 04eb83a19d
commit bfe28f127d
2 changed files with 8 additions and 5 deletions

View File

@ -520,14 +520,16 @@ class QGraphWindow(QtWidgets.QGraphicsView, Ui_GraphWindow):
elif other_item in self.graphic.items():
self.legend.addItem(other_item, convert(other_item.opts.get('name', ''), old='tex', new='html'))
def export_dialog(self):
def export_dialog(self, path=None):
filters = 'All files (*.*);;AGR (*.agr);;SVG (*.svg);;PDF (*.pdf)'
for imgformat in QtGui.QImageWriter.supportedImageFormats():
str_format = imgformat.data().decode('utf-8')
filters += ';;' + str_format.upper() + ' (*.' + str_format + ')'
if path is None:
path = ''
outfile = None
f = FileDialog(caption='Export graphic', filters=filters)
f = FileDialog(caption='Export graphic', directory=str(path), filter=filters)
mode = f.exec()
if mode == QtWidgets.QDialog.Accepted:
outfile = f.save_file()

View File

@ -2,6 +2,7 @@ from __future__ import annotations
import pathlib
import re
import warnings
from io import StringIO
from typing import Optional, Tuple
@ -216,9 +217,9 @@ class GraceEditor:
elif pos == 'in_colors':
# landing here for first mismatch after all colors
if cnt == 64:
raise ValueError('Maximum numbers of color reached, no new color created')
elif idx is None:
if idx is None:
if cnt >= 64:
warnings.warn('Maximum numbers of color reached, color is not used by xmgrace')
self.header.insert(i, f'@map color {cnt} to {rgb}, "{name}"\n')
return cnt
else: