DMX caputre/playback software
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

103 lines
3.3 KiB

import sys
from PyQt5.QtWidgets import QApplication, QMainWindow, QPushButton, QWidget, QVBoxLayout, QLabel
from PyQt5.QtCore import Qt
from PyQt5.QtGui import QImage, QPixmap, qRgb
from dmx import DMXRecorder
class MainWindow(QMainWindow):
def __init__(self):
super().__init__()
self.initUI()
self.isRecording = False
self.recorder = None
def initUI(self):
self.setWindowTitle("DMX Recorder")
self.resize(300, 400)
# Use dark theme
self.setStyleSheet('''
QWidget {
background-color: #222222;
color: #FFFFFF;
}
QSlider::groove:horizontal {
border: 1px solid #444444;
height: 8px;
background: #555555;
}
QSlider::handle:horizontal {
background: #888888;
border: 1px solid #444444;
width: 18px;
margin: -8px 0;
}
QLineEdit {
background-color: #333333;
border: 1px solid #555555;
color: #FFFFFF;
padding: 4px;
}
QPushButton {
background-color: #444444;
border: 1px solid #666666;
padding: 6px;
}
QPushButton:hover {
background-color: #555555;
}
QLabel {
color: #FFFFFF;
}
''')
self.central_widget = QWidget()
self.setCentralWidget(self.central_widget)
self.layout = QVBoxLayout()
self.central_widget.setLayout(self.layout)
self.record_button = QPushButton("Record")
self.record_button.clicked.connect(self.toggle_recording)
self.video_label = QLabel()
self.video_label.setAlignment(Qt.AlignCenter)
self.layout.addWidget(self.video_label)
self.layout.addWidget(self.record_button)
def toggle_recording(self):
if not self.isRecording:
# Start recording
self.recorder = DMXRecorder()
self.recorder.frame_ready.connect(self.update_frame)
self.recorder.start_recording()
self.record_button.setText("Stop")
self.isRecording = True
else:
# Stop recording
if self.recorder:
self.recorder.frame_ready.disconnect(self.update_frame)
self.recorder.stop_recording()
self.recorder = None
self.record_button.setText("Record")
self.isRecording = False
def update_frame(self, frame_array):
# Convert the numpy array to QImage and display
height, width = frame_array.shape
# Convert the numpy array to QImage
q_img = QImage(frame_array.data, width, height, width, QImage.Format_Indexed8)
# Create a grayscale color table
color_table = [qRgb(i, i, i) for i in range(256)]
q_img.setColorTable(color_table)
# Scale image to fit the label
pixmap = QPixmap.fromImage(q_img).scaled(self.video_label.width(), self.video_label.height(), Qt.KeepAspectRatio)
# Set the pixmap to the label
self.video_label.setPixmap(pixmap)
if __name__ == '__main__':
app = QApplication(sys.argv)
window = MainWindow()
window.show()
sys.exit(app.exec_())