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

View file

@ -1,19 +1,11 @@
# -*- coding: utf-8 -*-
"""
Module implementing MainWindow.
"""
from PyQt5.QtCore import (pyqtSlot,
QObject,
pyqtSignal,
QThreadPool,
QRunnable,)
from PyQt5.QtWidgets import (QMainWindow,
QProgressBar,
QDialogButtonBox,
QFileDialog,
QMessageBox,
QApplication)
from PyQt5.QtCore import (pyqtSlot, QObject, pyqtSignal, QThreadPool,
QRunnable, )
from PyQt5.QtWidgets import (QMainWindow, QProgressBar, QDialogButtonBox,
QFileDialog, QMessageBox, QApplication)
from .Ui_mainwindow import Ui_MainWindow
from .mplwidget import MplWidget
@ -46,21 +38,29 @@ class Worker(QRunnable):
c_lower = self.owner.doubleSpinBox_lower.value()
c_upper = self.owner.doubleSpinBox_upper.value()
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():
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 = []
for item in items:
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(),
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)
print("Start processing of data... ")
self.exp = Experiment(exp_type=instrument_type,
files=files,
t1=self.owner.doubleSpinBox_tmin.value(),
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()
print("done!")
self.signals.finished.emit()
@ -93,7 +93,6 @@ class Tasks(QObject):
for task in self.tasks:
self.data.append(task.exp)
print(self.data)
self.signals.finished.emit(self.data)
@ -117,7 +116,11 @@ class MainWindow(QMainWindow, Ui_MainWindow):
self.statusBar.addPermanentWidget(self.progressBar)
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*")
def on_buttonBox_open_reset_clicked(self, button):
@ -125,16 +128,15 @@ class MainWindow(QMainWindow, Ui_MainWindow):
Slot documentation goes here.
"""
if button == self.buttonBox_open_reset.button(QDialogButtonBox.Open):
filenames, filter = QFileDialog.getOpenFileNames(self, 'Open data file', '', "Text files (*.txt *.csv)")
self.listWidget_data.addItems(filenames)
filenames = QFileDialog.getOpenFileNames(
self, 'Open data file', '', "Text files (*.txt *.csv)")
self.listWidget_data.addItems(filenames[0])
if self.listWidget_data.count() > 1:
self.groupBox_replicates.setChecked(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()
print("Data cleared")
# self.radioButton_rep_rows.setEnabled(False)
# self.radioButton_rep_columns.setEnabled(False)
@pyqtSlot("QString")
def on_comboBox_instrument_currentIndexChanged(self, p0):
@ -142,17 +144,12 @@ class MainWindow(QMainWindow, Ui_MainWindow):
Slot documentation goes here.
"""
if p0 == 'Analytik Jena qTOWER 2.0/2.2':
print(p0)
self.groupBox_temp.setEnabled(True)
else:
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):
tab = MplWidget()
tab = MplWidget(parent=self)
tab.setObjectName(name)
return tab
@ -183,18 +180,19 @@ class MainWindow(QMainWindow, Ui_MainWindow):
"""
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
if self.spinBox_signal_threshold.value() == 0 and self.groupBox_signal_threshold.isChecked():
QMessageBox.warning(self, 'Warning', "Signal threshold is currently set to zero.", QMessageBox.Ok,
QMessageBox.Ok)
if self.spinBox_signal_threshold.value(
) == 0 and self.groupBox_signal_threshold.isChecked():
QMessageBox.warning(self, 'Warning',
"Signal threshold is currently set to zero.",
QMessageBox.Ok, QMessageBox.Ok)
self.progressBar.setEnabled(True)
self.statusBar.showMessage("Processing...")
self.tasks = Tasks()
self.tasks.signals.finished.connect(self.on_processing_finished)
self.worker = Worker(self)
self.tasks.add_task(self.worker)
self.tasks.start()
@ -203,20 +201,29 @@ class MainWindow(QMainWindow, Ui_MainWindow):
# For now, only read the first entry
exp = self.tasks.data[0]
save_data = QMessageBox.question(self, 'Save data', "Calculations are finished. Save results?",
QMessageBox.Yes | QMessageBox.No, QMessageBox.Yes)
save_data = QMessageBox.question(
self, 'Save data', "Calculations are finished. Save results?",
QMessageBox.Yes | QMessageBox.No, QMessageBox.Yes)
if save_data == QMessageBox.Yes:
dialog = QFileDialog()
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:
plate.write_tm_table('{}/plate_{}_04_tm.csv'.format(folder, str(plate.id)))
plate.write_derivative_table('{}/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)))
plate.write_tm_table(
'{}/plate_{}_04_tm.csv'.format(folder, str(plate.id)))
plate.write_derivative_table(
'{}/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:
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)):
@ -247,7 +254,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
QApplication.quit()
@pyqtSlot("bool")
def on_groupBox_cutoff_toggled(self, p0):
def on_groupBox_cutoff_toggled(self):
"""
Slot documentation goes here.
"""

View file

@ -26,11 +26,14 @@
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="opaqueResize">
<bool>false</bool>
</property>
<property name="handleWidth">
<number>2</number>
</property>
<property name="childrenCollapsible">
<bool>true</bool>
<bool>false</bool>
</property>
<widget class="QGroupBox" name="groupBox_experiment">
<property name="sizePolicy">
@ -463,9 +466,12 @@
</layout>
</widget>
<widget class="QTabWidget" name="tabWidget">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<horstretch>6</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
@ -476,31 +482,8 @@
</size>
</property>
<property name="currentIndex">
<number>0</number>
<number>-1</number>
</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>
</item>
@ -561,16 +544,6 @@
</property>
</action>
</widget>
<customwidgets>
<customwidget>
<class>MplWidget</class>
<extends>QWidget</extends>
<header>mplwidget</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources>
<include location="icons.qrc"/>
</resources>
<resources/>
<connections/>
</ui>