瀏覽代碼

fix bug and change version

Алексей Сидоров 1 年之前
父節點
當前提交
a972c8f809
共有 3 個文件被更改,包括 17 次插入27 次删除
  1. 1 4
      init_var.py
  2. 8 10
      module/cam/USBCam.py
  3. 8 13
      window/MainWindow.py

+ 1 - 4
init_var.py

@@ -5,20 +5,17 @@ from dotenv import load_dotenv
 from window.DialogCustomVariables import DialogCustomVariables
 
 
-__VERSION = "ver 0.3 beta"
 DEFAULT_PATH = os.path.join(appdirs.user_data_dir(), "propusk")
 DEFAULT_PATH_PHOTO = os.path.join(DEFAULT_PATH, "photo")
 
 no_media = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'image', 'no_media_main.jpg')
 os.environ.update({
-    'VERSION': __VERSION,
+    'VERSION': "ver 0.4 beta",
     'ABSOLUTE_PATH': os.path.dirname(os.path.abspath(__file__)),
     'NO_MEDIA_IMAGE': no_media,
     'INDEX_PHOTO': '0',
     'INDEX_CAMERA': '1'
 })
-# os.environ['DEFAULT_PATH'] = DEFAULT_PATH
-# os.environ['PHOTO_DIR'] = DEFAULT_PATH_PHOTO
 
 def load_variables():
     # Load variable from .env

+ 8 - 10
module/cam/USBCam.py

@@ -24,17 +24,17 @@ class USBCam:
     _image_capture: QImageCapture
     _current_preview = QImage()
     _label: QLabel
-    
+
     def __init__(self, q_Video_Widget: QVideoWidget, name_cam: str) -> None:
         self._create_dirs()
         self._video_widget = q_Video_Widget
 
         self._camera_info = get_object_cam_by_name(name_cam)
         if not self._camera_info:
-            logger.error("Не нашли камеру QMediaDevices.videoInputs(). убидитесь, что у вас есть камера")
+            logger.error(
+                "Не нашли камеру QMediaDevices.videoInputs(). убидитесь, что у вас есть камера")
             raise IndexError(
                 "Не нашли камеру QMediaDevices.videoInputs(). убидитесь, что у вас есть камера")
-        
 
     def start_cam(self):
         self._camera = QCamera(self._camera_info)
@@ -44,7 +44,7 @@ class USBCam:
         self._image_capture.imageCaptured.connect(self.image_captured)
         self._image_capture.imageSaved.connect(self.image_saved)
         self._image_capture.errorOccurred.connect(self._capture_error)
-        
+
         self._capture_session = QMediaCaptureSession()
         self._capture_session.setCamera(self._camera)
         self._capture_session.setImageCapture(self._image_capture)
@@ -70,7 +70,7 @@ class USBCam:
         self._file_name = create_filename()
         self._image_capture.captureToFile(self._file_name)
         logger.info(F"Создаем файл {self._file_name}")
-        
+
         return self._file_name
 
     @Slot(int, QImageCapture.Error, str)
@@ -91,11 +91,8 @@ class USBCam:
 
     @Slot(int, str)
     def image_saved(self, id, fileName):
-       load_image(self._label, fileName)
-       self.stop_cam()
-
-        
-
+        load_image(self._label, fileName)
+        self.stop_cam()
 
 
 def load_image(qlabel: QLabel, path_file: str) -> None:
@@ -113,5 +110,6 @@ def get_list_name_cam() -> list:
         [x.description() for x in QMediaDevices.videoInputs()]
     )]
 
+
 def get_object_cam_by_name(name_cam: str) -> QMediaDevices:
     return [x for x in QMediaDevices.videoInputs() if x.description() == name_cam][0]

+ 8 - 13
window/MainWindow.py

@@ -19,7 +19,6 @@ from .DialogAbout import DialogAbout
 from .DialogHistory import DialogHistory
 
 
-from time import sleep
 from datetime import datetime
 from logger import logger
 from pathlib import Path
@@ -50,7 +49,6 @@ class MainWindow(QMainWindow, Ui_MainWindow):
             self.change_tab
         )
 
-
     def __init_menu_action(self) -> None:
         self.action_open_history.triggered.connect(self.open_history)
         self.btn_show_personal_window.triggered.connect(
@@ -108,8 +106,6 @@ class MainWindow(QMainWindow, Ui_MainWindow):
         self.__check_setting_cam()
         if self.tabWidget.currentIndex() == 1:
             self.__mode = 'video'
-            
-        
 
     def __check_setting_cam(self) -> None:
         try:
@@ -193,7 +189,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
             widget.to_video()
             self.__create_wwc(widget, cam)
             self.btn_start_cam.setText(stop_cam)
-            
+
         else:
             self.__stop_cam()
             widget.to_image()
@@ -233,7 +229,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
             "date_from": self.date_from.dateTime().toString('dd.MM.yyyy hh:mm'),
             "date_to": self.date_to.dateTime().toString('dd.MM.yyyy hh:mm'),
             "face": self.__file_name_face,
-            "document": self.__file_name_face
+            "document": self.__file_name_document
         })
 
         render_text = TemplatePropusk(
@@ -284,13 +280,12 @@ class MainWindow(QMainWindow, Ui_MainWindow):
 
         if self.__wwc is not None:
             self.__stop_cam()
-        
-        
+
         self.stacked_document.to_image()
         self.stacked_face.to_image()
         load_image(self.stacked_document, os.environ.get('NO_MEDIA_IMAGE'))
         load_image(self.stacked_face, os.environ.get('NO_MEDIA_IMAGE'))
-            
+
         self.receiving_man.clear()
         self.purpose_visite.clear()
 
@@ -298,22 +293,22 @@ class MainWindow(QMainWindow, Ui_MainWindow):
         if self.__wwc is not None:
             self.__wwc.stop_cam()
             self.__wwc = None
-            
+
         self.btn_start_cam.setText(start_cam)
 
     def __create_widget_face_cam(self) -> None:
         self.gridLayout.removeWidget(self.stacked_face)
-            
+
         self.stacked_face = create_widget_stacked(
             name_object=u'stacked_face',
             obj=self.tab,
             layout=self.gridLayout,
             mode=self.__mode)
-        
+
         self.stacked_face.currentChanged.connect(
             self.__change_text_btn
         )
-    
+
     def __change_text_btn(self) -> None:
         if self.stacked_face.currentIndex() == 0:
             self.btn_start_cam.setText(stop_cam)