replaced exception with warning if maximum number of colors is reached; fixes T250
This commit is contained in:
parent
04eb83a19d
commit
bfe28f127d
@ -520,14 +520,16 @@ class QGraphWindow(QtWidgets.QGraphicsView, Ui_GraphWindow):
|
|||||||
elif other_item in self.graphic.items():
|
elif other_item in self.graphic.items():
|
||||||
self.legend.addItem(other_item, convert(other_item.opts.get('name', ''), old='tex', new='html'))
|
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)'
|
filters = 'All files (*.*);;AGR (*.agr);;SVG (*.svg);;PDF (*.pdf)'
|
||||||
for imgformat in QtGui.QImageWriter.supportedImageFormats():
|
for imgformat in QtGui.QImageWriter.supportedImageFormats():
|
||||||
str_format = imgformat.data().decode('utf-8')
|
str_format = imgformat.data().decode('utf-8')
|
||||||
filters += ';;' + str_format.upper() + ' (*.' + str_format + ')'
|
filters += ';;' + str_format.upper() + ' (*.' + str_format + ')'
|
||||||
|
|
||||||
|
if path is None:
|
||||||
|
path = ''
|
||||||
outfile = None
|
outfile = None
|
||||||
f = FileDialog(caption='Export graphic', filters=filters)
|
f = FileDialog(caption='Export graphic', directory=str(path), filter=filters)
|
||||||
mode = f.exec()
|
mode = f.exec()
|
||||||
if mode == QtWidgets.QDialog.Accepted:
|
if mode == QtWidgets.QDialog.Accepted:
|
||||||
outfile = f.save_file()
|
outfile = f.save_file()
|
||||||
|
@ -2,6 +2,7 @@ from __future__ import annotations
|
|||||||
|
|
||||||
import pathlib
|
import pathlib
|
||||||
import re
|
import re
|
||||||
|
import warnings
|
||||||
from io import StringIO
|
from io import StringIO
|
||||||
from typing import Optional, Tuple
|
from typing import Optional, Tuple
|
||||||
|
|
||||||
@ -216,9 +217,9 @@ class GraceEditor:
|
|||||||
|
|
||||||
elif pos == 'in_colors':
|
elif pos == 'in_colors':
|
||||||
# landing here for first mismatch after all colors
|
# landing here for first mismatch after all colors
|
||||||
if cnt == 64:
|
if idx is None:
|
||||||
raise ValueError('Maximum numbers of color reached, no new color created')
|
if cnt >= 64:
|
||||||
elif idx is None:
|
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')
|
self.header.insert(i, f'@map color {cnt} to {rgb}, "{name}"\n')
|
||||||
return cnt
|
return cnt
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user