Advertisement
Guest User

Untitled

a guest
Jul 19th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.05 KB | None | 0 0
  1. from PyQt5.QtWidgets import (QApplication, QComboBox, QDialog,
  2.                              QDialogButtonBox, QFormLayout, QGridLayout, QGroupBox, QHBoxLayout,
  3.                              QLabel, QLineEdit, QMenu, QMenuBar, QPushButton, QSpinBox, QTextEdit,
  4.                              QVBoxLayout)
  5.  
  6. import sys
  7. import os
  8. import time
  9. import threading
  10.  
  11.  
  12. class Dialog(QDialog):
  13.     NumGridRows = 3
  14.     NumButtons = 4
  15.  
  16.     def __init__(self):
  17.         super(Dialog, self).__init__()
  18.  
  19.         #Inicnalizacja metod
  20.         self.createGeometry()
  21.         self.createFormGroupBox()
  22.         self.createGridLayout()
  23.  
  24.         buttonBox = QPushButton("Close")
  25.         buttonBox.clicked.connect(self.close)
  26.  
  27.         #Tworzenie layoutu
  28.         mainLayout = QVBoxLayout()
  29.         mainLayout.addWidget(self.formGroupBox)
  30.         mainLayout.addWidget(buttonBox)
  31.  
  32.         self.setLayout(mainLayout)
  33.         self.setWindowTitle("Eden Cam")
  34.  
  35.     def createGeometry(self):
  36.         self.left = 10
  37.         self.top = 10
  38.         self.width = 250
  39.         self.height = 100
  40.         self.setGeometry(self.left, self.top, self.width, self.height)
  41.  
  42.     def startCapture(self):
  43.         number = 0
  44.         controll = True
  45.  
  46.         while controll == True:
  47.             try:
  48.                 print(
  49.                     "raspistill -rot 270 -awb auto -co 10 -sh 20 "
  50.                     "-br 37 -sa 15 -ISO 150 -o image0{}.jpg".format(number))
  51.                 time.sleep(2)
  52.             except self.stopCapture():
  53.                 controll = False
  54.                 break
  55.             finally:
  56.                 number += 1
  57.  
  58.     def stopCapture(self):
  59.         print("Koniec fotografowania")
  60.         return None
  61.  
  62.     def createFormGroupBox(self):
  63.         self.formGroupBox = QGroupBox("Monitoring mode")
  64.  
  65.         #Tworzenie przycisków
  66.         start=QPushButton('Start photo')
  67.         stop=QPushButton('Stop photo')
  68.  
  69.         #Dodanie akcji do przycisków
  70.         start.clicked.connect(self.startCapture)
  71.         stop.clicked.connect(self.stopCapture)
  72.  
  73.         #Tworzenie layoutu
  74.         layout = QFormLayout()
  75.         layout.addWidget(start)
  76.         layout.addWidget(stop)
  77.  
  78.         self.formGroupBox.setLayout(layout)
  79.  
  80.     def createGridLayout(self):
  81.         self.horizontalGroupBox = QGroupBox("Grid")
  82.         layout = QGridLayout()
  83.         layout.setColumnStretch(1, 4)
  84.         layout.setColumnStretch(2, 4)
  85.  
  86.         #Do grid Layoutu można wstawiać tylko QWidgety
  87.         layout.addWidget(QPushButton('1'), 0, 0)
  88.         layout.addWidget(QPushButton('2'), 0, 1)
  89.         layout.addWidget(QPushButton('3'), 0, 2)
  90.         layout.addWidget(QPushButton('4'), 1, 0)
  91.         layout.addWidget(QPushButton('5'), 1, 1)
  92.         layout.addWidget(QPushButton('6'), 1, 2)
  93.         layout.addWidget(QPushButton('7'), 2, 0)
  94.         layout.addWidget(QPushButton('8'), 2, 1)
  95.         layout.addWidget(QPushButton('9'), 2, 2)
  96.  
  97.         self.horizontalGroupBox.setLayout(layout)
  98.  
  99.  
  100. if __name__ == '__main__':
  101.     app = QApplication(sys.argv)
  102.     dialog = Dialog()
  103. sys.exit(dialog.exec_())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement