-
Notifications
You must be signed in to change notification settings - Fork 0
/
QtTest.py
54 lines (40 loc) · 1.41 KB
/
QtTest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
from PyQt5 import QtCore
from PyQt5.QtWidgets import (QApplication, QHBoxLayout, QLabel, QPushButton,
QVBoxLayout, QWidget)
#from picamera2 import Picamera2
#from picamera2.previews.qt import QGlPicamera2
def post_callback(request):
label.setText(''.join(f"{k}: {v}\n" for k, v in request.get_metadata().items()))
#picam2 = Picamera2()
#picam2.post_callback = post_callback
#picam2.configure(picam2.create_preview_configuration(main={"size": (800, 600)}))
app = QApplication([])
def on_button_clicked():
button.setEnabled(False)
#cfg = picam2.create_still_configuration()
#picam2.switch_mode_and_capture_file(cfg, "test.jpg", signal_function=qpicamera2.signal_done)
def capture_done(job):
#picam2.wait(job)
button.setEnabled(True)
def on_mouse_down(event):
pass
#qpicamera2 = QGlPicamera2(picam2, width=800, height=600, keep_ar=False)
button = QPushButton("Click to capture JPEG")
label = QLabel()
window = QWidget()
#qpicamera2.done_signal.connect(capture_done)
button.clicked.connect(on_button_clicked)
label.setFixedWidth(400)
label.setAlignment(QtCore.Qt.AlignTop)
layout_h = QHBoxLayout()
layout_v = QVBoxLayout()
layout_v.addWidget(label)
layout_v.addWidget(button)
#layout_h.addWidget(qpicamera2, 80)
layout_h.addLayout(layout_v, 20)
window.setWindowTitle("Qt Picamera2 App")
window.resize(1200, 600)
window.setLayout(layout_h)
#picam2.start()
window.show()
app.exec()