mirror of
https://github.com/Athemis/PyDSF.git
synced 2025-04-20 20:09:13 +00:00
Prepare for translation
Made strings translatable and generated first translation template.
This commit is contained in:
parent
35b2920d34
commit
abe85f323e
3 changed files with 285 additions and 21 deletions
|
@ -3,7 +3,7 @@
|
|||
Module implementing MainWindow.
|
||||
"""
|
||||
from PyQt5.QtCore import (pyqtSlot, QObject, pyqtSignal, QThreadPool,
|
||||
QRunnable, )
|
||||
QRunnable, QCoreApplication)
|
||||
from PyQt5.QtWidgets import (QMainWindow, QProgressBar, QDialogButtonBox,
|
||||
QFileDialog, QMessageBox, QApplication)
|
||||
|
||||
|
@ -116,8 +116,9 @@ 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(
|
||||
QCoreApplication.translate("MainWindow", "&Start Processing"),
|
||||
QDialogButtonBox.AcceptRole)
|
||||
|
||||
self.tasks = Tasks()
|
||||
self.worker = Worker(self)
|
||||
|
@ -129,7 +130,10 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
|||
"""
|
||||
if button == self.buttonBox_open_reset.button(QDialogButtonBox.Open):
|
||||
filenames = QFileDialog.getOpenFileNames(
|
||||
self, 'Open data file', '', "Text files (*.txt *.csv)")
|
||||
self,
|
||||
QCoreApplication.translate("MainWindow", "Open data file"), '',
|
||||
QCoreApplication.translate("MainWindow",
|
||||
"Text files (*.txt *.csv)"))
|
||||
self.listWidget_data.addItems(filenames[0])
|
||||
if self.listWidget_data.count() > 1:
|
||||
self.groupBox_replicates.setChecked(True)
|
||||
|
@ -158,19 +162,23 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
|||
|
||||
if id != 'average':
|
||||
tab = self.generate_plot_tab("tab_heatmap_{}".format(id))
|
||||
self.tabWidget.addTab(tab, "Heatmap #{}".format(plate.id))
|
||||
self.tabWidget.addTab(tab, QCoreApplication.translate(
|
||||
"MainWindow", "Heatmap #{}".format(plate.id)))
|
||||
plotter.plot_tm_heatmap_single(plate, tab)
|
||||
|
||||
tab = self.generate_plot_tab("tab_raw_{}".format(id))
|
||||
self.tabWidget.addTab(tab, "Raw Data #{}".format(plate.id))
|
||||
self.tabWidget.addTab(tab, QCoreApplication.translate(
|
||||
"MainWindow", "Raw Data #{}".format(plate.id)))
|
||||
plotter.plot_raw(plate, tab)
|
||||
|
||||
tab = self.generate_plot_tab("tab_derivative_{}".format(id))
|
||||
self.tabWidget.addTab(tab, "Derivatives #{}".format(plate.id))
|
||||
self.tabWidget.addTab(tab, QCoreApplication.translate(
|
||||
"MainWindow", "Derivatives #{}".format(plate.id)))
|
||||
plotter.plot_derivative(plate, tab)
|
||||
else:
|
||||
tab = self.generate_plot_tab("tab_heatmap_{}".format(id))
|
||||
self.tabWidget.addTab(tab, "Heatmap ({})".format(plate.id))
|
||||
self.tabWidget.addTab(tab, QCoreApplication.translate(
|
||||
"MainWindow", "Heatmap ({})".format(plate.id)))
|
||||
plotter.plot_tm_heatmap_single(plate, tab)
|
||||
|
||||
@pyqtSlot()
|
||||
|
@ -180,17 +188,24 @@ 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, QCoreApplication.translate("MainWindow", "Error"),
|
||||
QCoreApplication.translate("MainWindow",
|
||||
"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)
|
||||
QMessageBox.warning(
|
||||
self, QCoreApplication.translate("MainWindow", "Warning"),
|
||||
QCoreApplication.translate(
|
||||
"MainWindow",
|
||||
"Signal threshold is currently set to zero."),
|
||||
QMessageBox.Ok, QMessageBox.Ok)
|
||||
|
||||
self.progressBar.setEnabled(True)
|
||||
self.statusBar.showMessage("Processing...")
|
||||
self.statusBar.showMessage(QCoreApplication.translate("MainWindow",
|
||||
"Processing..."))
|
||||
|
||||
self.tasks.signals.finished.connect(self.on_processing_finished)
|
||||
self.tasks.add_task(self.worker)
|
||||
|
@ -202,13 +217,16 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
|||
exp = self.tasks.data[0]
|
||||
|
||||
save_data = QMessageBox.question(
|
||||
self, 'Save data', "Calculations are finished. Save results?",
|
||||
self, QCoreApplication.translate("MainWindow", "Save data"),
|
||||
QCoreApplication.translate(
|
||||
"MainWindow", "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, QCoreApplication.translate("MainWindow",
|
||||
"Choose path for results"))
|
||||
for plate in exp.plates:
|
||||
plate.write_tm_table(
|
||||
'{}/plate_{}_04_tm.csv'.format(folder, str(plate.id)))
|
||||
|
@ -236,7 +254,8 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
|||
self.generate_plate_tabs(plate)
|
||||
|
||||
self.progressBar.setEnabled(False)
|
||||
self.statusBar.showMessage("Finished!")
|
||||
self.statusBar.showMessage(QCoreApplication.translate("MainWindow",
|
||||
"Finished!"))
|
||||
|
||||
@pyqtSlot()
|
||||
def on_buttonBox_process_rejected(self):
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
from PyQt5 import QtWidgets
|
||||
from PyQt5.QtCore import QCoreApplication
|
||||
from matplotlib.backends.backend_qt5agg import (FigureCanvasQTAgg as
|
||||
FigureCanvas)
|
||||
from matplotlib.backends.backend_qt5agg import (NavigationToolbar2QT as
|
||||
|
@ -29,9 +30,14 @@ class MplCanvas(FigureCanvas):
|
|||
|
||||
class CustomNavigationToolbar(NavigationToolbar):
|
||||
toolitems = (
|
||||
('Save', 'Save the figure', 'filesave', 'save_figure'),
|
||||
('Subplots', 'Configure subplots', 'subplots', 'configure_subplots'),
|
||||
(None, None, None, None), )
|
||||
(QCoreApplication.translate("CustomNavigationToolbar", 'Save'),
|
||||
QCoreApplication.translate("CustomNavigationToolbar",
|
||||
'Save the figure'), 'filesave',
|
||||
'save_figure'),
|
||||
(QCoreApplication.translate("CustomNavigationToolbar", 'Subplots'),
|
||||
QCoreApplication.translate("CustomNavigationToolbar",
|
||||
'Configure subplots'), 'subplots',
|
||||
'configure_subplots'), (None, None, None, None), )
|
||||
|
||||
def __init__(self, canvas, parent, coordinates=True):
|
||||
NavigationToolbar.__init__(self, canvas, parent,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue