mirror of
https://github.com/FAUSheppy/ths-datenlogger
synced 2025-12-07 12:31:34 +01:00
Implement GUI
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,4 +1,5 @@
|
|||||||
*.png
|
*.png
|
||||||
|
target/
|
||||||
*.bak
|
*.bak
|
||||||
cache/
|
cache/
|
||||||
*.dbf
|
*.dbf
|
||||||
|
|||||||
@@ -28,6 +28,8 @@ def get_keys(like=None):
|
|||||||
|
|
||||||
def change_cfg(key,value):
|
def change_cfg(key,value):
|
||||||
global conf
|
global conf
|
||||||
|
if conf == None:
|
||||||
|
parse_config()
|
||||||
confs = conf["plot"]
|
confs = conf["plot"]
|
||||||
v = str(value)
|
v = str(value)
|
||||||
key = str(key)
|
key = str(key)
|
||||||
104
src/main/python/gui.py
Normal file
104
src/main/python/gui.py
Normal file
@@ -0,0 +1,104 @@
|
|||||||
|
#!/usr/bin/python3
|
||||||
|
|
||||||
|
from fbs_runtime.application_context.PyQt5 import ApplicationContext
|
||||||
|
from PyQt5.QtCore import QDateTime, Qt, QTimer
|
||||||
|
from PyQt5.QtWidgets import (QApplication, QCheckBox, QComboBox, QDateTimeEdit,
|
||||||
|
QDial, QDialog, QGridLayout, QGroupBox, QHBoxLayout, QLabel, QLineEdit,
|
||||||
|
QProgressBar, QPushButton, QRadioButton, QScrollBar, QSizePolicy,
|
||||||
|
QSlider, QSpinBox, QStyleFactory, QTableWidget, QTabWidget, QTextEdit,
|
||||||
|
QVBoxLayout, QWidget)
|
||||||
|
|
||||||
|
import localization.de as de
|
||||||
|
|
||||||
|
class WidgetGallery(QDialog):
|
||||||
|
|
||||||
|
def __init__(self, parent=None):
|
||||||
|
super(WidgetGallery, self).__init__(parent)
|
||||||
|
|
||||||
|
self.localization = de
|
||||||
|
self.srcFileString = ""
|
||||||
|
|
||||||
|
styleComboBox = QComboBox()
|
||||||
|
styleComboBox.addItems(QStyleFactory.keys())
|
||||||
|
|
||||||
|
self.createFileSelection()
|
||||||
|
self.createDateSelection()
|
||||||
|
self.createCheckboxArea()
|
||||||
|
|
||||||
|
mainLayout = QGridLayout()
|
||||||
|
mainLayout.addLayout(topLayout, 0, 0, 1, 2)
|
||||||
|
mainLayout.addWidget(self.fileSelectionGroup, 1, 0)
|
||||||
|
mainLayout.addWidget(self.dateSelectionGroupBox, 1, 1)
|
||||||
|
mainLayout.addWidget(self.checkboxGroup, 2, 0)
|
||||||
|
|
||||||
|
mainLayout.setRowStretch(1, 1)
|
||||||
|
mainLayout.setRowStretch(2, 1)
|
||||||
|
mainLayout.setColumnStretch(0, 1)
|
||||||
|
mainLayout.setColumnStretch(1, 1)
|
||||||
|
|
||||||
|
self.setLayout(mainLayout)
|
||||||
|
|
||||||
|
self.setWindowTitle(self.localization.window_title)
|
||||||
|
|
||||||
|
def createFileSelection(self):
|
||||||
|
'''Generate the area containing the file selectors and go button'''
|
||||||
|
|
||||||
|
self.fileSelectionGroup = QGroupBox(self.localization.file_selection)
|
||||||
|
|
||||||
|
# basic object #
|
||||||
|
buttonGo = QPushButton(self.localization.button_go)
|
||||||
|
buttonSrcFile = QPushButton(self.localization.button_set_src_file)
|
||||||
|
srcFileName = QLabel(self.srcFileString)
|
||||||
|
|
||||||
|
buttonTargetFile = QPushButton(self.target_file)
|
||||||
|
buttonUseSrcDir = QCheckBox(self.localization.button_use_src_dir)
|
||||||
|
|
||||||
|
# connectors #
|
||||||
|
buttonGo.connect(self.run)
|
||||||
|
buttonSrcFile.connect(self.selectSrcFile)
|
||||||
|
buttonTargetFile.connect(self.selectTargetFile)
|
||||||
|
buttonUseSrcDir.connect(self.useSrcDir)
|
||||||
|
|
||||||
|
# layout #
|
||||||
|
layout = QVBoxLayout()
|
||||||
|
|
||||||
|
layout.addWidget(buttonGo)
|
||||||
|
layout.addWidget(buttonSrcFile)
|
||||||
|
layout.addWidget(srcFileName)
|
||||||
|
|
||||||
|
layout.addWidget(buttonTargetFile)
|
||||||
|
layout.addWidget(buttonUseSrcDir)
|
||||||
|
|
||||||
|
layout.addStretch(1)
|
||||||
|
self.dateSelectionGroupBox.setLayout(layout)
|
||||||
|
|
||||||
|
def createDateSelection(self):
|
||||||
|
'''Generate the area containing the date selectors'''
|
||||||
|
|
||||||
|
self.dateSelectionGroupBox = QGroupBox(self.localization.date_selection)
|
||||||
|
|
||||||
|
layout = QVBoxLayout()
|
||||||
|
layout.addWidget() # TODO
|
||||||
|
layout.addStretch(1)
|
||||||
|
self.topRightGroupBox.setLayout(layout)
|
||||||
|
|
||||||
|
def createCheckboxArea(self):
|
||||||
|
'''Generate area with configuration options'''
|
||||||
|
|
||||||
|
self.checkboxGroup = QGroupBox(self.localization.options)
|
||||||
|
|
||||||
|
buttonOTemp = QCheckBox(self.localization.button_otemp)
|
||||||
|
buttonOHumidity = QCheckBox(self.localization.button_ohumidity)
|
||||||
|
|
||||||
|
layout = QVBoxLayout()
|
||||||
|
layout.addWidget(buttonOTemp)
|
||||||
|
layout.addWidget(buttonOHumidity)
|
||||||
|
layout.addStretch(1)
|
||||||
|
self.topRightGroupBox.setLayout(layout)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
appctxt = ApplicationContext()
|
||||||
|
gallery = WidgetGallery()
|
||||||
|
gallery.show()
|
||||||
|
sys.exit(appctxt.app.exec_())
|
||||||
@@ -31,7 +31,7 @@ class Data:
|
|||||||
'''Get time of last timestamp'''
|
'''Get time of last timestamp'''
|
||||||
return max(self.times)
|
return max(self.times)
|
||||||
|
|
||||||
def get_timeframe(self, callback,date1=None,date2=None):
|
def get_timeframe(self, callback, date1=None, date2=None):
|
||||||
out_x = []
|
out_x = []
|
||||||
out_y = []
|
out_y = []
|
||||||
i = 0
|
i = 0
|
||||||
@@ -151,7 +151,7 @@ def processExternalData(datapoints, plotNameKey, fromTime, toTime, dtype):
|
|||||||
raise e
|
raise e
|
||||||
|
|
||||||
|
|
||||||
def read_in_file(path, backend=None, outsideData=False):
|
def read_in_file(path, backend=None, outsideData=False, plotOutsideTemp=True, plotOutsideHum=True):
|
||||||
'''Read in a file, add outside data if requested'''
|
'''Read in a file, add outside data if requested'''
|
||||||
|
|
||||||
datapoints = dict()
|
datapoints = dict()
|
||||||
@@ -179,8 +179,8 @@ def read_in_file(path, backend=None, outsideData=False):
|
|||||||
plotSettings = [ CFG("plot_temperatur"),
|
plotSettings = [ CFG("plot_temperatur"),
|
||||||
CFG("plot_humidity"),
|
CFG("plot_humidity"),
|
||||||
CFG("plot_dewcels"),
|
CFG("plot_dewcels"),
|
||||||
outsideData,
|
plotOutsideTemp,
|
||||||
outsideData ]
|
plotOutsideHum ]
|
||||||
|
|
||||||
assert(len(names) == len(colors) == len(identifiers) == len(plotSettings))
|
assert(len(names) == len(colors) == len(identifiers) == len(plotSettings))
|
||||||
|
|
||||||
@@ -1,9 +1,22 @@
|
|||||||
window_title = "Datenlogger Tool"
|
window_title = "Datenlogger Tool"
|
||||||
file_selection = "Dateiauswahl"
|
file_selection = "Dateiauswahl"
|
||||||
button_go = "Start"
|
button_go = "Start"
|
||||||
|
button_go_wait = "Bitte Warten.."
|
||||||
button_set_src_file = "Datei.."
|
button_set_src_file = "Datei.."
|
||||||
button_use_src_dir = "Gleicher Ordner"
|
button_use_src_dir = "Gleicher Ordner"
|
||||||
date_selection = "Zeitbereich"
|
date_selection = "Zeitbereich"
|
||||||
options = "Optionen"
|
options = "Optionen"
|
||||||
button_otemp = "Ausßentemperatur"
|
button_otemp = "Ausßentemperatur einzeichnen"
|
||||||
button_ohumidity = "Außenluftfeuchtigkeit"
|
button_ohumidity = "Außenluftfeuchtigkeit einzeichnen"
|
||||||
|
output_file = "Ausgabe"
|
||||||
|
output_file_placeholder = "Datei auswählen.."
|
||||||
|
src_file_dialog = "Datei auswählen"
|
||||||
|
src_file_extensions = "Logger Dateien (*.txt *.csv *.dbf);; Alle *.*"
|
||||||
|
save_file_dialog = "Zieldatei"
|
||||||
|
wait_dialog_text = "Datei wird gelesen.."
|
||||||
|
error_read_in = "Fehler beim Einlesen der Datei."
|
||||||
|
done_text = "Fertig"
|
||||||
|
start_section = "Ausführen"
|
||||||
|
close = "Schließen"
|
||||||
|
open_pic = "Bild öffnen.."
|
||||||
|
bad_time = "Fehlerhafte Zeitangabe!"
|
||||||
|
|||||||
@@ -1,14 +1,22 @@
|
|||||||
#!/usr/bin/python3
|
#!/usr/bin/python3
|
||||||
|
|
||||||
from fbs_runtime.application_context.PyQt5 import ApplicationContext
|
from fbs_runtime.application_context.PyQt5 import ApplicationContext
|
||||||
from PyQt5.QtCore import QDateTime, Qt, QTimer
|
from PyQt5.QtCore import QDateTime, Qt, QTimer, QUrl
|
||||||
|
import PyQt5.QtCore
|
||||||
|
import PyQt5.QtGui
|
||||||
from PyQt5.QtWidgets import (QApplication, QCheckBox, QComboBox, QDateTimeEdit,
|
from PyQt5.QtWidgets import (QApplication, QCheckBox, QComboBox, QDateTimeEdit,
|
||||||
QDial, QDialog, QGridLayout, QGroupBox, QHBoxLayout, QLabel, QLineEdit,
|
QDial, QDialog, QGridLayout, QGroupBox, QHBoxLayout, QLabel, QLineEdit,
|
||||||
QProgressBar, QPushButton, QRadioButton, QScrollBar, QSizePolicy,
|
QProgressBar, QPushButton, QRadioButton, QScrollBar, QSizePolicy,
|
||||||
QSlider, QSpinBox, QStyleFactory, QTableWidget, QTabWidget, QTextEdit,
|
QSlider, QSpinBox, QStyleFactory, QTableWidget, QTabWidget, QTextEdit,
|
||||||
QVBoxLayout, QWidget)
|
QVBoxLayout, QWidget, QFileDialog, QDateEdit, QMessageBox)
|
||||||
|
|
||||||
import localization.de as de
|
import localization.de as de
|
||||||
|
import sys
|
||||||
|
import datetime as dt
|
||||||
|
|
||||||
|
import input_backend
|
||||||
|
import plot_main
|
||||||
|
import config_parse as cp
|
||||||
|
|
||||||
class WidgetGallery(QDialog):
|
class WidgetGallery(QDialog):
|
||||||
|
|
||||||
@@ -18,85 +26,250 @@ class WidgetGallery(QDialog):
|
|||||||
self.localization = de
|
self.localization = de
|
||||||
self.srcFileString = ""
|
self.srcFileString = ""
|
||||||
self.targetFileString = ""
|
self.targetFileString = ""
|
||||||
|
self.truePath = None
|
||||||
|
|
||||||
styleComboBox = QComboBox()
|
styleComboBox = QComboBox()
|
||||||
styleComboBox.addItems(QStyleFactory.keys())
|
styleComboBox.addItems(QStyleFactory.keys())
|
||||||
|
|
||||||
|
self.createStartSection()
|
||||||
self.createFileSelection()
|
self.createFileSelection()
|
||||||
self.createDateSelection()
|
self.createDateSelection()
|
||||||
self.createCheckboxArea()
|
self.createCheckboxArea()
|
||||||
|
|
||||||
mainLayout = QGridLayout()
|
mainLayout = QGridLayout()
|
||||||
mainLayout.addLayout(topLayout, 0, 0, 1, 2)
|
|
||||||
mainLayout.addWidget(self.fileSelectionGroup, 1, 0)
|
mainLayout.addWidget(self.fileSelectionGroup, 1, 0)
|
||||||
mainLayout.addWidget(self.dateSelectionGroupBox, 1, 1)
|
mainLayout.addWidget(self.dateSelectionGroupBox, 2, 0)
|
||||||
mainLayout.addWidget(self.checkboxGroup, 2, 0)
|
mainLayout.addWidget(self.checkboxGroup, 3, 0)
|
||||||
|
mainLayout.addWidget(self.startSection, 4, 0)
|
||||||
mainLayout.setRowStretch(1, 1)
|
|
||||||
mainLayout.setRowStretch(2, 1)
|
|
||||||
mainLayout.setColumnStretch(0, 1)
|
|
||||||
mainLayout.setColumnStretch(1, 1)
|
|
||||||
|
|
||||||
self.setLayout(mainLayout)
|
self.setLayout(mainLayout)
|
||||||
|
|
||||||
self.setWindowTitle(self.localization.window_title)
|
self.setWindowTitle(self.localization.window_title)
|
||||||
|
|
||||||
|
def createStartSection(self):
|
||||||
|
'''Generate Aread containing the start button'''
|
||||||
|
|
||||||
|
self.startSection = QGroupBox(self.localization.start_section)
|
||||||
|
self.buttonGo = QPushButton(self.localization.button_go)
|
||||||
|
self.buttonGo.setDisabled(True)
|
||||||
|
self.buttonGo.clicked.connect(self.run)
|
||||||
|
|
||||||
|
layout = QVBoxLayout()
|
||||||
|
layout.addWidget(self.buttonGo)
|
||||||
|
|
||||||
|
self.startSection.setLayout(layout)
|
||||||
|
|
||||||
def createFileSelection(self):
|
def createFileSelection(self):
|
||||||
'''Generate the area containing the file selectors and go button'''
|
'''Generate the area containing the file selectors and go button'''
|
||||||
|
|
||||||
self.fileSelectionGroup = QGroupBox(self.localization.file_selection)
|
self.fileSelectionGroup = QGroupBox(self.localization.file_selection)
|
||||||
|
|
||||||
# basic object #
|
# basic object #
|
||||||
buttonGo = QPushButton(self.localization.button_go)
|
self.buttonSrcFile = QPushButton(self.localization.button_set_src_file)
|
||||||
buttonSrcFile = QPushButton(self.localization.button_set_src_file)
|
self.srcFileName = QLabel(self.localization.output_file)
|
||||||
srcFileName = QLabel(self.srcFileString)
|
|
||||||
|
|
||||||
buttonTargetFile = QPushButton(self.targetFileString)
|
self.buttonTargetFile = QPushButton(self.localization.output_file_placeholder)
|
||||||
buttonUseSrcDir = QCheckBox(self.localization.button_use_src_dir)
|
self.boxUseSrcDir = QCheckBox(self.localization.button_use_src_dir)
|
||||||
|
|
||||||
# connectors #
|
# connectors #
|
||||||
buttonGo.connect(self.run)
|
self.buttonSrcFile.clicked.connect(self.selectSrcFile)
|
||||||
buttonSrcFile.connect(self.selectSrcFile)
|
self.buttonTargetFile.clicked.connect(self.selectTargetFile)
|
||||||
buttonTargetFile.connect(self.selectTargetFile)
|
self.boxUseSrcDir.stateChanged.connect(self.useSrcDir)
|
||||||
buttonUseSrcDir.connect(self.useSrcDir)
|
self.boxUseSrcDir.setChecked(True)
|
||||||
|
|
||||||
# layout #
|
# layout #
|
||||||
layout = QVBoxLayout()
|
layout = QVBoxLayout()
|
||||||
|
|
||||||
layout.addWidget(buttonGo)
|
layout.addWidget(self.buttonSrcFile)
|
||||||
layout.addWidget(buttonSrcFile)
|
layout.addWidget(self.srcFileName)
|
||||||
layout.addWidget(srcFileName)
|
|
||||||
|
|
||||||
layout.addWidget(buttonTargetFile)
|
layout.addWidget(self.buttonTargetFile)
|
||||||
layout.addWidget(buttonUseSrcDir)
|
layout.addWidget(self.boxUseSrcDir)
|
||||||
|
|
||||||
layout.addStretch(1)
|
layout.addStretch(1)
|
||||||
self.dateSelectionGroupBox.setLayout(layout)
|
self.fileSelectionGroup.setLayout(layout)
|
||||||
|
|
||||||
def createDateSelection(self):
|
def createDateSelection(self):
|
||||||
'''Generate the area containing the date selectors'''
|
'''Generate the area containing the date selectors'''
|
||||||
|
|
||||||
self.dateSelectionGroupBox = QGroupBox(self.localization.date_selection)
|
self.dateSelectionGroupBox = QGroupBox(self.localization.date_selection)
|
||||||
|
|
||||||
layout = QVBoxLayout()
|
layout = QGridLayout()
|
||||||
#layout.addWidget() # TODO
|
|
||||||
layout.addStretch(1)
|
self.startDateEdit = QDateEdit(calendarPopup=True)
|
||||||
self.topRightGroupBox.setLayout(layout)
|
self.startDateEdit.setDisplayFormat("dd.MM.yyyy")
|
||||||
|
self.startDateEdit.setReadOnly(True)
|
||||||
|
self.startDateEdit.lineEdit().setDisabled(True)
|
||||||
|
|
||||||
|
self.endDateEdit = QDateEdit(calendarPopup=True)
|
||||||
|
self.endDateEdit.setDisplayFormat("dd.MM.yyyy")
|
||||||
|
self.endDateEdit.setReadOnly(True)
|
||||||
|
self.endDateEdit.lineEdit().setDisabled(True)
|
||||||
|
|
||||||
|
self.startTimeEdit = QLineEdit("00:00")
|
||||||
|
self.endTimeEdit = QLineEdit("23:59")
|
||||||
|
self.startTimeEdit.setDisabled(True)
|
||||||
|
self.endTimeEdit.setDisabled(True)
|
||||||
|
|
||||||
|
layout.addWidget(self.startDateEdit, 0, 0)
|
||||||
|
layout.addWidget(self.startTimeEdit, 0, 1)
|
||||||
|
|
||||||
|
layout.addWidget(self.endDateEdit, 1, 0)
|
||||||
|
layout.addWidget(self.endTimeEdit, 1, 1)
|
||||||
|
|
||||||
|
layout.setColumnStretch(0, 1)
|
||||||
|
layout.setColumnStretch(1, 1)
|
||||||
|
|
||||||
|
self.dateSelectionGroupBox.setLayout(layout)
|
||||||
|
|
||||||
def createCheckboxArea(self):
|
def createCheckboxArea(self):
|
||||||
'''Generate area with configuration options'''
|
'''Generate area with configuration options'''
|
||||||
|
|
||||||
self.checkboxGroup = QGroupBox(self.localization.options)
|
self.checkboxGroup = QGroupBox(self.localization.options)
|
||||||
|
|
||||||
buttonOTemp = QCheckBox(self.localization.button_otemp)
|
self.boxOTemp = QCheckBox(self.localization.button_otemp)
|
||||||
buttonOHumidity = QCheckBox(self.localization.button_ohumidity)
|
self.boxOHumidity = QCheckBox(self.localization.button_ohumidity)
|
||||||
|
|
||||||
layout = QVBoxLayout()
|
layout = QVBoxLayout()
|
||||||
layout.addWidget(buttonOTemp)
|
layout.addWidget(self.boxOTemp)
|
||||||
layout.addWidget(buttonOHumidity)
|
layout.addWidget(self.boxOHumidity)
|
||||||
layout.addStretch(1)
|
layout.addStretch(1)
|
||||||
self.topRightGroupBox.setLayout(layout)
|
self.checkboxGroup.setLayout(layout)
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
'''Run generation with selected file and options'''
|
||||||
|
|
||||||
|
# set save target if nessesary #
|
||||||
|
self.buttonGo.setText(self.localization.button_go_wait)
|
||||||
|
self.buttonGo.setDisabled(True)
|
||||||
|
self.repaint()
|
||||||
|
|
||||||
|
if self.boxUseSrcDir.isChecked():
|
||||||
|
target = self.srcFileString
|
||||||
|
forcePath = False
|
||||||
|
else:
|
||||||
|
target = self.targetFileString
|
||||||
|
forcePath = True
|
||||||
|
|
||||||
|
# workaround for checkboxes changed #
|
||||||
|
self.datapoints = input_backend.read_in_file(self.srcFileString,
|
||||||
|
outsideData=True,
|
||||||
|
plotOutsideTemp=self.boxOTemp.isChecked(),
|
||||||
|
plotOutsideHum=self.boxOHumidity.isChecked())
|
||||||
|
|
||||||
|
# build dates #
|
||||||
|
try:
|
||||||
|
startTimeHelper = dt.datetime.strptime(self.startTimeEdit.text(),"%H:%M")
|
||||||
|
endTimeHelper = dt.datetime.strptime(self.endTimeEdit.text(),"%H:%M")
|
||||||
|
except ValueError as e:
|
||||||
|
errorBox = QMessageBox(self)
|
||||||
|
errorBox.setAttribute(PyQt5.QtCore.Qt.WA_DeleteOnClose)
|
||||||
|
errorBox.setText(self.localization.bad_time)
|
||||||
|
errorBox.setDetailedText(str(e))
|
||||||
|
errorBox.show()
|
||||||
|
self.buttonGo.setText(self.localization.button_go)
|
||||||
|
self.buttonGo.setDisabled(False)
|
||||||
|
return
|
||||||
|
|
||||||
|
startTimeOffset = dt.timedelta(hours=startTimeHelper.hour, minutes=startTimeHelper.minute)
|
||||||
|
endTimeOffset = dt.timedelta(hours=endTimeHelper.hour, minutes=endTimeHelper.minute)
|
||||||
|
|
||||||
|
zeroTime = dt.time(0, 0)
|
||||||
|
startDateTime = dt.datetime.combine(self.startDateEdit.date().toPyDate(), zeroTime)
|
||||||
|
startDateTime += startTimeOffset
|
||||||
|
endDateTime = dt.datetime.combine(self.endDateEdit.date().toPyDate(), zeroTime)
|
||||||
|
endDateTime += endTimeOffset
|
||||||
|
|
||||||
|
self.truePath = plot_main.plot(self.datapoints, path=target,
|
||||||
|
date1=startDateTime,
|
||||||
|
date2=endDateTime,
|
||||||
|
forcePath=forcePath)
|
||||||
|
|
||||||
|
self.buttonGo.setText(self.localization.button_go)
|
||||||
|
self.buttonGo.setDisabled(False)
|
||||||
|
|
||||||
|
doneDialog = QMessageBox(self)
|
||||||
|
doneDialog.setAttribute(PyQt5.QtCore.Qt.WA_DeleteOnClose)
|
||||||
|
doneDialog.setText(self.localization.done_text)
|
||||||
|
doneDialog.addButton(self.localization.open_pic, QMessageBox.YesRole)
|
||||||
|
doneDialog.addButton(self.localization.close, QMessageBox.NoRole)
|
||||||
|
doneDialog.buttonClicked.connect(self.openFile)
|
||||||
|
doneDialog.show()
|
||||||
|
|
||||||
|
def selectSrcFile(self):
|
||||||
|
'''Function to select a src-file'''
|
||||||
|
|
||||||
|
self.srcFileString = QFileDialog.getOpenFileName(self, self.localization.src_file_dialog,
|
||||||
|
"", "Data-Files (*.txt *.csv *.dbf)")[0]
|
||||||
|
self.srcFileName.setText(self.srcFileString)
|
||||||
|
|
||||||
|
if not self.srcFileString:
|
||||||
|
return
|
||||||
|
|
||||||
|
waitDialog = QMessageBox(self)
|
||||||
|
waitDialog.setAttribute(PyQt5.QtCore.Qt.WA_DeleteOnClose)
|
||||||
|
waitDialog.setText(self.localization.wait_dialog_text)
|
||||||
|
waitDialog.show()
|
||||||
|
try:
|
||||||
|
self.datapoints = input_backend.read_in_file(self.srcFileString,
|
||||||
|
outsideData=False,
|
||||||
|
plotOutsideTemp=False,
|
||||||
|
plotOutsideHum=False)
|
||||||
|
except Exception as e:
|
||||||
|
waitDialog.close()
|
||||||
|
errorBox = QMessageBox(self)
|
||||||
|
errorBox.setAttribute(PyQt5.QtCore.Qt.WA_DeleteOnClose)
|
||||||
|
errorBox.setText(self.localization.error_read_in)
|
||||||
|
errorBox.setDetailedText(str(e))
|
||||||
|
errorBox.show()
|
||||||
|
return
|
||||||
|
|
||||||
|
waitDialog.close()
|
||||||
|
|
||||||
|
start = self.datapoints[cp.CFG("plot_temperatur_key")].getFirstTime()
|
||||||
|
self.startDateEdit.setDateTime(start)
|
||||||
|
|
||||||
|
end = self.datapoints[cp.CFG("plot_temperatur_key")].getLastTime()
|
||||||
|
self.endDateEdit.setDateTime(end)
|
||||||
|
|
||||||
|
self.buttonGo.setDisabled(False)
|
||||||
|
self.endDateEdit.setReadOnly(False)
|
||||||
|
self.startDateEdit.setReadOnly(False)
|
||||||
|
self.startDateEdit.lineEdit().setDisabled(False)
|
||||||
|
self.endDateEdit.lineEdit().setDisabled(False)
|
||||||
|
self.startTimeEdit.setDisabled(False)
|
||||||
|
self.endTimeEdit.setDisabled(False)
|
||||||
|
|
||||||
|
def selectTargetFile(self):
|
||||||
|
'''Function to select a target-file'''
|
||||||
|
self.targetFileString = QFileDialog.getSaveFileName(self,
|
||||||
|
self.localization.save_file_dialog)[0]
|
||||||
|
if not self.targetFileString:
|
||||||
|
return
|
||||||
|
|
||||||
|
self.buttonTargetFile.setText(self.targetFileString)
|
||||||
|
self.buttonGo.setDisabled(False)
|
||||||
|
|
||||||
|
def useSrcDir(self):
|
||||||
|
'''Function to handle use src dir checkbox'''
|
||||||
|
if self.boxUseSrcDir.isChecked():
|
||||||
|
self.buttonTargetFile.setDisabled(True)
|
||||||
|
if self.srcFileString:
|
||||||
|
self.buttonGo.setDisabled(False)
|
||||||
|
self.srcFileName.setText(self.srcFileString)
|
||||||
|
else:
|
||||||
|
self.buttonTargetFile.setDisabled(False)
|
||||||
|
if self.targetFileString:
|
||||||
|
self.buttonTargetFile.setText(self.targetFileString)
|
||||||
|
else:
|
||||||
|
self.buttonGo.setDisabled(True)
|
||||||
|
|
||||||
|
def openFile(self, button):
|
||||||
|
if button.text() == self.localization.open_pic and self.truePath:
|
||||||
|
print("JES")
|
||||||
|
PyQt5.QtGui.QDesktopServices.openUrl(QUrl.fromLocalFile(self.truePath));
|
||||||
|
else:
|
||||||
|
pass
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
appctxt = ApplicationContext()
|
appctxt = ApplicationContext()
|
||||||
|
|||||||
@@ -19,16 +19,12 @@ import plot_imageutils
|
|||||||
import plot_timeutils
|
import plot_timeutils
|
||||||
|
|
||||||
|
|
||||||
def plot(datapoints,path=None,date1=None,date2=None):
|
def plot(datapoints, path=None, date1=None, date2=None, forcePath=False):
|
||||||
plotname = "" if CFG("name_of_plot") == "None" else CFG("name_of_plot")
|
plotname = "" if CFG("name_of_plot") == "None" else CFG("name_of_plot")
|
||||||
tup = [None,None,plot_timeutils.between_dates,plotname]
|
tup = [None,None,plot_timeutils.between_dates,plotname]
|
||||||
if CFG("enable_multicore_support"):
|
return __plot(tup, datapoints, path, date1, date2, forcePath)
|
||||||
thread = Process(target=__plot,args=(tup,datapoints,date1,date2))
|
|
||||||
thread.start()
|
|
||||||
else:
|
|
||||||
__plot(tup,datapoints,path,date1,date2)
|
|
||||||
|
|
||||||
def __plot(tup,datapoints,path,date1=None,date2=None):
|
def __plot(tup, datapoints, path, date1=None, date2=None, forcePath=False):
|
||||||
NO_SERIES = True
|
NO_SERIES = True
|
||||||
x,y,ymin,ymax,unix_x,major_xticks = ( [] , [], -1 , -1 , [], [] )
|
x,y,ymin,ymax,unix_x,major_xticks = ( [] , [], -1 , -1 , [], [] )
|
||||||
lw = CFG("plot_line_width")
|
lw = CFG("plot_line_width")
|
||||||
@@ -68,7 +64,10 @@ def __plot(tup,datapoints,path,date1=None,date2=None):
|
|||||||
if path == None:
|
if path == None:
|
||||||
path = open_file()
|
path = open_file()
|
||||||
|
|
||||||
pic_path = output_path(path,date1,date2)
|
if not forcePath:
|
||||||
|
pic_path = output_path(path,date1,date2)
|
||||||
|
else:
|
||||||
|
pic_path = path
|
||||||
|
|
||||||
|
|
||||||
## set resoltuion ##
|
## set resoltuion ##
|
||||||
@@ -83,6 +82,8 @@ def __plot(tup,datapoints,path,date1=None,date2=None):
|
|||||||
### do operations on the finished png ###
|
### do operations on the finished png ###
|
||||||
plot_imageutils.check_and_rotate(pic_path)
|
plot_imageutils.check_and_rotate(pic_path)
|
||||||
|
|
||||||
|
return pic_path
|
||||||
|
|
||||||
def output_path(path,date1,date2):
|
def output_path(path,date1,date2):
|
||||||
if date1 != None and date2 == None:
|
if date1 != None and date2 == None:
|
||||||
pic_path = path + "-nach-%s"%date1.strftime("%d.%m.%y") + ".png"
|
pic_path = path + "-nach-%s"%date1.strftime("%d.%m.%y") + ".png"
|
||||||
Reference in New Issue
Block a user