From 1a8761ea39f26f8dbc933cda2f51cfbab6c0e5a5 Mon Sep 17 00:00:00 2001 From: Holger Frey Date: Tue, 30 Apr 2019 17:31:14 +0200 Subject: [PATCH] linted --- mtor/gui.py | 50 +++++++++++++++++++++-------------------------- mtor/workflows.py | 1 + 2 files changed, 23 insertions(+), 28 deletions(-) diff --git a/mtor/gui.py b/mtor/gui.py index c339530..e60e20a 100644 --- a/mtor/gui.py +++ b/mtor/gui.py @@ -1,22 +1,18 @@ +import sys +import os + from pathlib import Path from subprocess import Popen -home = Path.home() - -import sys -import os from PyQt5.QtWidgets import ( QApplication, - QMainWindow, - QPushButton, QDesktopWidget, - QHBoxLayout, - QVBoxLayout, - QWidget, + QFileDialog, + QGridLayout, QLabel, QLineEdit, - QGridLayout, - QFileDialog, + QPushButton, + QWidget, ) from PyQt5.QtGui import QIcon, QIntValidator @@ -24,7 +20,6 @@ from .workflows import ( prescan_workflow, image_workflow, data_workflow, - cached_data_workflow, postprocessing_workflow, ) @@ -103,18 +98,11 @@ class MtorImageAnalysis(QWidget): grid.addWidget(self.btn_run, 9, 1) self.setLayout(grid) - #self.resize(350, 300) + # self.resize(350, 300) self.center_window_on_desktop() self.setWindowTitle("mTor Image Analysis") self.setWindowIcon(QIcon("web.png")) - # helpers - self.dir_selected.setText("/Users/holgerfrey/Developer/mtor/mtor-bilder") - self.roi_top_input.setText("50") - self.roi_right_input.setText("875") - self.roi_bottom_input.setText("300") - self.roi_left_input.setText("725") - self.show() def center_window_on_desktop(self): @@ -124,7 +112,7 @@ class MtorImageAnalysis(QWidget): self.move(fg.topLeft()) def get_tif_dir(self): - dlg = QFileDialog(directory=str(home)) + dlg = QFileDialog(directory=str(Path.home())) dlg.setFileMode(QFileDialog.Directory) if dlg.exec_(): @@ -139,7 +127,6 @@ class MtorImageAnalysis(QWidget): self.dir_selected.setText(filenames[0]) self.check_button_state() - def check_button_state(self): values = self.get_values() self.btn_run.setEnabled(all(values)) @@ -178,19 +165,26 @@ def run_gui(): app.exec_() if mia.analysis_parameters is not None: - analysis_parameters = tuple( (p for p in mia.analysis_parameters) ) + analysis_parameters = tuple((p for p in mia.analysis_parameters)) pw = prescan_workflow(*analysis_parameters) iw = image_workflow(pw.parameters) dw = data_workflow(iw.data, iw.parameters) fw = postprocessing_workflow(dw.data, dw.parameters) - pdf_path = dw.parameters.data_dir / "report.pdf" + pdf_path = fw.parameters.data_dir / "report.pdf" if sys.platform.startswith("win"): os.startfile(str(pdf_path)) else: if sys.platform.startswith("darwin"): - cmd = ["open", path] + cmd = ["open", str(pdf_path)] else: - cmd = ["xdg-open", path] - Popen(cmd, shell=False, stding=None, stdout=None, stderr=None, close_fds=True) - + cmd = ["xdg-open", str(pdf_path)] + Popen( + cmd, + shell=False, + stding=None, + stdout=None, + stderr=None, + close_fds=True, + ) + sys.exit() diff --git a/mtor/workflows.py b/mtor/workflows.py index fedd86d..e600d20 100644 --- a/mtor/workflows.py +++ b/mtor/workflows.py @@ -85,6 +85,7 @@ def postprocessing_workflow(selected_files, parameters): remove_cuts_dir(parameters) print("5/5: Post processing, annotating color coded images") annotate_color_coded_images(file_stems, parameters) + return WorkflowResult(None, parameters) def cached_data_workflow(folder):