Commit 7b1451e5 authored by AJ Fite's avatar AJ Fite 🛫

Pretty much done enabling/disabling UI elements

parent e149a9a3
......@@ -48,34 +48,73 @@
</widget>
</item>
<item row="3" column="2">
<widget class="QGraphicsView" name="graphicsView_7"/>
<widget class="QGraphicsView" name="imgSE">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QGraphicsView" name="graphicsView_5"/>
<widget class="QGraphicsView" name="imgN">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QGraphicsView" name="graphicsView_8"/>
<widget class="QGraphicsView" name="imgS">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QGraphicsView" name="graphicsView_4"/>
<widget class="QGraphicsView" name="imgCenter">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QGraphicsView" name="graphicsView_2"/>
<widget class="QGraphicsView" name="imgW">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QGraphicsView" name="graphicsView_6"/>
<widget class="QGraphicsView" name="imgNE">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QGraphicsView" name="graphicsView_3"/>
<widget class="QGraphicsView" name="imgSW">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QGraphicsView" name="graphicsView"/>
<widget class="QGraphicsView" name="imgNW">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QGraphicsView" name="graphicsView_9"/>
<widget class="QGraphicsView" name="imgE">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QProgressBar" name="progressBar">
<widget class="QProgressBar" name="capProgress">
<property name="enabled">
<bool>false</bool>
</property>
<property name="value">
<number>0</number>
</property>
......@@ -83,12 +122,21 @@
</item>
<item row="6" column="2">
<widget class="QLCDNumber" name="solarIrradiance">
<property name="enabled">
<bool>false</bool>
</property>
<property name="minimumSize">
<size>
<width>70</width>
<height>30</height>
</size>
</property>
<property name="smallDecimalPoint">
<bool>false</bool>
</property>
<property name="segmentStyle">
<enum>QLCDNumber::Filled</enum>
</property>
</widget>
</item>
<item row="7" column="0" colspan="3">
......@@ -112,28 +160,60 @@
</widget>
</item>
<item row="5" column="1">
<widget class="QLabel" name="label_2">
<widget class="QLabel" name="capProgressLabel">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Capture Progress</string>
</property>
</widget>
</item>
<item row="5" column="2">
<widget class="QLabel" name="label_3">
<widget class="QLabel" name="solarIrradianceLabel">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Solar Irradiance</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_4">
<widget class="QLabel" name="cameraCountLabel">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Camera Count</string>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLCDNumber" name="cameraCount"/>
<widget class="QLCDNumber" name="cameraCount">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item row="8" column="2">
<widget class="QLabel" name="statusLabel">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="autoFillBackground">
<bool>true</bool>
</property>
<property name="text">
<string>Status: Stopped</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</item>
......
from watchdog.events import PatternMatchingEventHandler
from datetime import date
# Computes where the lepton grabber is currently dumping output
class FileHandlerUtils:
@staticmethod
......
......@@ -14,11 +14,11 @@ from config import Config, ConfigEditor
class MainWindow(QMainWindow):
simfProcess = QProcess()
observer = Observer()
periodic = None # thread pointer for the status bar
def __init__(self):
super().__init__(flags=Qt.Window)
uic.loadUi('MainWindow.ui', self)
self.show()
self.passprompt = None
self.configdialog = None
......@@ -45,6 +45,9 @@ class MainWindow(QMainWindow):
self.simfProcess.started.connect(self.process_started)
self.simfProcess.finished.connect(self.process_finished)
# Ready to show the UI!
self.show()
# Opens a link
@staticmethod
def open_link(link):
......@@ -53,7 +56,7 @@ class MainWindow(QMainWindow):
# Triggered when window closes, I know it isn't PEP8 compliant but thats
# the way pyqt5 is
def closeEvent(self, QCloseEvent):
self.simfProcess.kill()
self.simfProcess.kill() # Cleanly kill the simfprocess
self.close()
def show_about(self):
......@@ -62,9 +65,33 @@ class MainWindow(QMainWindow):
def show_settings(self):
self.configdialog = ConfigEditor()
# Toggle all the enable/disable options
# status=true lepton-grabber process running
# status=false lepton-grabber process stopped
# sorry
def button_toggle(self, status):
self.capProgress.setEnabled(status)
self.cameraCount.setEnabled(status)
self.solarIrradiance.setEnabled(status)
self.startCapButton.setDisabled(status)
self.stopCapButton.setEnabled(status)
self.capProgressLabel.setEnabled(status)
self.cameraCountLabel.setEnabled(status)
self.solarIrradianceLabel.setEnabled(status)
self.imgN.setEnabled(status)
self.imgNE.setEnabled(status)
self.imgE.setEnabled(status)
self.imgSE.setEnabled(status)
self.imgS.setEnabled(status)
self.imgSW.setEnabled(status)
self.imgW.setEnabled(status)
self.imgNW.setEnabled(status)
self.imgCenter.setEnabled(status)
# Triggered when the QProcess that runs the lepton-grabber runs
def process_started(self):
self.startCapButton.setDisabled(True)
self.stopCapButton.setEnabled(True)
self.statusLabel.setText("Status: Capturing")
self.button_toggle(True)
# Start the file observers
if not self.observer.is_alive():
......@@ -79,9 +106,12 @@ class MainWindow(QMainWindow):
os.mkdir(datadir)
self.observer.schedule(filehandlers.ImageHandler(self), path=datadir)
# Triggered when the QProcess that runs the lepton-grabber dies for any
# reason
def process_finished(self):
self.startCapButton.setEnabled(True)
self.stopCapButton.setDisabled(True)
self.statusLabel.setText("Status: Stopped")
self.button_toggle(False)
self.console_write()
self.console_write_line("Capture Ended")
......@@ -102,7 +132,6 @@ class MainWindow(QMainWindow):
# Event handle fired when there is new stdout or stderr from SIMF
def console_write(self):
print('Read input!')
output = str(self.simfProcess.readAll(), encoding='utf-8')
self.console_write_line(output)
......@@ -149,7 +178,7 @@ class MainWindow(QMainWindow):
self.simfProcess.kill() # Kill the capture subprocess
# Main Function
# Main Function for the whole thing
if __name__ == '__main__':
config = Config()
app = QApplication(sys.argv)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment