Commit 5a7815df authored by Yan's avatar Yan
Browse files

DRL table saving works

parent d7531555
......@@ -11,6 +11,7 @@ import matplotlib
import numpy as np
import prasopes.datatools as dt
import prasopes.graphtools as gt
import prasopes.filetools as ft
matplotlib.use("Qt5Agg")
class HBar(QtWidgets.QFrame):
......@@ -246,8 +247,26 @@ def load_drlconfig(ptable, dtable):
ptable.removeRow(row)
def save_drlconfig(ptable, dtable):
print("hello")
def save_drlconfig(ptable, dtable, parent):
"""safe DRL table layout so it can be summoned when needed"""
exp_f_name = ft.get_save_filename(
"Save DRL table layout", "comma-separated values (*.csv)",
"csv", parent)
if exp_f_name is not '':
expf = open(exp_f_name, 'w')
expf.write("#ion_name, start m/z, end m/z, visible,"
"corrected_to, factor\n")
for row in range(ptable.rowCount()):
vals = []
for i in range(3):
vals.append(ptable.cellWidget(row,i).text())
vals.append(dtable.cellWidget(row,1).checkState())
vals.append(dtable.cellWidget(row,2).currentIndex())
vals.append(dtable.cellWidget(row,3).text())
#vals = ",".join(map(str, vals))
expf.write("{}\n".format((",".join(map(str, vals)))))
expf.close()
def dialog(parent, ds, filename, mass_selector, spectrum, cache):
......@@ -302,8 +321,10 @@ def dialog(parent, ds, filename, mass_selector, spectrum, cache):
dial_widget, mass_selector, spectrum, ds, pt, dt, chromplot))
btn_rem.clicked.connect(lambda: remove_rows(pt,dt))
drl_load.clicked.connect(lambda: load_drlconfig(pt, dt))
drl_save.clicked.connect(lambda: save_drlconfig(pt, dt))
dial_widget.finished.connect(lambda: savecache(cache, pt, dt, graph_canvas))
drl_save.clicked.connect(lambda: save_drlconfig(
pt, dt, dial_widget))
dial_widget.finished.connect(lambda: savecache(
cache, pt, dt, graph_canvas))
main_layout = QtWidgets.QVBoxLayout(dial_widget)
sub_layout = QtWidgets.QHBoxLayout()
......
Supports Markdown
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