Commit 91ce38cc authored by Yan's avatar Yan
Browse files

Printing support for main window spectrum Pt1

* Experimental printing support
* Added script to generate icon python resource
parent c0580d1f
......@@ -7,9 +7,11 @@ from matplotlib.gridspec import GridSpec
from PyQt5 import QtCore
from PyQt5 import QtWidgets
from PyQt5 import QtGui
from PyQt5 import QtPrintSupport
from rawprasslib import load_raw
from rawprasslib import rawprasslib
from prasopes.predictmz import predict as getmzpattern
from io import BytesIO
import prasopes.graphtools as gt
import prasopes.filetools as ft
import prasopes.zcetools as zce
......@@ -57,6 +59,28 @@ def load_file(parent, chrom_plot, spc, d_set, ms_s, fn, chrom_s,
update.signal.emit()
def print_graph(mass_spec, chrom_spec, spect, fn):
printfig = Figure(figsize=(10, 4), dpi=300)
printplot = printfig.add_subplot(111)
if cf.settings().value("view/oddeven",type=bool):
print("TODO")
else:
gt.pop_plot(printplot, mass_spec)
printPreview = QtPrintSupport.QPrintPreviewDialog()
printer = printPreview.printer()
def ubercommand():
cache_file = BytesIO()
printfig.savefig(cache_file)
cache_file.seek(0)
image = QtGui.QImage.fromData(cache_file.read())
printer.setResolution(600)
painter = QtGui.QPainter(printPreview.printer())
painter.drawImage(QtCore.QPoint(0,0), image)
painter.end()
printPreview.paintRequested.connect(lambda: ubercommand())
printPreview.exec()
def update_spectrum(condition, chromatogram, spect, ds,
ms, fn, chrom, config):
if fn[0] is not None and condition:
......@@ -170,6 +194,10 @@ def main():
exportact.setShortcut(QtCore.Qt.CTRL + QtCore.Qt.Key_E)
exportact.triggered.connect(lambda: ft.export_dial(
ms, chrom, filename, main_window))
printact = QtWidgets.QAction(QtGui.QIcon.fromTheme(
"document-print"), "&Print", None)
printact.setShortcut(QtCore.Qt.CTRL + QtCore.Qt.Key_P)
printact.triggered.connect(lambda: print_graph(ms, chrom, spectrum, filename))
settingsact = QtWidgets.QAction(QtGui.QIcon.fromTheme(
"preferences-system"), "&Settings...", None)
settingsact.triggered.connect(lambda: cf.dial(main_window))
......@@ -227,6 +255,8 @@ def main():
file_menu.addAction(openact)
file_menu.addAction(exportact)
file_menu.addSeparator()
file_menu.addAction(printact)
file_menu.addSeparator()
file_menu.addAction(settingsact)
file_menu.addSeparator()
file_menu.addAction(quitact)
......
#!/bin/bash
#Script for adding new icons
#modify the tangoicons.qrc file first, then run this script
#the script presumes that it is being run in the folder where it is located
pyrcc5 tangoicons.qrc > tangoicons.py
This diff is collapsed.
......@@ -15,6 +15,9 @@
<file alias="16x16/zoom-original.png">TangoMFK/16x16/zoom-original.png</file>
<file alias="24x24/zoom-original.png">TangoMFK/24x24/zoom-original.png</file>
<file alias="32x32/zoom-original.png">TangoMFK/32x32/zoom-original.png</file>
<file alias="16x16/document-open.png">TangoMFK/16x16/document-open.png</file>
<file alias="24x24/document-open.png">TangoMFK/24x24/document-open.png</file>
<file alias="32x32/document-open.png">TangoMFK/32x32/document-open.png</file>
<file alias="index.theme">TangoMFK/index.theme</file>
</qresource>
</RCC>
......
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