|
@@ -1,4 +1,6 @@
|
|
from PySide6.QtWidgets import QStackedWidget, QWidget, QLabel, QGridLayout
|
|
from PySide6.QtWidgets import QStackedWidget, QWidget, QLabel, QGridLayout
|
|
|
|
+from PySide6.QtGui import QResizeEvent, QPixmap
|
|
|
|
+from PySide6.QtCore import QSize
|
|
from PySide6.QtMultimediaWidgets import QVideoWidget
|
|
from PySide6.QtMultimediaWidgets import QVideoWidget
|
|
from module.cam.USBCam import load_image
|
|
from module.cam.USBCam import load_image
|
|
import os
|
|
import os
|
|
@@ -8,10 +10,30 @@ class PStackedWidget(QStackedWidget):
|
|
def __init__(self, parent=None, mode='video'):
|
|
def __init__(self, parent=None, mode='video'):
|
|
super(PStackedWidget, self).__init__(parent)
|
|
super(PStackedWidget, self).__init__(parent)
|
|
self.__mode = mode
|
|
self.__mode = mode
|
|
|
|
+ self.resize_state = False
|
|
|
|
|
|
self.__setup_image_stacked()
|
|
self.__setup_image_stacked()
|
|
self.__setup_video_stacked()
|
|
self.__setup_video_stacked()
|
|
self.set_default_image()
|
|
self.set_default_image()
|
|
|
|
+ self.resizeEvent = self.__resize
|
|
|
|
+
|
|
|
|
+ def __resize(self, event: QResizeEvent) -> None:
|
|
|
|
+ self.image.resize(event.size())
|
|
|
|
+ self.video.resize(event.size())
|
|
|
|
+ img = self.image.pixmap().toImage().scaled(
|
|
|
|
+ event.size().width()-20,
|
|
|
|
+ event.size().height()-20
|
|
|
|
+ )
|
|
|
|
+ self.image.setPixmap(QPixmap.fromImage(img))
|
|
|
|
+
|
|
|
|
+ if self.video.__class__.__name__ in 'QLabel':
|
|
|
|
+ img = self.video.pixmap().toImage().scaled(
|
|
|
|
+ event.size().width()-20,
|
|
|
|
+ event.size().height()-20
|
|
|
|
+ )
|
|
|
|
+ self.video.setPixmap(QPixmap.fromImage(img))
|
|
|
|
+
|
|
|
|
+ # print(type(self.video))
|
|
|
|
|
|
def __setup_image_stacked(self) -> None:
|
|
def __setup_image_stacked(self) -> None:
|
|
self.page_image = QWidget()
|
|
self.page_image = QWidget()
|
|
@@ -22,7 +44,7 @@ class PStackedWidget(QStackedWidget):
|
|
|
|
|
|
self.image = QLabel(self.page_image)
|
|
self.image = QLabel(self.page_image)
|
|
self.image.setObjectName("image")
|
|
self.image.setObjectName("image")
|
|
- self.layout_image.addWidget(self.image, 0, 0, 0, 0)
|
|
|
|
|
|
+ self.layout_image.addWidget(self.image)
|
|
|
|
|
|
self.addWidget(self.page_image)
|
|
self.addWidget(self.page_image)
|
|
|
|
|
|
@@ -39,7 +61,7 @@ class PStackedWidget(QStackedWidget):
|
|
self.video = QLabel(self.page_video)
|
|
self.video = QLabel(self.page_video)
|
|
|
|
|
|
self.video.setObjectName("video")
|
|
self.video.setObjectName("video")
|
|
- self.layout_video.addWidget(self.video, 0, 0, 0, 0)
|
|
|
|
|
|
+ self.layout_video.addWidget(self.video)
|
|
|
|
|
|
self.addWidget(self.page_video)
|
|
self.addWidget(self.page_video)
|
|
|
|
|