1
0
Fork 0
mirror of https://github.com/Athemis/PyDSF.git synced 2025-04-05 14:46:03 +00:00

Coding style; Overhaul of GUI

This commit is contained in:
Alexander Minges 2015-07-08 01:04:34 +02:00
parent 07d44ba86e
commit 35b2920d34
3 changed files with 71 additions and 108 deletions

View file

@ -2,8 +2,7 @@
# Form implementation generated from reading ui file 'mainwindow.ui' # Form implementation generated from reading ui file 'mainwindow.ui'
# #
# Created: Sat Jan 31 19:20:48 2015 # Created by: PyQt5 UI code generator 5.4.2
# by: PyQt5 UI code generator 5.4
# #
# WARNING! All changes made in this file will be lost! # WARNING! All changes made in this file will be lost!
@ -21,8 +20,9 @@ class Ui_MainWindow(object):
self.horizontalLayout.setObjectName("horizontalLayout") self.horizontalLayout.setObjectName("horizontalLayout")
self.splitter = QtWidgets.QSplitter(self.centralWidget) self.splitter = QtWidgets.QSplitter(self.centralWidget)
self.splitter.setOrientation(QtCore.Qt.Horizontal) self.splitter.setOrientation(QtCore.Qt.Horizontal)
self.splitter.setOpaqueResize(False)
self.splitter.setHandleWidth(2) self.splitter.setHandleWidth(2)
self.splitter.setChildrenCollapsible(True) self.splitter.setChildrenCollapsible(False)
self.splitter.setObjectName("splitter") self.splitter.setObjectName("splitter")
self.groupBox_experiment = QtWidgets.QGroupBox(self.splitter) self.groupBox_experiment = QtWidgets.QGroupBox(self.splitter)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred)
@ -195,26 +195,14 @@ class Ui_MainWindow(object):
self.buttonBox_process.setObjectName("buttonBox_process") self.buttonBox_process.setObjectName("buttonBox_process")
self.formLayout_3.setWidget(3, QtWidgets.QFormLayout.FieldRole, self.buttonBox_process) self.formLayout_3.setWidget(3, QtWidgets.QFormLayout.FieldRole, self.buttonBox_process)
self.tabWidget = QtWidgets.QTabWidget(self.splitter) self.tabWidget = QtWidgets.QTabWidget(self.splitter)
self.tabWidget.setEnabled(True)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred)
sizePolicy.setHorizontalStretch(0) sizePolicy.setHorizontalStretch(6)
sizePolicy.setVerticalStretch(0) sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.tabWidget.sizePolicy().hasHeightForWidth()) sizePolicy.setHeightForWidth(self.tabWidget.sizePolicy().hasHeightForWidth())
self.tabWidget.setSizePolicy(sizePolicy) self.tabWidget.setSizePolicy(sizePolicy)
self.tabWidget.setMinimumSize(QtCore.QSize(300, 300)) self.tabWidget.setMinimumSize(QtCore.QSize(300, 300))
self.tabWidget.setObjectName("tabWidget") self.tabWidget.setObjectName("tabWidget")
#self.tab_raw = MplWidget()
#self.tab_raw.setObjectName("tab_raw")
#self.tabWidget.addTab(self.tab_raw, "")
#self.tab_derivative = MplWidget()
#self.tab_derivative.setObjectName("tab_derivative")
#self.tabWidget.addTab(self.tab_derivative, "")
#self.tab_heatmap = MplWidget()
#self.tab_heatmap.setObjectName("tab_heatmap")
#self.tabWidget.addTab(self.tab_heatmap, "")
#self.tab_heatmap_avg = MplWidget()
#self.tab_heatmap_avg.setEnabled(False)
#self.tab_heatmap_avg.setObjectName("tab_heatmap_avg")
#self.tabWidget.addTab(self.tab_heatmap_avg, "")
self.horizontalLayout.addWidget(self.splitter) self.horizontalLayout.addWidget(self.splitter)
MainWindow.setCentralWidget(self.centralWidget) MainWindow.setCentralWidget(self.centralWidget)
self.menuBar = QtWidgets.QMenuBar(MainWindow) self.menuBar = QtWidgets.QMenuBar(MainWindow)
@ -255,7 +243,7 @@ class Ui_MainWindow(object):
self.label_cbar_end.setBuddy(self.doubleSpinBox_cbar_end) self.label_cbar_end.setBuddy(self.doubleSpinBox_cbar_end)
self.retranslateUi(MainWindow) self.retranslateUi(MainWindow)
self.tabWidget.setCurrentIndex(0) self.tabWidget.setCurrentIndex(-1)
QtCore.QMetaObject.connectSlotsByName(MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow): def retranslateUi(self, MainWindow):
@ -291,14 +279,9 @@ class Ui_MainWindow(object):
self.doubleSpinBox_cbar_start.setSuffix(_translate("MainWindow", " °C")) self.doubleSpinBox_cbar_start.setSuffix(_translate("MainWindow", " °C"))
self.label_cbar_end.setText(_translate("MainWindow", "En&d")) self.label_cbar_end.setText(_translate("MainWindow", "En&d"))
self.doubleSpinBox_cbar_end.setSuffix(_translate("MainWindow", " °C")) self.doubleSpinBox_cbar_end.setSuffix(_translate("MainWindow", " °C"))
#self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_raw), _translate("MainWindow", "Raw Data"))
#self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_derivative), _translate("MainWindow", "&2nd derivative"))
#self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_heatmap), _translate("MainWindow", "Heatmap"))
#self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_heatmap_avg), _translate("MainWindow", "Heatmap average"))
self.menuFile.setTitle(_translate("MainWindow", "Fi&le")) self.menuFile.setTitle(_translate("MainWindow", "Fi&le"))
self.menuHelp.setTitle(_translate("MainWindow", "Hel&p")) self.menuHelp.setTitle(_translate("MainWindow", "Hel&p"))
self.actionQuit.setText(_translate("MainWindow", "&Quit")) self.actionQuit.setText(_translate("MainWindow", "&Quit"))
self.actionAbout.setText(_translate("MainWindow", "&About")) self.actionAbout.setText(_translate("MainWindow", "&About"))
self.actionAbout_Qt.setText(_translate("MainWindow", "About &Qt")) self.actionAbout_Qt.setText(_translate("MainWindow", "About &Qt"))
from .mplwidget import MplWidget

View file

@ -1,19 +1,11 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
""" """
Module implementing MainWindow. Module implementing MainWindow.
""" """
from PyQt5.QtCore import (pyqtSlot, from PyQt5.QtCore import (pyqtSlot, QObject, pyqtSignal, QThreadPool,
QObject, QRunnable, )
pyqtSignal, from PyQt5.QtWidgets import (QMainWindow, QProgressBar, QDialogButtonBox,
QThreadPool, QFileDialog, QMessageBox, QApplication)
QRunnable,)
from PyQt5.QtWidgets import (QMainWindow,
QProgressBar,
QDialogButtonBox,
QFileDialog,
QMessageBox,
QApplication)
from .Ui_mainwindow import Ui_MainWindow from .Ui_mainwindow import Ui_MainWindow
from .mplwidget import MplWidget from .mplwidget import MplWidget
@ -46,21 +38,29 @@ class Worker(QRunnable):
c_lower = self.owner.doubleSpinBox_lower.value() c_lower = self.owner.doubleSpinBox_lower.value()
c_upper = self.owner.doubleSpinBox_upper.value() c_upper = self.owner.doubleSpinBox_upper.value()
if self.owner.groupBox_cbar.isChecked(): if self.owner.groupBox_cbar.isChecked():
cbar_range = (self.owner.doubleSpinBox_cbar_start, self.owner.doubleSpinBox_cbar_end) cbar_range = (self.owner.doubleSpinBox_cbar_start,
self.owner.doubleSpinBox_cbar_end)
if self.owner.groupBox_signal_threshold.isChecked(): if self.owner.groupBox_signal_threshold.isChecked():
signal_threshold = self.owner.spinBox_signal_threshold.value() signal_threshold = self.owner.spinBox_signal_threshold.value()
items = (self.owner.listWidget_data.item(i) for i in range(self.owner.listWidget_data.count())) items = (self.owner.listWidget_data.item(i)
for i in range(self.owner.listWidget_data.count()))
files = [] files = []
for item in items: for item in items:
files.append(item.text()) files.append(item.text())
self.exp = Experiment(exp_type=instrument_type, files=files, t1=self.owner.doubleSpinBox_tmin.value(), t2=self.owner.doubleSpinBox_tmax.value(), self.exp = Experiment(exp_type=instrument_type,
dt=self.owner.doubleSpinBox_dt.value(), cols=12, rows=8, cutoff_low=c_lower, cutoff_high=c_upper, files=files,
signal_threshold=signal_threshold, color_range=cbar_range) t1=self.owner.doubleSpinBox_tmin.value(),
print("Start processing of data... ") t2=self.owner.doubleSpinBox_tmax.value(),
dt=self.owner.doubleSpinBox_dt.value(),
cols=12,
rows=8,
cutoff_low=c_lower,
cutoff_high=c_upper,
signal_threshold=signal_threshold,
color_range=cbar_range)
self.exp.analyze() self.exp.analyze()
print("done!")
self.signals.finished.emit() self.signals.finished.emit()
@ -93,7 +93,6 @@ class Tasks(QObject):
for task in self.tasks: for task in self.tasks:
self.data.append(task.exp) self.data.append(task.exp)
print(self.data)
self.signals.finished.emit(self.data) self.signals.finished.emit(self.data)
@ -117,7 +116,11 @@ class MainWindow(QMainWindow, Ui_MainWindow):
self.statusBar.addPermanentWidget(self.progressBar) self.statusBar.addPermanentWidget(self.progressBar)
self.statusBar.showMessage("Welcome to PyDSF") self.statusBar.showMessage("Welcome to PyDSF")
self.buttonBox_process.addButton("&Start Processing", QDialogButtonBox.AcceptRole) self.buttonBox_process.addButton("&Start Processing",
QDialogButtonBox.AcceptRole)
self.tasks = Tasks()
self.worker = Worker(self)
@pyqtSlot("QAbstractButton*") @pyqtSlot("QAbstractButton*")
def on_buttonBox_open_reset_clicked(self, button): def on_buttonBox_open_reset_clicked(self, button):
@ -125,16 +128,15 @@ class MainWindow(QMainWindow, Ui_MainWindow):
Slot documentation goes here. Slot documentation goes here.
""" """
if button == self.buttonBox_open_reset.button(QDialogButtonBox.Open): if button == self.buttonBox_open_reset.button(QDialogButtonBox.Open):
filenames, filter = QFileDialog.getOpenFileNames(self, 'Open data file', '', "Text files (*.txt *.csv)") filenames = QFileDialog.getOpenFileNames(
self.listWidget_data.addItems(filenames) self, 'Open data file', '', "Text files (*.txt *.csv)")
self.listWidget_data.addItems(filenames[0])
if self.listWidget_data.count() > 1: if self.listWidget_data.count() > 1:
self.groupBox_replicates.setChecked(True) self.groupBox_replicates.setChecked(True)
self.radioButton_rep_files.setEnabled(True) self.radioButton_rep_files.setEnabled(True)
elif button == self.buttonBox_open_reset.button(QDialogButtonBox.Reset): elif button == self.buttonBox_open_reset.button(
QDialogButtonBox.Reset):
self.listWidget_data.clear() self.listWidget_data.clear()
print("Data cleared")
# self.radioButton_rep_rows.setEnabled(False)
# self.radioButton_rep_columns.setEnabled(False)
@pyqtSlot("QString") @pyqtSlot("QString")
def on_comboBox_instrument_currentIndexChanged(self, p0): def on_comboBox_instrument_currentIndexChanged(self, p0):
@ -142,17 +144,12 @@ class MainWindow(QMainWindow, Ui_MainWindow):
Slot documentation goes here. Slot documentation goes here.
""" """
if p0 == 'Analytik Jena qTOWER 2.0/2.2': if p0 == 'Analytik Jena qTOWER 2.0/2.2':
print(p0)
self.groupBox_temp.setEnabled(True) self.groupBox_temp.setEnabled(True)
else: else:
self.groupBox_temp.setEnabled(False) self.groupBox_temp.setEnabled(False)
# self.groupBox_data.setEnabled(True)
# self.groupBox_cutoff.setEnabled(True)
# self.groupBox_cbar.setEnabled(True)
# self.groupBox_signal_threshold.setEnabled(True)
def generate_plot_tab(self, name): def generate_plot_tab(self, name):
tab = MplWidget() tab = MplWidget(parent=self)
tab.setObjectName(name) tab.setObjectName(name)
return tab return tab
@ -183,18 +180,19 @@ class MainWindow(QMainWindow, Ui_MainWindow):
""" """
if self.listWidget_data.count() < 1: if self.listWidget_data.count() < 1:
QMessageBox.critical(self, 'Error', "No data file loaded!", QMessageBox.Close, QMessageBox.Close) QMessageBox.critical(self, 'Error', "No data file loaded!",
QMessageBox.Close, QMessageBox.Close)
return return
if self.spinBox_signal_threshold.value() == 0 and self.groupBox_signal_threshold.isChecked(): if self.spinBox_signal_threshold.value(
QMessageBox.warning(self, 'Warning', "Signal threshold is currently set to zero.", QMessageBox.Ok, ) == 0 and self.groupBox_signal_threshold.isChecked():
QMessageBox.Ok) QMessageBox.warning(self, 'Warning',
"Signal threshold is currently set to zero.",
QMessageBox.Ok, QMessageBox.Ok)
self.progressBar.setEnabled(True) self.progressBar.setEnabled(True)
self.statusBar.showMessage("Processing...") self.statusBar.showMessage("Processing...")
self.tasks = Tasks()
self.tasks.signals.finished.connect(self.on_processing_finished) self.tasks.signals.finished.connect(self.on_processing_finished)
self.worker = Worker(self)
self.tasks.add_task(self.worker) self.tasks.add_task(self.worker)
self.tasks.start() self.tasks.start()
@ -203,20 +201,29 @@ class MainWindow(QMainWindow, Ui_MainWindow):
# For now, only read the first entry # For now, only read the first entry
exp = self.tasks.data[0] exp = self.tasks.data[0]
save_data = QMessageBox.question(self, 'Save data', "Calculations are finished. Save results?", save_data = QMessageBox.question(
QMessageBox.Yes | QMessageBox.No, QMessageBox.Yes) self, 'Save data', "Calculations are finished. Save results?",
QMessageBox.Yes | QMessageBox.No, QMessageBox.Yes)
if save_data == QMessageBox.Yes: if save_data == QMessageBox.Yes:
dialog = QFileDialog() dialog = QFileDialog()
dialog.setFileMode(QFileDialog.Directory) dialog.setFileMode(QFileDialog.Directory)
folder = dialog.getExistingDirectory(self, 'Choose path for results') folder = dialog.getExistingDirectory(self,
'Choose path for results')
for plate in exp.plates: for plate in exp.plates:
plate.write_tm_table('{}/plate_{}_04_tm.csv'.format(folder, str(plate.id))) plate.write_tm_table(
plate.write_derivative_table('{}/plate_{}_03_dI_dT.csv'.format(folder, str(plate.id))) '{}/plate_{}_04_tm.csv'.format(folder, str(plate.id)))
plate.write_filtered_table('{}/plate_{}_02_filtered_data.csv'.format(folder, str(plate.id))) plate.write_derivative_table(
plate.write_raw_table('{}/plate_{}_01_raw_data.csv'.format(folder, str(plate.id))) '{}/plate_{}_03_dI_dT.csv'.format(folder, str(plate.id)))
plate.write_filtered_table(
'{}/plate_{}_02_filtered_data.csv'.format(folder,
str(plate.id)))
plate.write_raw_table('{}/plate_{}_01_raw_data.csv'.format(
folder, str(plate.id)))
if exp.avg_plate: if exp.avg_plate:
exp.avg_plate.write_avg_tm_table('{}/plate_{}_05_tm_avg.csv'.format(folder, str(self.worker.exp.avg_plate.id))) exp.avg_plate.write_avg_tm_table(
'{}/plate_{}_05_tm_avg.csv'.format(
folder, str(self.worker.exp.avg_plate.id)))
for i in range(len(self.worker.exp.plates)): for i in range(len(self.worker.exp.plates)):
@ -247,7 +254,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
QApplication.quit() QApplication.quit()
@pyqtSlot("bool") @pyqtSlot("bool")
def on_groupBox_cutoff_toggled(self, p0): def on_groupBox_cutoff_toggled(self):
""" """
Slot documentation goes here. Slot documentation goes here.
""" """

View file

@ -26,11 +26,14 @@
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="opaqueResize">
<bool>false</bool>
</property>
<property name="handleWidth"> <property name="handleWidth">
<number>2</number> <number>2</number>
</property> </property>
<property name="childrenCollapsible"> <property name="childrenCollapsible">
<bool>true</bool> <bool>false</bool>
</property> </property>
<widget class="QGroupBox" name="groupBox_experiment"> <widget class="QGroupBox" name="groupBox_experiment">
<property name="sizePolicy"> <property name="sizePolicy">
@ -463,9 +466,12 @@
</layout> </layout>
</widget> </widget>
<widget class="QTabWidget" name="tabWidget"> <widget class="QTabWidget" name="tabWidget">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred"> <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>6</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
@ -476,31 +482,8 @@
</size> </size>
</property> </property>
<property name="currentIndex"> <property name="currentIndex">
<number>0</number> <number>-1</number>
</property> </property>
<widget class="MplWidget" name="tab_raw">
<attribute name="title">
<string>Raw Data</string>
</attribute>
</widget>
<widget class="MplWidget" name="tab_derivative">
<attribute name="title">
<string>&amp;2nd derivative</string>
</attribute>
</widget>
<widget class="MplWidget" name="tab_heatmap">
<attribute name="title">
<string>Heatmap</string>
</attribute>
</widget>
<widget class="MplWidget" name="tab_heatmap_avg">
<property name="enabled">
<bool>false</bool>
</property>
<attribute name="title">
<string>Heatmap average</string>
</attribute>
</widget>
</widget> </widget>
</widget> </widget>
</item> </item>
@ -561,16 +544,6 @@
</property> </property>
</action> </action>
</widget> </widget>
<customwidgets> <resources/>
<customwidget>
<class>MplWidget</class>
<extends>QWidget</extends>
<header>mplwidget</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources>
<include location="icons.qrc"/>
</resources>
<connections/> <connections/>
</ui> </ui>