Browse Source

fix check cam

Alex Sidorov 1 year ago
parent
commit
f179072ead
2 changed files with 17 additions and 8 deletions
  1. 1 2
      module/cam/IPCam.py
  2. 16 6
      window/MainWindow.py

+ 1 - 2
module/cam/IPCam.py

@@ -2,7 +2,6 @@ from PySide6.QtWidgets import QLabel
 from PySide6.QtCore import Qt
 from threading import Thread
 from PySide6.QtGui import QImage, QPixmap
-from PySide6.QtWidgets import QMessageBox
 import cv2
 from module.ImageTool import create_filename
 from logger import logger
@@ -68,7 +67,7 @@ class IPCam(Thread):
         logger.info("stop take image from ip cam")
         self.cap.release()
         self.status = False
-        # cv2.destroyAllWindows()
+        cv2.destroyAllWindows()
         self.join()
 
     def cupture_image(self, qLabel: QLabel) -> str:

+ 16 - 6
window/MainWindow.py

@@ -1,4 +1,4 @@
-from PySide6.QtWidgets import QMainWindow, QMessageBox
+from PySide6.QtWidgets import QMainWindow, QMessageBox, QApplication
 from PySide6.QtCore import QDate, QDateTime
 
 from module.WorkWithDB import *
@@ -8,6 +8,7 @@ from module.Printer import Printer
 from module.lang.ru import *
 from module.cam import IPCam, USBCam, load_image
 
+
 from widgets import PStackedWidget, create_widget_stacked
 
 from .ui_py.ui_MainWindow import Ui_MainWindow
@@ -22,18 +23,19 @@ from time import sleep
 from datetime import datetime
 from logger import logger
 from pathlib import Path
-
+import sys
 
 vecrot_cam_from_db = [str, str, str]
 
 
 class MainWindow(QMainWindow, Ui_MainWindow):
     def __init__(self, parent=None) -> None:
+        
         super(MainWindow, self).__init__(parent)
         self.setupUi(self)
         self.__wwc = None
         self.data_propusk = None
-
+        self._parent=parent
         self.date_from.setDateTime(QDateTime().currentDateTime())
         self.date_to.setDateTime(QDateTime().currentDateTime())
 
@@ -126,6 +128,10 @@ class MainWindow(QMainWindow, Ui_MainWindow):
                 self.__check_setting_cam()
             else:
                 self.close()
+        except TypeError:
+            logger.warning(warring_cams.get("title"))
+
+        
 
     def __update_list_combobox(self) -> None:
         self.__load_personal()
@@ -172,11 +178,15 @@ class MainWindow(QMainWindow, Ui_MainWindow):
                 return cam[0].mode, cam[0].selected_cam, cam[1].selected_cam
             except:
                 logger.error('Нет записи о камерах')
-                show_dialog(
+                if show_dialog(
                     QMessageBox.Icon.Critical,
-                    'Отсутствуют записи о камерах',
+                    'Камера',
                     'Отсутствуют записи о камерах'
-                )
+                ):
+                    self.__show_setting_cam_window()
+                    self.__check_setting_cam()
+                else:
+                    sys.exit(0)
 
     def __press_btn_start_cam(self):
         match self.tabWidget.currentIndex():