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

Little Clean-Up, redone DRL table construction

created function for construction of the tables.
parent b14b0a3a
......@@ -103,5 +103,6 @@ def main():
main_window.show()
sys.exit(app.exec_())
if __name__ == "__main__":
main()
......@@ -12,13 +12,38 @@ matplotlib.use("Qt5Agg")
class HBar(QtWidgets.QFrame):
"""horizontal bar class"""
def __init__(self):
super(HBar, self).__init__()
self._main = QtWidgets.QWidget()
self.setFrameShape(QtWidgets.QFrame.HLine)
def iontable(labels, exp_col):
"""creates a table for ions"""
table = QtWidgets.QTableWidget(columnCount=len(labels))
table.setSizePolicy(QtWidgets.QSizePolicy.Fixed,
QtWidgets.QSizePolicy.Expanding)
table.setHorizontalHeaderLabels(labels)
tx = table.verticalHeader().width() \
+ table.verticalScrollBar().height()
for n in range(len(labels)):
tx = tx + table.columnWidth(n)
table.setMinimumSize(tx, 0)
table.horizontalHeader().setSectionResizeMode(
exp_col, QtWidgets.QHeaderView.Stretch)
table.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn)
table_add = QtWidgets.QPushButton("Add")
table_rem = QtWidgets.QPushButton("Remove")
table_butlayout = QtWidgets.QHBoxLayout()
table_butlayout.addWidget(table_add)
table_butlayout.addWidget(table_rem)
table_butlayout.addStretch(0)
return table, table_butlayout, table_add, table_rem
def dialog(parent, ds, filename):
"""constructs a dialog window"""
dial_widget = QtWidgets.QDialog(
parent, windowTitle='Delayed reactant labelling')
......@@ -28,79 +53,45 @@ def dialog(parent, ds, filename):
graph_canvas.setStyleSheet("background-color:transparent;")
graph_canvas.setAutoFillBackground(False)
drl_load = QtWidgets.QPushButton("Load")
drl_save = QtWidgets.QPushButton("Save")
drl_export = QtWidgets.QPushButton("Export")
close = QtWidgets.QPushButton("Close")
close.clicked.connect(dial_widget.close)
# pt = parenttable
pt, pt_butlayout, pt_add, pt_rem = iontable(
["Name", "start (m/z)", "end (m/z)", "profile"], 2)
# dt = daughtertable
dt, dt_butlayout, dt_add, dt_rem = iontable(
["Name", "start (m/z)", "end (m/z)", "corr to"], 2)
add_corr = QtWidgets.QPushButton("Add correction")
dt_butlayout.addWidget(add_corr)
main_layout = QtWidgets.QVBoxLayout(dial_widget)
sub_layout = QtWidgets.QHBoxLayout()
main_layout.addLayout(sub_layout)
main_layout.addWidget(HBar())
tablelayout = QtWidgets.QVBoxLayout()
main_butlayout = QtWidgets.QHBoxLayout()
drl_load = QtWidgets.QPushButton("Load")
drl_save = QtWidgets.QPushButton("Save")
drl_export = QtWidgets.QPushButton("Export")
cancel = QtWidgets.QPushButton("Cancel")
main_layout.addLayout(sub_layout)
main_layout.addWidget(HBar())
main_layout.addLayout(main_butlayout)
main_butlayout.addWidget(drl_load)
main_butlayout.addWidget(drl_save)
main_butlayout.addStretch(1)
main_butlayout.addWidget(drl_export)
main_butlayout.addWidget(cancel)
# pt = parenttable
pt = QtWidgets.QTableWidget(columnCount=3)
pt.setSizePolicy(QtWidgets.QSizePolicy.Fixed,
QtWidgets.QSizePolicy.Expanding)
pt.setRowCount(5)
pt.setHorizontalHeaderLabels(
["Name", "start (m/z)", "end (m/z)", "intensity"])
ptx = pt.verticalHeader().width() + pt.verticalScrollBar().height()
for n in range(pt.columnCount()):
ptx = ptx + pt.columnWidth(n)
pt.setMinimumSize(ptx, 0)
pt.horizontalHeader().setSectionResizeMode(2, QtWidgets.QHeaderView.Stretch)
pt.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn)
pt_butlayout = QtWidgets.QHBoxLayout()
pt_add = QtWidgets.QPushButton("Add")
pt_rem = QtWidgets.QPushButton("Remove")
# dt = daughtertable
dt = QtWidgets.QTableWidget(columnCount=4)
dt.setSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Expanding)
dt.setRowCount(3)
dt.setHorizontalHeaderLabels(
["Name", "start (m/z)", "end (m/z)", "corr to"])
dtx = pt.verticalHeader().width() + pt.verticalScrollBar().height()
for n in range(dt.columnCount()):
dtx = dtx + dt.columnWidth(n)
dt.setMinimumSize(dtx, 0)
dt.horizontalHeader().setSectionResizeMode(
dt.columnCount()-1, QtWidgets.QHeaderView.Stretch)
dt.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn)
dt_butlayout = QtWidgets.QHBoxLayout()
dt_add = QtWidgets.QPushButton("Add")
dt_rem = QtWidgets.QPushButton("Remove")
add_corr_widget = QtWidgets.QDialog(dial_widget)
add_corr = QtWidgets.QPushButton("Add correction")
add_corr.clicked.connect(add_corr_widget.show)
main_butlayout.addWidget(close)
sub_layout.addWidget(graph_canvas)
sub_layout.addWidget(graph_canvas, stretch=1)
sub_layout.addLayout(tablelayout)
tablelayout.addWidget(QtWidgets.QLabel("Raw ions table:"))
tablelayout.addWidget(pt)
tablelayout.addLayout(pt_butlayout)
pt_butlayout.addWidget(pt_add)
pt_butlayout.addWidget(pt_rem)
pt_butlayout.addStretch(1)
tablelayout.addWidget(HBar())
tablelayout.addWidget(QtWidgets.QLabel("Corrected ions table:"))
tablelayout.addWidget(dt)
tablelayout.addLayout(dt_butlayout)
dt_butlayout.addWidget(dt_add)
dt_butlayout.addWidget(dt_rem)
dt_butlayout.addStretch(1)
dt_butlayout.addWidget(add_corr)
dial_widget.show()
from PyQt5 import QtCore
from PyQt5 import QtWidgets
from rawprasslib import load_raw
import os.path
......
......@@ -225,4 +225,3 @@ def populate(mpl_chromatogram, mpl_spectrum, data_set,
chrom_spect['t_end'] = data_set['chrom_dat'][0, -1]
pop_plot(mpl_chromatogram, chrom_spect)
mpl_chromatogram.figure.canvas.draw()
......@@ -95,7 +95,7 @@ def exp_zce(zce_spec, zcegrad_spec, fn, parent):
def help_msg(pw):
path = pkg_resources.resource_filename(__name__,'zcetools_help')
path = pkg_resources.resource_filename(__name__, 'zcetools_help')
with open(path, 'r') as helpfile:
helpcontent = helpfile.read()
QtWidgets.QMessageBox.information(
......@@ -145,4 +145,3 @@ def dialog(parent, ds, filename):
dial_layout.addLayout(butt_layout)
pop_dial(coffspect, coffspect_grad, ds, dial_widget, coff, coffgrad,
textfield, filename, parent)
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