Exemplo n.º 1
0
class CaptureDialog(QDialog):
    def __init__(self, parent=None):
        QDialog.__init__(self, parent)

        self.parent = parent
        self.data = None
        self.init_ui()

    def init_ui(self):
        self.centralWidget = QtWidgets.QFrame(self)
        self.centralWidget.setObjectName("centralWidget")
        self.centralWidget.setGeometry(QtCore.QRect(0, 0, 600, 600))
        self.centralWidget.setFrameShape(QtWidgets.QFrame.Box)

        self.frame_2 = QtWidgets.QFrame(self.centralWidget)
        self.frame_2.setObjectName("frame_2")
        self.frame_2.setGeometry(QtCore.QRect(10, 10, 580, 580))
        self.frame_2.setFrameShape(QtWidgets.QFrame.Box)
        self.canvas = Canvas(self.frame_2)

        self.canvas.setGeometry(QtCore.QRect(0, 0, 580, 580))
        self.canvas.setEnabled(True)
        self.canvas.setFocus(True)
        self.canvas.setDrawingShapeToSquare(False)
        self.canvas.restoreCursor()
        self.canvas.mode = self.canvas.CREATE
        self.image = None
        self.canvas.show()
        self.canvas.newShape.connect(self.new_shape)

    def new_shape(self):
        """Pop-up and give focus to the label editor.
        position MUST be in global coordinates.
        """
        BB = QDialogButtonBox

        x1, y1, x2, y2 = int(self.canvas.line[0].x()), int(
            self.canvas.line[0].y()), int(self.canvas.line[1].x()), int(
                self.canvas.line[1].y())
        image = self.image[y1:y2, x1:x2]
        self.labelDialog = LabelDialog(parent=self, image=image)

        self.labelDialog.show()
Exemplo n.º 2
0
class Ui_MainWindow(object):
    def setupUi(self, MainWindow):
        MainWindow.setObjectName("MainWindow")
        MainWindow.resize(800, 600)
        MainWindow.setMinimumSize(QtCore.QSize(800, 600))
        MainWindow.setBaseSize(QtCore.QSize(800, 600))
        font = QtGui.QFont()
        font.setFamily("Segoe UI")
        font.setPointSize(10)
        MainWindow.setFont(font)
        MainWindow.setLocale(
            QtCore.QLocale(QtCore.QLocale.Russian, QtCore.QLocale.Russia))
        self.centralwidget = QtWidgets.QWidget(MainWindow)
        self.centralwidget.setObjectName("centralwidget")
        self.horizontalLayout_3 = QtWidgets.QHBoxLayout(self.centralwidget)
        self.horizontalLayout_3.setContentsMargins(10, 10, 10, 0)
        self.horizontalLayout_3.setSpacing(10)
        self.horizontalLayout_3.setObjectName("horizontalLayout_3")
        self.verticalLayout = QtWidgets.QVBoxLayout()
        self.verticalLayout.setObjectName("verticalLayout")
        self.componentList = QtWidgets.QListWidget(self.centralwidget)
        self.componentList.setObjectName("typeList")
        self.componentList.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
        self.verticalLayout.addWidget(self.componentList)
        self.recordList = QtWidgets.QListWidget(self.centralwidget)
        self.recordList.setObjectName("componentList")
        self.recordList.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
        self.verticalLayout.addWidget(self.recordList)
        self.horizontalLayout_3.addLayout(self.verticalLayout)
        self.scrollArea = QtWidgets.QScrollArea(self.centralwidget)
        self.scrollArea.setWidgetResizable(True)
        self.scrollArea.setObjectName("scrollArea")
        self.canvas = Canvas()
        self.canvas.setGeometry(QtCore.QRect(0, 0, 432, 547))
        self.canvas.setObjectName("canvas")
        self.scrollArea.setWidget(self.canvas)
        self.horizontalLayout_3.addWidget(self.scrollArea)
        self.verticalLayout_2 = QtWidgets.QVBoxLayout()
        self.verticalLayout_2.setObjectName("verticalLayout_2")
        self.rectangleList = QtWidgets.QListWidget(self.centralwidget)
        self.rectangleList.setObjectName("objectList")
        self.rectangleList.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
        self.verticalLayout_2.addWidget(self.rectangleList)
        self.shotButton = QtWidgets.QPushButton(self.centralwidget)
        self.shotButton.setObjectName("shotButton")
        self.verticalLayout_2.addWidget(self.shotButton)
        self.saveButton = QtWidgets.QPushButton(self.centralwidget)
        self.saveButton.setObjectName("saveButton")
        self.verticalLayout_2.addWidget(self.saveButton)
        self.horizontalLayout_3.addLayout(self.verticalLayout_2)
        self.horizontalLayout_3.setStretch(0, 3)
        self.horizontalLayout_3.setStretch(1, 8)
        self.horizontalLayout_3.setStretch(2, 3)
        MainWindow.setCentralWidget(self.centralwidget)
        self.menubar = QtWidgets.QMenuBar(MainWindow)
        self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 21))
        self.menubar.setObjectName("menubar")
        self.fileMenu = QtWidgets.QMenu(self.menubar)
        self.fileMenu.setObjectName("fileMenu")
        self.redactorMenu = QtWidgets.QMenu(self.menubar)
        self.redactorMenu.setObjectName("redactorMenu")
        self.modeMenu = QtWidgets.QMenu(self.redactorMenu)
        self.modeMenu.setObjectName("modeMenu")
        self.databaseMenu = QtWidgets.QMenu(self.menubar)
        self.databaseMenu.setObjectName("databaseMenu")
        MainWindow.setMenuBar(self.menubar)
        self.statusbar = QtWidgets.QStatusBar(MainWindow)
        self.statusbar.setObjectName("statusbar")
        MainWindow.setStatusBar(self.statusbar)
        self.saveAll = QtWidgets.QAction(MainWindow)
        self.saveAll.setObjectName("saveAll")
        self.modeSelect = QtWidgets.QAction(MainWindow)
        self.modeSelect.setCheckable(True)
        self.modeSelect.setObjectName("modeSelect")
        self.modeEdit = QtWidgets.QAction(MainWindow)
        self.modeEdit.setCheckable(True)
        self.modeEdit.setObjectName("modeEdit")
        self.addClass = QtWidgets.QAction(MainWindow)
        self.addClass.setObjectName("addClass")
        self.addClass.setStatusTip("Add new class")
        self.addImage = QtWidgets.QAction(MainWindow)
        self.addImage.setObjectName("addImage")
        self.addImage.setStatusTip("Add current frame as class\'s image")
        self.fileMenu.addAction(self.saveAll)
        self.modeMenu.addAction(self.modeSelect)
        self.modeMenu.addAction(self.modeEdit)
        self.databaseMenu.addAction(self.addClass)
        self.databaseMenu.addAction(self.addImage)
        self.redactorMenu.addAction(self.modeMenu.menuAction())
        self.menubar.addAction(self.fileMenu.menuAction())
        self.menubar.addAction(self.redactorMenu.menuAction())
        self.menubar.addAction(self.databaseMenu.menuAction())

        self.retranslateUi(MainWindow)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)

    def retranslateUi(self, MainWindow):
        _translate = QtCore.QCoreApplication.translate
        MainWindow.setWindowTitle(_translate("MainWindow", "Edit database"))
        self.shotButton.setText(_translate("MainWindow", "Shot"))
        self.saveButton.setText(_translate("MainWindow", "Save"))
        self.fileMenu.setTitle(_translate("MainWindow", "File"))
        self.redactorMenu.setTitle(_translate("MainWindow", "Editor"))
        self.modeMenu.setTitle(_translate("MainWindow", "Mode"))
        self.databaseMenu.setTitle(_translate("MainWindow", "Database"))
        self.saveAll.setText(_translate("MainWindow",
                                        "Apply changes and save"))
        self.modeSelect.setText(_translate("MainWindow", "Select"))
        self.modeEdit.setText(_translate("MainWindow", "Edit"))
        self.addClass.setText(_translate("MainWindow", "Add class"))
        self.addImage.setText(_translate("MainWindow", "Add class image"))