Commit 813f6770 authored by Yan's avatar Yan
Browse files

Added print support for DRL

parent ad40b1ee
#!/usr/bin/env python3
from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas
from matplotlib.figure import Figure
from matplotlib.widgets import SpanSelector
from PyQt5 import QtCore
from PyQt5 import QtWidgets
from PyQt5 import QtGui
from PyQt5 import QtPrintSupport
import sys
import matplotlib
import numpy as np
......@@ -93,8 +93,6 @@ def update_drlspectrum(ptable, dtable, ds, drlspectrum):
count = 0
for row in range(dtable.rowCount()):
#print(row)
print(count)
if dtable.cellWidget(row, 1).checkState() ==2:
dtable.item(row,0).setBackground(QtGui.QBrush(
QtGui.QColor(*colors[count%len(colors)], alpha=50)))
......@@ -345,6 +343,27 @@ def export_drlspectrum(parent, fn, ptable, dtable, ds):
expf.close()
def print_graph(labels, ptable, dtable, ds):
printfig = Figure(figsize=(5,2), dpi=100)
printplot = printfig.add_subplot(111)
printcanvas = FigureCanvas(printfig)
gt.pop_plot(printplot, labels)
update_drlspectrum(ptable, dtable, ds, printplot)
widget = QtWidgets.QDialog(None,
windowTitle='Print preview')
layout = QtWidgets.QVBoxLayout(widget)
layout.addWidget(printcanvas)
widget.resize(600,400)
widget.show()
dialog = QtPrintSupport.QPrintDialog()
if dialog.exec_() == QtWidgets.QDialog.Accepted:
#dialog.printer().setFullPage(False)
#printcanvas.render(dialog.printer())
#graph.canvas.render(dialog.printer())
printcanvas.render(dialog.printer())
widget.close()
def main_window(parent, ds, filename, cache):
"""constructs a dialog window"""
def saveonclose(window, event, cache,pt,dt,canvas):
......@@ -374,6 +393,7 @@ def main_window(parent, ds, filename, cache):
drl_load = QtWidgets.QPushButton("&Load")
drl_save = QtWidgets.QPushButton("&Save")
drl_export = QtWidgets.QPushButton("&Export")
drl_print = QtWidgets.QPushButton("&Print")
close = QtWidgets.QPushButton("&Close")
close.clicked.connect(dial_widget.close)
......@@ -403,6 +423,8 @@ def main_window(parent, ds, filename, cache):
dial_widget, pt, dt, ds, chromplot))
drl_save.clicked.connect(lambda: save_drlconfig(
pt, dt, dial_widget))
drl_print.clicked.connect(lambda: print_graph(
graphlabels, pt, dt, ds))
drl_export.clicked.connect(lambda: export_drlspectrum(
dial_widget, filename, pt, dt, ds))
......@@ -425,6 +447,7 @@ def main_window(parent, ds, filename, cache):
main_butlayout.addWidget(drl_save)
main_butlayout.addStretch(1)
main_butlayout.addWidget(drl_export)
main_butlayout.addWidget(drl_print)
main_butlayout.addWidget(close)
sub_layout.addWidget(graph_canvas, stretch=1)
......
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