Commit 85160f63 authored by 3Yan's avatar 3Yan
Browse files

Config now supports floats in copy/print image sizes

parent fa82b41d
......@@ -45,12 +45,13 @@ def pathlineconf(label, value, config):
return layout
def posintvarconf(label, value, config):
def posvarconf(label, value, config, num="int"):
"""adds generic positive integer config line"""
textfield = QtWidgets.QLineEdit(str(config.value(value)))
textfield.editingFinished.connect(lambda: config.setValue(
value, textfield.text()))
validator = QtGui.QIntValidator()
validator = QtGui.QIntValidator() if num == "int"\
else QtGui.QDoubleValidator()
validator.setBottom(0)
textfield.setValidator(validator)
layout = QtWidgets.QHBoxLayout()
......@@ -80,25 +81,25 @@ def dial(parent):
printtab = QtWidgets.QWidget()
printlayout = QtWidgets.QVBoxLayout(printtab)
printlayout.addLayout(posintvarconf(
"Figure width (inch)", "print/xinch", config))
printlayout.addLayout(posintvarconf(
"Figure height (inch)", "print/yinch", config))
printlayout.addLayout(posintvarconf(
printlayout.addLayout(posvarconf(
"Figure width (inch)", "print/xinch", config, "nonint"))
printlayout.addLayout(posvarconf(
"Figure height (inch)", "print/yinch", config, "nonint"))
printlayout.addLayout(posvarconf(
"Figure dpi", "print/dpi", config))
printlayout.addLayout(posintvarconf(
printlayout.addLayout(posvarconf(
"Figure x axis major ticks count", "print/xtics", config))
tabs.addTab(printtab, "Printing")
imggentab = QtWidgets.QWidget()
imggenlayout = QtWidgets.QVBoxLayout(imggentab)
imggenlayout.addLayout(posintvarconf(
"Figure width (inch)", "imggen/xinch", config))
imggenlayout.addLayout(posintvarconf(
"Figure height (inch)", "imggen/yinch", config))
imggenlayout.addLayout(posintvarconf(
imggenlayout.addLayout(posvarconf(
"Figure width (inch)", "imggen/xinch", config, "nonint"))
imggenlayout.addLayout(posvarconf(
"Figure height (inch)", "imggen/yinch", config, "nonint"))
imggenlayout.addLayout(posvarconf(
"Figure dpi", "imggen/dpi", config))
imggenlayout.addLayout(posintvarconf(
imggenlayout.addLayout(posvarconf(
"Figure x axis major ticks count", "imggen/xtics", config))
tabs.addTab(imggentab, "Image clip/export")
......
......@@ -13,12 +13,12 @@ import prasopes.config as cf
def paint_image(mass_spec, spect, fn=None, painttarget=None):
"""generates QImage from mass spectrum"""
if isinstance(painttarget, type(QtPrintSupport.QPrinter())):
xinch, yinch, dpi, xtics = [cf.settings().value("print/{}".format(i),
type=int) for i in ("xinch", "yinch", "dpi", "xtics")]
else:
xinch, yinch, dpi, xtics = [cf.settings().value("imggen/{}".format(i),
type=int) for i in ("xinch", "yinch", "dpi", "xtics")]
configtype = "print/{}" if isinstance(
painttarget, type(QtPrintSupport.QPrinter())) else "imggen/{}"
xinch, yinch = [float(cf.settings().value(configtype.format(i)).replace(",",".")) for i
in ("xinch", "yinch")]
dpi, xtics = [int(cf.settings().value(configtype.format(i))) for i
in ("dpi", "xtics")]
paintfig = Figure(figsize=(xinch, yinch), dpi=dpi, constrained_layout=True)
canvas = FigureCanvas(paintfig)
printplot = paintfig.add_subplot(111)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment