def setUp(self):
     super(QPixmapQDatastream, self).setUp()
     self.source_pixmap = QPixmap(100, 100)
     self.source_pixmap.fill(Qt.red)
     self.output_pixmap = QPixmap()
     self.buffer = QByteArray()
     self.read_stream = QDataStream(self.buffer, QIODevice.ReadOnly)
     self.write_stream = QDataStream(self.buffer, QIODevice.WriteOnly)
    def testWithKey(self):
        pm1 = QPixmap()
        ok = QPixmapCache.find(QPixmapCache.Key(), pm1)
        self.assertFalse(ok)

        self.assertEqual(QPixmapCache.find(QPixmapCache.Key()), None)

        pm2 = QPixmap()
        key = QPixmapCache.insert(pm2)

        pm3 = QPixmap()
        ok = QPixmapCache.find(key, pm3)
        self.assertTrue(ok)

        self.assertEqual(QPixmapCache.find(key).toImage().bits(), pm3.toImage().bits())
Beispiel #3
0
    def __init__(self, previewImage, fileName):
        super(ImageView, self).__init__()

        self.fileName = fileName

        mainLayout = QVBoxLayout(self)
        self.imageLabel = QLabel()
        self.imageLabel.setPixmap(QPixmap.fromImage(previewImage))
        mainLayout.addWidget(self.imageLabel)

        topLayout = QHBoxLayout()
        self.fileNameLabel = QLabel(QDir.toNativeSeparators(fileName))
        self.fileNameLabel.setTextInteractionFlags(Qt.TextBrowserInteraction)

        topLayout.addWidget(self.fileNameLabel)
        topLayout.addStretch()
        copyButton = QPushButton("Copy")
        copyButton.setToolTip("Copy file name to clipboard")
        topLayout.addWidget(copyButton)
        copyButton.clicked.connect(self.copy)
        launchButton = QPushButton("Launch")
        launchButton.setToolTip("Launch image viewer")
        topLayout.addWidget(launchButton)
        launchButton.clicked.connect(self.launch)
        mainLayout.addLayout(topLayout)
Beispiel #4
0
 def tick(self):
     self.game.tick()
     bitmap = self.game.visualize()
     image = QImage(bitmap.data, bitmap.shape[1], bitmap.shape[0], QImage.Format_Grayscale8)
     self.scene.removeItem(self.item)
     pixmap = QPixmap.fromImage(image)
     self.item = self.scene.addPixmap(pixmap)
Beispiel #5
0
    def generateAndExportClicked(self):

        g = Generator()
        g.tileWidth = self.tileWidthSpinBox.value()
        g.tileHeight = self.tileHeightSpinBox.value()
        g.forcePot = self.forcePotCheckBox.isChecked()
        g.isTransparent = self.transparentCheckbox.isChecked()
        g.bgColor = self.backgroundColorEdit.getColor()
        g.reorder = self.reorderTilesCheckBox.isChecked()
        g.padding = self.paddingSpinBox.value()

        target = g.create(self.pixmapWidget.pixmap);

        # export
        self.lastDir = os.path.dirname(self.path)
        targetPath = QFileDialog.getSaveFileName(self, 'Export', self.lastDir, 'PNG (*.png)')
        if targetPath:
            target.save(targetPath[0])
            showPixmap = QPixmap.fromImage(target)
            if self.showPixmapWidget:
                self.showPixmapWidget.deleteLater()
                del self.showPixmapWidget
            self.showPixmapWidget = PixmapWidget()
            self.showPixmapWidget.setWindowIcon(self.windowIcon())
            self.showPixmapWidget.setWindowTitle(os.path.basename(targetPath[0]))
            self.showPixmapWidget.resize(showPixmap.width(), showPixmap.height())
            self.showPixmapWidget.setPixmap(showPixmap)
            self.showPixmapWidget.show()
Beispiel #6
0
 def createDropTextPixmap(self):
     pixmap = QPixmap(481, 300)
     pixmap.fill(QColor("#333333"))
     painter = QPainter(pixmap)
     font = QFont("Arial")
     font.setPixelSize(28)
     font.setBold(True)
     fm = QFontMetrics(font)
     painter.setFont(font)
     painter.setPen(QPen(QColor("#888888"), 1))
     text = "Drop the tileset image here"
     x = (pixmap.width()-fm.width(text))/2
     y = (pixmap.height()+fm.height())/2
     painter.drawText(x, y, text)
     del painter
     return pixmap
    def testWithString(self):
        pm1 = QPixmap()
        ok = QPixmapCache.find('img', pm1)
        self.assertFalse(ok)

        self.assertEqual(QPixmapCache.find('img'), None)

        pm2 = QPixmap()
        ok = QPixmapCache.insert('img', pm2)
        self.assertTrue(ok)

        pm3 = QPixmap()
        ok = QPixmapCache.find('img', pm3)
        self.assertTrue(ok)
        b1 = QPixmapCache.find('img').toImage().bits()
        b2 = pm3.toImage().bits()
        self.assertEqual(QPixmapCache.find('img').toImage().bits(), pm3.toImage().bits())
Beispiel #8
0
    def updatePixmap(self, image, scaleFactor):
        if not self.lastDragPos.isNull():
            return

        self.pixmap = QPixmap.fromImage(image)
        self.pixmapOffset = QPoint()
        self.lastDragPosition = QPoint()
        self.pixmapScale = scaleFactor
        self.update()
Beispiel #9
0
 def fileDropped(self, path):
     path = str(path)
     name, ext = os.path.splitext(path)
     ext = ext[1:]
     if not ext in self.supportedFormats:
         QMessageBox.warning(self, "Warning", "The dropped file is not supported")
         return
     pixmap = QPixmap(path)
     if pixmap.isNull():
         QMessageBox.warning(self, "Warning", "Can't load the image")
         return
     if self.path:
         self.fileWatcher.removePath(self.path)
     self.path = path
     self.fileWatcher.addPath(self.path)
     self.pixmapWidget.setPixmap(pixmap)
     self.generateAndExportButton.setEnabled(True)
     self.setTitle()
     self.activateWindow()
class QPixmapQDatastream(UsesQApplication):
    '''QDataStream <<>> QPixmap'''

    def setUp(self):
        super(QPixmapQDatastream, self).setUp()
        self.source_pixmap = QPixmap(100, 100)
        self.source_pixmap.fill(Qt.red)
        self.output_pixmap = QPixmap()
        self.buffer = QByteArray()
        self.read_stream = QDataStream(self.buffer, QIODevice.ReadOnly)
        self.write_stream = QDataStream(self.buffer, QIODevice.WriteOnly)

    def testStream(self):
        self.write_stream << self.source_pixmap

        self.read_stream >> self.output_pixmap

        image = self.output_pixmap.toImage()
        pixel = image.pixel(10,10)
        self.assertEqual(pixel, QColor(Qt.red).rgba())
        self.assertEqual(self.source_pixmap.toImage(), self.output_pixmap.toImage())
Beispiel #11
0
    def __init__(self, parent=None):
        super(RenderArea, self).__init__(parent)

        self.pen = QPen()
        self.brush = QBrush()
        self.pixmap = QPixmap()

        self.shape = RenderArea.Polygon
        self.antialiased = False
        self.transformed = False
        self.pixmap.load(':/images/qt-logo.png')

        self.setBackgroundRole(QPalette.Base)
        self.setAutoFillBackground(True)
Beispiel #12
0
    def __init__(self, parent=None):
        super(MandelbrotWidget, self).__init__(parent)

        self.thread = RenderThread()
        self.pixmap = QPixmap()
        self.pixmapOffset = QPoint()
        self.lastDragPos = QPoint()

        self.centerX = DefaultCenterX
        self.centerY = DefaultCenterY
        self.pixmapScale = DefaultScale
        self.curScale = DefaultScale

        self.thread.renderedImage.connect(self.updatePixmap)

        self.setWindowTitle("Mandelbrot")
        self.setCursor(Qt.CrossCursor)
        self.resize(550, 400)
Beispiel #13
0
 def testQPixmapConstructor(self):
     label = QLabel()
     pixmap1 = QPixmap(xpm)
     self.assertFalse(pixmap1.isNull())
     self.assertEqual(pixmap1.width(), 27)
     self.assertEqual(pixmap1.height(), 22)
Beispiel #14
0
 def retuenicon(self, name):
     return QIcon(
         QPixmap(
             os.path.normpath(
                 os.path.join(os.path.dirname(os.path.realpath(__file__)),
                              '', name + '.png'))))
Beispiel #15
0
class MandelbrotWidget(QWidget):
    def __init__(self, parent=None):
        super(MandelbrotWidget, self).__init__(parent)

        self.thread = RenderThread()
        self.pixmap = QPixmap()
        self.pixmapOffset = QPoint()
        self.lastDragPos = QPoint()

        self.centerX = DefaultCenterX
        self.centerY = DefaultCenterY
        self.pixmapScale = DefaultScale
        self.curScale = DefaultScale

        self.thread.renderedImage.connect(self.updatePixmap)

        self.setWindowTitle("Mandelbrot")
        self.setCursor(Qt.CrossCursor)
        self.resize(550, 400)

    def paintEvent(self, event):
        painter = QPainter(self)
        painter.fillRect(self.rect(), Qt.black)

        if self.pixmap.isNull():
            painter.setPen(Qt.white)
            painter.drawText(self.rect(), Qt.AlignCenter,
                    "Rendering initial image, please wait...")
            return

        if self.curScale == self.pixmapScale:
            painter.drawPixmap(self.pixmapOffset, self.pixmap)
        else:
            scaleFactor = self.pixmapScale / self.curScale
            newWidth = int(self.pixmap.width() * scaleFactor)
            newHeight = int(self.pixmap.height() * scaleFactor)
            newX = self.pixmapOffset.x() + (self.pixmap.width() - newWidth) / 2
            newY = self.pixmapOffset.y() + (self.pixmap.height() - newHeight) / 2

            painter.save()
            painter.translate(newX, newY)
            painter.scale(scaleFactor, scaleFactor)
            exposed, _ = painter.matrix().inverted()
            exposed = exposed.mapRect(self.rect()).adjusted(-1, -1, 1, 1)
            painter.drawPixmap(exposed, self.pixmap, exposed)
            painter.restore()

        text = "Use mouse wheel or the '+' and '-' keys to zoom. Press and " \
                "hold left mouse button to scroll."
        metrics = painter.fontMetrics()
        textWidth = metrics.width(text)

        painter.setPen(Qt.NoPen)
        painter.setBrush(QColor(0, 0, 0, 127))
        painter.drawRect((self.width() - textWidth) / 2 - 5, 0, textWidth + 10,
                metrics.lineSpacing() + 5)
        painter.setPen(Qt.white)
        painter.drawText((self.width() - textWidth) / 2,
                metrics.leading() + metrics.ascent(), text)

    def resizeEvent(self, event):
        self.thread.render(self.centerX, self.centerY, self.curScale, self.size())

    def keyPressEvent(self, event):
        if event.key() == Qt.Key_Plus:
            self.zoom(ZoomInFactor)
        elif event.key() == Qt.Key_Minus:
            self.zoom(ZoomOutFactor)
        elif event.key() == Qt.Key_Left:
            self.scroll(-ScrollStep, 0)
        elif event.key() == Qt.Key_Right:
            self.scroll(+ScrollStep, 0)
        elif event.key() == Qt.Key_Down:
            self.scroll(0, -ScrollStep)
        elif event.key() == Qt.Key_Up:
            self.scroll(0, +ScrollStep)
        else:
            super(MandelbrotWidget, self).keyPressEvent(event)

    def wheelEvent(self, event):
        numDegrees = event.angleDelta().y() / 8
        numSteps = numDegrees / 15.0
        self.zoom(pow(ZoomInFactor, numSteps))

    def mousePressEvent(self, event):
        if event.buttons() == Qt.LeftButton:
            self.lastDragPos = QPoint(event.pos())

    def mouseMoveEvent(self, event):
        if event.buttons() & Qt.LeftButton:
            self.pixmapOffset += event.pos() - self.lastDragPos
            self.lastDragPos = QPoint(event.pos())
            self.update()

    def mouseReleaseEvent(self, event):
        if event.button() == Qt.LeftButton:
            self.pixmapOffset += event.pos() - self.lastDragPos
            self.lastDragPos = QPoint()

            deltaX = (self.width() - self.pixmap.width()) / 2 - self.pixmapOffset.x()
            deltaY = (self.height() - self.pixmap.height()) / 2 - self.pixmapOffset.y()
            self.scroll(deltaX, deltaY)

    def updatePixmap(self, image, scaleFactor):
        if not self.lastDragPos.isNull():
            return

        self.pixmap = QPixmap.fromImage(image)
        self.pixmapOffset = QPoint()
        self.lastDragPosition = QPoint()
        self.pixmapScale = scaleFactor
        self.update()

    def zoom(self, zoomFactor):
        self.curScale *= zoomFactor
        self.update()
        self.thread.render(self.centerX, self.centerY, self.curScale,
                self.size())

    def scroll(self, deltaX, deltaY):
        self.centerX += deltaX * self.curScale
        self.centerY += deltaY * self.curScale
        self.update()
        self.thread.render(self.centerX, self.centerY, self.curScale,
                self.size())
Beispiel #16
0
	def preview_card(self, card_dict):

		pixmap = QPixmap()
		pixmap.loadFromData(self.card_catalog.retrieve_card_image(card_dict).content)
		self.ui.card_preview.setPixmap(pixmap)
		self.ui.card_preview.setScaledContents(True)
Beispiel #17
0
 def changeHeatMapdisplay(self):
     if self.heatMapIndex is not None:
         hmc.plot_pressure(self.df, self.heatMapIndex)
         self.heatMap.setPixmap(QPixmap("pics/HM{index}.svg".format(index=self.heatMapIndex)))
     else:
         self.heatMap.setText("ERROR: NO DATA FOUND")
Beispiel #18
0
 def setImage(self, image):
     self.image2.setPixmap(QPixmap.fromImage(image))
Beispiel #19
0
    def update_screen(self):
        self.story_box.setText(self.storyText[self.scene])

        image = QPixmap("images/image_{}.jpg".format(self.scene))
        self.story_image.setPixmap(image)
Beispiel #20
0
    def __init__(self):
        super().__init__()

        w = QWidget()

        hb = QHBoxLayout()
        hb.setSizeConstraint(QLayout.SetFixedSize)

        self._timer = QTimer()
        self._timer.timeout.connect(self.update_timer)
        self._timer.start(1000)  # 1 second timer

        # tag::status[]
        self.mines = QLabel()
        self.mines.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter)

        self.clock = QLabel()
        self.clock.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter)

        f = self.mines.font()
        f.setPointSize(24)
        f.setWeight(75)
        self.mines.setFont(f)
        self.clock.setFont(f)

        self.clock.setText("000")

        self.button = QPushButton()
        self.button.setFixedSize(QSize(32, 32))
        self.button.setIconSize(QSize(32, 32))
        self.button.setIcon(QIcon("./icons/smiley.png"))
        self.button.setFlat(True)

        self.button.pressed.connect(self.button_pressed)

        self.statusBar()

        l = QLabel()
        l.setPixmap(QPixmap.fromImage(IMG_BOMB))
        l.setAlignment(Qt.AlignRight | Qt.AlignVCenter)
        hb.addWidget(l)

        hb.addWidget(self.mines)
        hb.addWidget(self.button)
        hb.addWidget(self.clock)

        l = QLabel()
        l.setPixmap(QPixmap.fromImage(IMG_CLOCK))
        l.setAlignment(Qt.AlignLeft | Qt.AlignVCenter)
        hb.addWidget(l)

        vb = QVBoxLayout()
        vb.setSizeConstraint(QLayout.SetFixedSize)
        vb.addLayout(hb)
        # end::status[]

        # tag::grid[]
        self.grid = QGridLayout()
        self.grid.setSpacing(5)
        self.grid.setSizeConstraint(QLayout.SetFixedSize)
        # end::grid[]

        vb.addLayout(self.grid)
        w.setLayout(vb)

        self.setCentralWidget(w)

        self.menuBar().setNativeMenuBar(False)

        # tag::menuGame[]
        game_menu = self.menuBar().addMenu("&Game")

        new_game_action = QAction("New game", self)
        new_game_action.setStatusTip(
            "Start a new game (your current game will be lost)"
        )
        new_game_action.triggered.connect(self.reset_map)
        game_menu.addAction(new_game_action)

        levels = game_menu.addMenu("Levels")
        for n, level in enumerate(LEVELS):
            level_action = QAction(level[0], self)
            level_action.setStatusTip("{1}x{1} grid, with {2} mines".format(*level))
            level_action.triggered.connect(lambda _, n=n: self.set_level(n))
            levels.addAction(level_action)
        # end::menuGame[]

        # Start on easy
        self.set_level(0)
        self.show()
Beispiel #21
0
    def _state_WAIT_FOR_PROJECT(self, event: Event, previousState: State,
                                *args, **kwargs) -> None:
        """
		This is the state handler for the WAIT_FOR_PROJECT state.
		
		This method is responsible for completing the GUI setup. It should only be called once ever.
		
		:param event: The event that caused entrance to this state
		:type event: Event
		:param previousState: The state visited prior to entering this state.
		:type previousState: State
		:param args: Any additional arguments needed for this state.
		:type args: list
		:param kwargs: Any additional keyword arguments needed for this state.
		:type kwargs: dict
		:return: None
		:rtype: NoneType
		"""
        # Just for simpler code in this function.
        v = self.view
        ui = self.view.ui

        v.setProject(None)

        # Set up the GUI
        ui.tempView.hide()
        ui.targetGUIModelView = FacileGraphicsView()
        ui.apiModelView = FacileActionGraphicsView()
        ui.viewSplitter.addWidget(ui.targetGUIModelView)
        ui.viewSplitter.addWidget(ui.apiModelView)

        # add spacers to toolbar.
        w = QWidget()
        w.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        ui.toolBar.insertWidget(ui.actionValidate, w)

        # create blank model to show that no project is open.
        blankProjectExplorer = QStandardItemModel()
        blankProjectExplorer.setHorizontalHeaderLabels([""])
        label = QStandardItem("No project is open.")
        label.setFlags(Qt.NoItemFlags)
        blankProjectExplorer.appendRow([label])
        ui.projectExplorerView.setModel(blankProjectExplorer)

        # create blank model to show that no item is selected.
        blankPropertiesModel = QStandardItemModel()
        blankPropertiesModel.setHorizontalHeaderLabels([""])
        label = QStandardItem("No model item is selected.")
        label.setFlags(Qt.NoItemFlags)
        blankPropertiesModel.appendRow([label])
        ui.propertyEditorView.setModel(blankPropertiesModel)

        # Create Timer for detecting app termination
        def tick() -> None:
            if not self._project.getProcess():
                self.view.appWatcher.stop()
                self.view.onStopAppTriggered(confirm=False)

        self.view.appWatcher = QTimer(self.view)
        self.view.appWatcher.timeout.connect(tick)
        self.view.appWatcher.setInterval(500)

        # Create actions for recent projects
        try:
            import data.project as proj
            recentProjects = proj.Project.getRecents(limit=10)
        except json.JSONDecodeError as e:
            ui.menuRecent_Projects_2.addAction(
                "Error loading recent projects.")
        else:
            if len(recentProjects) == 0:
                ui.menuRecent_Projects_2.addAction("No recent projects.")
            else:
                for proj in recentProjects[:10]:
                    action = ui.menuRecent_Projects_2.addAction(proj)
                    action.triggered.connect(v.onOpenRecentProject)
                    icon = QIcon()
                    icon.addPixmap(
                        QPixmap(":/icon/resources/icons/office/open-door.png"),
                        QIcon.Normal, QIcon.Off)
                    action.setIcon(icon)

        # Connecting the configVars' change signal to logic that will update the TGUIM View
        self.configVars.updateTGUIMView.connect(
            lambda: v.ui.targetGUIModelView.scene().invalidate(
                v.ui.targetGUIModelView.scene().sceneRect(), QGraphicsScene.
                ItemLayer))

        # Sync actions to their associated configuration variables (configVars).
        ui.actionShow_Behaviors.setChecked(self.configVars.showBehaviors)
        ui.actionShow_Token_Tags.setChecked(self.configVars.showTokenTags)

        # Connect Facile's actions (At least all of the ones that are static)
        ui.actionFrom_Scratch.triggered.connect(
            v.onNewProjectFromScratchTriggered)
        ui.actionFrom_Existing_Project.triggered.connect(
            v.onNewProjectFromExistingTriggered)
        ui.actionOpen_Project.triggered.connect(v.onOpenProjectTriggered)
        ui.actionSave_Project.triggered.connect(v.onSaveProjectTriggered)
        ui.actionSave_as.triggered.connect(v.onSaveProjectAsTriggered)
        ui.actionManage_Project.triggered.connect(v.onManageProjectTriggered)
        ui.actionAutoExplore.triggered.connect(v.onAutomaticExploration)
        ui.actionManualExplore.triggered.connect(v.onManualExploration)
        ui.actionAdd_Behavior.triggered.connect(v.onAddBehaviorTriggered)
        ui.actionShow_Behaviors.triggered.connect(
            self.configVars.setShowBehaviors)
        ui.actionShow_Token_Tags.triggered.connect(
            self.configVars.setShowTokenTags)
        ui.actionValidate.triggered.connect(ui.validatorView.ran.emit)

        def onPowerApp(checked):
            if checked == True:
                v.onStartAppTriggered()
            else:
                v.onStopAppTriggered(confirm=True)

        ui.actionPower_App.triggered.connect(onPowerApp)

        def onNewActionPipeline():
            ap = ActionPipeline()
            blackBoxEditor = BlackBoxEditorDialog(ap)
            result = blackBoxEditor.exec_()
            if result == QDialog.Rejected:
                return
            else:
                self._project.getAPIModel().addActionPipeline(ap)
                v._actionPipelinesMenu.addAction(ap)
                ui.actionMenuTabWidget.setCurrentWidget(v._actionPipelinesMenu)

        ui.actionAdd_Action_Pipeline.triggered.connect(onNewActionPipeline)
        v._actionPipelinesMenu.actionSelected.connect(
            self.setCurrentActionPipeline)

        def onAPICompiler():
            apicomp = ApiCompilerDialog()
            apicomp.exec_()

        ui.actionShow_API_Compiler.triggered.connect(onAPICompiler)

        # Disable actions
        ui.actionSave_Project.setEnabled(False)
        ui.actionSave_as.setEnabled(False)
        ui.actionAutoExplore.setEnabled(False)
        ui.actionManualExplore.setEnabled(False)
        ui.actionDetailed_View.setEnabled(False)
        ui.actionShow_Behaviors.setEnabled(False)
        ui.actionShow_Token_Tags.setEnabled(False)
        ui.actionAdd_Behavior.setEnabled(False)
        ui.actionPower_App.setEnabled(False)
        ui.actionManage_Project.setEnabled(False)
        ui.actionAdd_Action_Pipeline.setEnabled(False)
        ui.actionShow_API_Compiler.setEnabled(False)
        ui.actionValidate.setEnabled(False)

        # disable validator buttons
        ui.validatorView.ui.runButton.setEnabled(False)
        ui.validatorView.ui.stopButton.setEnabled(False)
        ui.validatorView.ui.clearButton.setEnabled(False)
Beispiel #22
0
    def videostart(self):
        try:
            start_time = time.time()
            # Wait for a coherent pair of frames: depth and color
            frames = self.pipeline.wait_for_frames()
            aligned_frames = self.align.process(frames)
            depth_frame = aligned_frames.get_depth_frame()
            color_frame = aligned_frames.get_color_frame()

            points = self.pc.calculate(depth_frame)

            coordinates = np.ndarray(buffer=points.get_vertices(),
                                     dtype=np.float32,
                                     shape=(1080, 1920, 3))

            if not depth_frame or not color_frame:
                self.message('Fail to load frame')

            # Convert images to numpy arrays
            depth_image = np.asanyarray(depth_frame.get_data())
            color_image = np.asanyarray(color_frame.get_data())

            # Apply colormap on depth image (image must be converted to 8-bit per pixel first)
            depth_colormap = cv2.applyColorMap(
                cv2.convertScaleAbs(depth_image, alpha=0.03), cv2.COLORMAP_JET)

            depth_colormap_dim = depth_colormap.shape
            color_colormap_dim = color_image.shape

            # If depth and color resolutions are different, resize color image to match depth image for display
            if depth_colormap_dim != color_colormap_dim:
                resized_color_image = cv2.resize(color_image,
                                                 dsize=(depth_colormap_dim[1],
                                                        depth_colormap_dim[0]),
                                                 interpolation=cv2.INTER_AREA)
                images = np.hstack((resized_color_image, depth_colormap))
            else:
                images = np.hstack((color_image, depth_colormap))

            frame = cv2.cvtColor(images, cv2.COLOR_BGR2RGB)

            image = qimage2ndarray.array2qimage(frame)

            self.imageLabel.setPixmap(QPixmap.fromImage(image))

            cor = coordinates.copy()
            self.data = {'frame_id': self.frame_id, 'coordinate': cor}

            if self.record_flag:
                self.depthFrame.append(self.data)
                self.saveVideo(color_image)
                self.frame_id += 1
                print('Record Time : ', time.time() - start_time)
            else:
                if self.depthFrame == []:
                    pass
                else:
                    if not self.frame_id == 0:
                        self.thread.start()
                        print('Depth Record Time : ', time.time() - start_time)
                    else:
                        self.thread = threading.Thread(target=self.saveDepth)
            # print('Just view Time : ',time.time() - start_time)
        except Exception as e:
            print(e)

        finally:
            # self.pipeline.stop()
            pass
Beispiel #23
0
    def __init__(self, parent: QWidget, model: Model) -> None:
        super().__init__(parent)

        self.hoverIndexRow = -1
        self.modmodel = model
        self.modCountLastUpdate = len(self.modmodel)
        self.installLock = asyncio.Lock()

        self.setMouseTracking(True)
        self.setSelectionMode(QAbstractItemView.ExtendedSelection)
        self.setSelectionBehavior(QAbstractItemView.SelectRows)
        self.setWordWrap(False)
        self.setSortingEnabled(True)
        self.setFocusPolicy(Qt.StrongFocus)
        self.setAcceptDrops(True)
        self.setEditTriggers(QTableView.EditKeyPressed | QTableView.DoubleClicked)
        self.setShowGrid(False)

        self.setStyleSheet('''
            QTableView {
                gridline-color: rgba(255,255,255,1);
            }
            QTableView::item:!selected:hover {
                background-color: rgb(217, 235, 249);
            }
            ''')

        self.setVerticalScrollMode(QAbstractItemView.ScrollPerPixel)
        self.setHorizontalScrollMode(QAbstractItemView.ScrollPerPixel)
        self.setContextMenuPolicy(Qt.CustomContextMenu)
        self.customContextMenuRequested.connect(self.showContextMenu)

        self.verticalHeader().hide()
        self.verticalHeader().setVisible(False)
        self.verticalHeader().setDefaultSectionSize(25)
        self.setCornerButtonEnabled(False)
        self.horizontalHeader().setHighlightSections(False)
        self.horizontalHeader().setStretchLastSection(True)
        self.horizontalHeader().setSectionsMovable(True)

        self.listmodel = ModListModel(self, model)
        self.filtermodel = ModListFilterModel(self, self.listmodel)
        self.setModel(self.filtermodel)

        self.setItemDelegate(ModListItemDelegate(self))
        self.setSelectionModel(ModListSelectionModel(self, self.filtermodel))

        self.resizeColumnsToContents()

        settings = QSettings()
        if settings.value('modlistHorizontalHeaderState'):
            self.horizontalHeader().restoreState(settings.value('modlistHorizontalHeaderState'))  # type: ignore

        self.horizontalHeader().sectionMoved.connect(lambda: self.headerChangedEvent())
        self.horizontalHeader().sectionResized.connect(lambda: self.headerChangedEvent())

        self.setFocus()

        self.sortByColumn(3, Qt.AscendingOrder, False)
        self.sortByColumn(2, Qt.AscendingOrder, False)
        self.sortByColumn(1, Qt.AscendingOrder, False)
        if settings.value('modlistSortColumn') is not None and \
           settings.value('modlistSortOrder') is not None:
            try:
                self.sortByColumn(
                    cast(int, settings.value('modlistSortColumn', 1, int)),
                    Qt.DescendingOrder if cast(int, settings.value('modlistSortOrder', 1, int)) else Qt.AscendingOrder,
                    False
                )
            except Exception as e:
                logger.exception(f'could not restore sort order: {e}')
        self.horizontalHeader().sortIndicatorChanged.connect(self.sortByColumn)

        self.doubleClicked.connect(self.doubleClickEvent)
        model.updateCallbacks.append(self.modelUpdateEvent)

        # setup viewport caching to counter slow resizing with many table elements
        self.resizeTimer = QTimer(self)
        self.resizeTimer.setSingleShot(True)
        self.resizeTimer.setInterval(250)
        self.resizeTimer.timeout.connect(lambda: [
            self.resizeTimer.stop(),
            self.viewport().repaint(),
        ])
        self.viewportCache = QPixmap()
        self.viewportCacheSize = QSize(0, 0)
Beispiel #24
0
class RenderArea(QWidget):
    points = QPolygon([
        QPoint(10, 80),
        QPoint(20, 10),
        QPoint(80, 30),
        QPoint(90, 70)
    ])

    Line, Points, Polyline, Polygon, Rect, RoundedRect, Ellipse, Arc, Chord, \
            Pie, Path, Text, Pixmap = range(13)

    def __init__(self, parent=None):
        super(RenderArea, self).__init__(parent)

        self.pen = QPen()
        self.brush = QBrush()
        self.pixmap = QPixmap()

        self.shape = RenderArea.Polygon
        self.antialiased = False
        self.transformed = False
        self.pixmap.load(':/images/qt-logo.png')

        self.setBackgroundRole(QPalette.Base)
        self.setAutoFillBackground(True)

    def minimumSizeHint(self):
        return QSize(100, 100)

    def sizeHint(self):
        return QSize(400, 200)

    def setShape(self, shape):
        self.shape = shape
        self.update()

    def setPen(self, pen):
        self.pen = pen
        self.update()

    def setBrush(self, brush):
        self.brush = brush
        self.update()

    def setAntialiased(self, antialiased):
        self.antialiased = antialiased
        self.update()

    def setTransformed(self, transformed):
        self.transformed = transformed
        self.update()

    def paintEvent(self, event):
        rect = QRect(10, 20, 80, 60)

        path = QPainterPath()
        path.moveTo(20, 80)
        path.lineTo(20, 30)
        path.cubicTo(80, 0, 50, 50, 80, 80)

        startAngle = 30 * 16
        arcLength = 120 * 16

        painter = QPainter(self)
        painter.setPen(self.pen)
        painter.setBrush(self.brush)
        if self.antialiased:
            painter.setRenderHint(QPainter.Antialiasing)

        for x in range(0, self.width(), 100):
            for y in range(0, self.height(), 100):
                painter.save()
                painter.translate(x, y)
                if self.transformed:
                    painter.translate(50, 50)
                    painter.rotate(60.0)
                    painter.scale(0.6, 0.9)
                    painter.translate(-50, -50)

                if self.shape == RenderArea.Line:
                    painter.drawLine(rect.bottomLeft(), rect.topRight())
                elif self.shape == RenderArea.Points:
                    painter.drawPoints(RenderArea.points)
                elif self.shape == RenderArea.Polyline:
                    painter.drawPolyline(RenderArea.points)
                elif self.shape == RenderArea.Polygon:
                    painter.drawPolygon(RenderArea.points)
                elif self.shape == RenderArea.Rect:
                    painter.drawRect(rect)
                elif self.shape == RenderArea.RoundedRect:
                    painter.drawRoundedRect(rect, 25, 25, Qt.RelativeSize)
                elif self.shape == RenderArea.Ellipse:
                    painter.drawEllipse(rect)
                elif self.shape == RenderArea.Arc:
                    painter.drawArc(rect, startAngle, arcLength)
                elif self.shape == RenderArea.Chord:
                    painter.drawChord(rect, startAngle, arcLength)
                elif self.shape == RenderArea.Pie:
                    painter.drawPie(rect, startAngle, arcLength)
                elif self.shape == RenderArea.Path:
                    painter.drawPath(path)
                elif self.shape == RenderArea.Text:
                    painter.drawText(rect, Qt.AlignCenter,
                                     "PySide 2\nQt %s" % qVersion())
                elif self.shape == RenderArea.Pixmap:
                    painter.drawPixmap(10, 10, self.pixmap)

                painter.restore()

        painter.setPen(self.palette().dark().color())
        painter.setBrush(Qt.NoBrush)
        painter.drawRect(QRect(0, 0, self.width() - 1, self.height() - 1))
Beispiel #25
0
from PySide2.QtWidgets import *
from PySide2.QtGui import QPixmap

app = QApplication([])
window = QWidget()
# Add a Label:
label = QLabel()
# Add a pixmap instance to the label:
label.setPixmap(QPixmap("./111.jpg"))
layout = QVBoxLayout()
layout.addWidget(label)
window.setLayout(layout)
window.show()
app.exec_()
Beispiel #26
0
    def __init__(self, hole=None, matlib=MatLib()):
        """Initialize the widget according to hole

        Parameters
        ----------
        self : PHoleM52
            A PHoleM52 widget
        hole : HoleM52
            current hole to edit
        matlib : MatLib
            Material Library
        """
        # Build the interface according to the .ui file
        QWidget.__init__(self)
        self.setupUi(self)

        self.matlib = matlib
        self.hole = hole

        # Set FloatEdit unit
        self.lf_W0.unit = "m"
        self.lf_W3.unit = "m"
        self.lf_H0.unit = "m"
        self.lf_H1.unit = "m"
        self.lf_H2.unit = "m"

        # Set default materials
        self.w_mat_0.setText("mat_void")
        self.w_mat_0.def_mat = "Air"
        self.w_mat_0.is_hide_button = True

        self.w_mat_1.setText("magnet_0")
        self.w_mat_1.def_mat = "Magnet1"
        self.w_mat_1.is_hide_button = True

        # Set unit name (m ou mm)
        self.u = gui_option.unit
        wid_list = [
            self.unit_W0,
            self.unit_W3,
            self.unit_H0,
            self.unit_H1,
            self.unit_H2,
        ]
        for wid in wid_list:
            wid.setText("[" + self.u.get_m_name() + "]")

        # Adapt GUI with/without magnet
        if hole.magnet_0 is None:  # SyRM
            self.img_slot.setPixmap(
                QPixmap(
                    ":/images/images/MachineSetup/SMHoleMag/HoleM52_no_mag.png"
                ))
            self.w_mat_0.update(self.hole, "mat_void", self.matlib)
            self.w_mat_1.hide()
        else:
            self.w_mat_0.update(self.hole, "mat_void", self.matlib)
            self.w_mat_1.update(self.hole.magnet_0, "mat_type", self.matlib)

        # Fill the fields with the machine values (if they're filled)
        self.lf_W0.setValue(self.hole.W0)
        self.lf_W3.setValue(self.hole.W3)
        self.lf_H0.setValue(self.hole.H0)
        self.lf_H1.setValue(self.hole.H1)
        self.lf_H2.setValue(self.hole.H2)

        # Display the main output of the hole (surface, height...)
        self.comp_output()

        # Connect the signal
        self.lf_W0.editingFinished.connect(self.set_W0)
        self.lf_W3.editingFinished.connect(self.set_W3)
        self.lf_H0.editingFinished.connect(self.set_H0)
        self.lf_H1.editingFinished.connect(self.set_H1)
        self.lf_H2.editingFinished.connect(self.set_H2)

        self.w_mat_0.saveNeeded.connect(self.emit_save)
        self.w_mat_1.saveNeeded.connect(self.emit_save)
Beispiel #27
0
def resize9patch(image, dw, dh):
    sw = image.width()
    sh = image.height()
    if sw > 2 and sh > 2 and dw > 0 and dh > 0:
        pixmap = QPixmap(dw, dh)
        pixmap.fill(Qt.transparent)
        pr = QPainter(pixmap)
        pr.setRenderHint(QPainter.Antialiasing)
        pr.setRenderHint(QPainter.SmoothPixmapTransform)

        horz = []
        vert = []
        horz_stretch = 0
        vert_stretch = 0

        pos = 0
        last = image.pixel(1, 0)
        for x in range(1, sw - 1):
            nextP = image.pixel(x + 1, 0)
            if isStretchableMarker(last) != isStretchableMarker(
                    nextP) or x == sw - 2:
                stretchable = isStretchableMarker(last)
                length = x - pos
                horz.append(Part(pos, length, stretchable))
                if stretchable:
                    horz_stretch += length
                last = nextP
                pos = x
        pos = 0
        last = image.pixel(0, 1)
        for y in range(1, sh - 1):
            nextP = image.pixel(0, y + 1)
            if isStretchableMarker(last) != isStretchableMarker(
                    nextP) or y == sh - 2:
                stretchable = isStretchableMarker(last)
                length = y - pos
                vert.append(Part(pos, length, stretchable))
                if stretchable:
                    vert_stretch += length
                last = nextP
                pos = y

        horz_mul = 0
        vert_mul = 0
        if horz_stretch > 0:
            horz_mul = float((dw - (sw - 2 - horz_stretch)) / horz_stretch)
        if vert_stretch > 0:
            vert_mul = float((dh - (sh - 2 - vert_stretch)) / vert_stretch)
        dy0 = 0
        dy1 = 0
        vstretch = 0
        len_vert = len(vert)
        len_horz = len(horz)
        for i in range(len_vert):
            sy0 = vert[i].pos
            sy1 = vert[i].pos + vert[i].length
            if i + 1 == len_vert:
                dy1 = dh
            elif vert[i].stretchable:
                vstretch += float(vert[i].length * vert_mul)
                s = floor(vstretch)
                vstretch -= s
                dy1 += int(s)
            else:
                dy1 += vert[i].length
            dx0 = 0
            dx1 = 0
            hstretch = 0
            for j in range(len_horz):
                sx0 = horz[j].pos
                sx1 = horz[j].pos + horz[j].length
                if j + 1 == len_horz:
                    dx1 = dw
                elif horz[j].stretchable:
                    hstretch += float(horz[j].length * horz_mul)
                    s = floor(hstretch)
                    hstretch -= s
                    dx1 += int(s)
                else:
                    dx1 += horz[j].length
                pr.drawImage(QRect(dx0, dy0, dx1 - dx0, dy1 - dy0), image,
                             QRect(sx0 + 1, sy0 + 1, sx1 - sx0, sy1 - sy0))
                dx0 = dx1
            dy0 = dy1
        return pixmap
    return QPixmap()
Beispiel #28
0
 def testImage(self):
     app = QApplication([])
     image = QPixmap(":image")
     self.assertFalse(image.isNull())
Beispiel #29
0
 def open_file(self):
     fileName = QFileDialog.getOpenFileName(
         self, "Open Image", "", "Image Files (*.png *.jpg *.bmp)")
     self.pictureLabel.setPixmap(QPixmap(fileName))
 def testQPixmapConstructor(self):
     label = QLabel()
     pixmap1 = QPixmap(xpm)
     self.assertFalse(pixmap1.isNull())
     self.assertEqual(pixmap1.width(), 27)
     self.assertEqual(pixmap1.height(), 22)
Beispiel #31
0
    def setupUi(self, Dialog):
        if Dialog.objectName():
            Dialog.setObjectName(u"Dialog")
        Dialog.resize(400, 300)
        self.tabWidget = QTabWidget(Dialog)
        self.tabWidget.setObjectName(u"tabWidget")
        self.tabWidget.setGeometry(QRect(17, 38, 370, 211))
        self.tab = QWidget()
        self.tab.setObjectName(u"tab")
        self.label = QLabel(self.tab)
        self.label.setObjectName(u"label")
        self.label.setGeometry(QRect(40, 40, 81, 16))
        self.lineEdit = QLineEdit(self.tab)
        self.lineEdit.setObjectName(u"lineEdit")
        self.lineEdit.setGeometry(QRect(110, 40, 181, 24))
        self.lineEdit_2 = QLineEdit(self.tab)
        self.lineEdit_2.setObjectName(u"lineEdit_2")
        self.lineEdit_2.setGeometry(QRect(110, 70, 181, 24))
        self.lineEdit_2.setEchoMode(QLineEdit.Password)
        self.label_2 = QLabel(self.tab)
        self.label_2.setObjectName(u"label_2")
        self.label_2.setGeometry(QRect(40, 70, 81, 16))
        self.horizontalLayoutWidget = QWidget(self.tab)
        self.horizontalLayoutWidget.setObjectName(u"horizontalLayoutWidget")
        self.horizontalLayoutWidget.setGeometry(QRect(190, 150, 169, 31))
        self.horizontalLayout = QHBoxLayout(self.horizontalLayoutWidget)
        self.horizontalLayout.setObjectName(u"horizontalLayout")
        self.horizontalLayout.setContentsMargins(0, 0, 0, 0)
        self.pb_login = QPushButton(self.horizontalLayoutWidget)
        self.pb_login.setObjectName(u"pb_login")

        self.horizontalLayout.addWidget(self.pb_login)

        self.pb_cancel2 = QPushButton(self.horizontalLayoutWidget)
        self.pb_cancel2.setObjectName(u"pb_cancel2")

        self.horizontalLayout.addWidget(self.pb_cancel2)

        icon = QIcon()
        icon.addFile(u":/staticfiles/icons/Users.png", QSize(), QIcon.Normal,
                     QIcon.Off)
        self.tabWidget.addTab(self.tab, icon, "")
        self.tab_2 = QWidget()
        self.tab_2.setObjectName(u"tab_2")
        self.lineEdit_3 = QLineEdit(self.tab_2)
        self.lineEdit_3.setObjectName(u"lineEdit_3")
        self.lineEdit_3.setGeometry(QRect(140, 60, 181, 24))
        self.label_3 = QLabel(self.tab_2)
        self.label_3.setObjectName(u"label_3")
        self.label_3.setGeometry(QRect(50, 90, 81, 16))
        self.label_4 = QLabel(self.tab_2)
        self.label_4.setObjectName(u"label_4")
        self.label_4.setGeometry(QRect(50, 60, 81, 16))
        self.lineEdit_4 = QLineEdit(self.tab_2)
        self.lineEdit_4.setObjectName(u"lineEdit_4")
        self.lineEdit_4.setGeometry(QRect(140, 90, 181, 24))
        self.lineEdit_4.setMaxLength(20)
        self.lineEdit_4.setEchoMode(QLineEdit.Password)
        self.label_5 = QLabel(self.tab_2)
        self.label_5.setObjectName(u"label_5")
        self.label_5.setGeometry(QRect(50, 120, 81, 16))
        self.lineEdit_5 = QLineEdit(self.tab_2)
        self.lineEdit_5.setObjectName(u"lineEdit_5")
        self.lineEdit_5.setGeometry(QRect(140, 120, 181, 24))
        self.lineEdit_5.setEchoMode(QLineEdit.Password)
        self.comboBox = QComboBox(self.tab_2)
        self.comboBox.addItem("")
        self.comboBox.addItem("")
        self.comboBox.setObjectName(u"comboBox")
        self.comboBox.setGeometry(QRect(140, 30, 181, 24))
        self.pb_save = QPushButton(self.tab_2)
        self.pb_save.setObjectName(u"pb_save")
        self.pb_save.setGeometry(QRect(187, 153, 80, 25))
        self.pb_cancel = QPushButton(self.tab_2)
        self.pb_cancel.setObjectName(u"pb_cancel")
        self.pb_cancel.setGeometry(QRect(277, 153, 80, 25))
        icon1 = QIcon()
        icon1.addFile(u":/staticfiles/icons/login.png", QSize(), QIcon.Normal,
                      QIcon.Off)
        self.tabWidget.addTab(self.tab_2, icon1, "")
        self.label_7 = QLabel(Dialog)
        self.label_7.setObjectName(u"label_7")
        self.label_7.setGeometry(QRect(47, 8, 341, 31))
        self.label_7.setFrameShape(QFrame.StyledPanel)
        self.label_6 = QLabel(Dialog)
        self.label_6.setObjectName(u"label_6")
        self.label_6.setGeometry(QRect(17, 258, 371, 31))
        self.label_6.setFrameShape(QFrame.Box)
        self.label_8 = QLabel(Dialog)
        self.label_8.setObjectName(u"label_8")
        self.label_8.setGeometry(QRect(14, 7, 31, 31))
        self.label_8.setPixmap(QPixmap(u":/staticfiles/icons/stock6.png"))
        self.label_8.setScaledContents(True)

        self.retranslateUi(Dialog)

        self.tabWidget.setCurrentIndex(0)

        QMetaObject.connectSlotsByName(Dialog)
Beispiel #32
0
 def SetPicture(self, data):
     pic = QPixmap()
     pic.loadFromData(data)
     self.picLabel.setPixmap(pic)
Beispiel #33
0
 def paintEvent(self, event):
     painter = QPainter(self)
     painter.drawPixmap(self.rect(), QPixmap("images/home_bg.jpg"), QRect())
Beispiel #34
0
 def get_login_info(self):
     self.sub_ui.veri_img_label.setPixmap(QPixmap('veri.png'))
     self.sub_ui.show()
Beispiel #35
0
    def __init__(self):
        super().__init__()

        # tag::tabWidget[]
        self.tabs = QTabWidget()
        self.tabs.setDocumentMode(True)
        self.tabs.tabBarDoubleClicked.connect(self.tab_open_doubleclick)
        self.tabs.currentChanged.connect(self.current_tab_changed)
        self.tabs.setTabsClosable(True)
        self.tabs.tabCloseRequested.connect(self.close_current_tab)

        self.setCentralWidget(self.tabs)
        # end::tabWidget[]

        navtb = QToolBar("Navigation")
        navtb.setIconSize(QSize(16, 16))
        self.addToolBar(navtb)

        back_btn = QAction(QIcon(os.path.join("icons", "arrow-180.png")),
                           "Back", self)
        back_btn.setStatusTip("Back to previous page")
        back_btn.triggered.connect(lambda: self.tabs.currentWidget().back())
        navtb.addAction(back_btn)

        next_btn = QAction(QIcon(os.path.join("icons", "arrow-000.png")),
                           "Forward", self)
        next_btn.setStatusTip("Forward to next page")
        next_btn.triggered.connect(lambda: self.tabs.currentWidget().forward())
        navtb.addAction(next_btn)

        reload_btn = QAction(
            QIcon(os.path.join("icons", "arrow-circle-315.png")), "Reload",
            self)
        reload_btn.setStatusTip("Reload page")
        reload_btn.triggered.connect(
            lambda: self.tabs.currentWidget().reload())
        navtb.addAction(reload_btn)

        home_btn = QAction(QIcon(os.path.join("icons", "home.png")), "Home",
                           self)
        home_btn.setStatusTip("Go home")
        home_btn.triggered.connect(self.navigate_home)
        navtb.addAction(home_btn)

        navtb.addSeparator()

        self.httpsicon = QLabel()  # Yes, really!
        self.httpsicon.setPixmap(
            QPixmap(os.path.join("icons", "lock-nossl.png")))
        navtb.addWidget(self.httpsicon)

        self.urlbar = QLineEdit()
        self.urlbar.returnPressed.connect(self.navigate_to_url)
        navtb.addWidget(self.urlbar)

        stop_btn = QAction(QIcon(os.path.join("icons", "cross-circle.png")),
                           "Stop", self)
        stop_btn.setStatusTip("Stop loading current page")
        stop_btn.triggered.connect(lambda: self.tabs.currentWidget().stop())
        navtb.addAction(stop_btn)

        self.menuBar().setNativeMenuBar(False)
        self.statusBar()

        file_menu = self.menuBar().addMenu("&File")

        new_tab_action = QAction(
            QIcon(os.path.join("icons", "ui-tab--plus.png")), "New Tab", self)
        new_tab_action.setStatusTip("Open a new tab")
        new_tab_action.triggered.connect(lambda _: self.add_new_tab())
        file_menu.addAction(new_tab_action)

        open_file_action = QAction(
            QIcon(os.path.join("icons", "disk--arrow.png")), "Open file...",
            self)
        open_file_action.setStatusTip("Open from file")
        open_file_action.triggered.connect(self.open_file)
        file_menu.addAction(open_file_action)

        save_file_action = QAction(
            QIcon(os.path.join("icons", "disk--pencil.png")),
            "Save Page As...", self)
        save_file_action.setStatusTip("Save current page to file")
        save_file_action.triggered.connect(self.save_file)
        file_menu.addAction(save_file_action)

        print_action = QAction(QIcon(os.path.join("icons", "printer.png")),
                               "Print...", self)
        print_action.setStatusTip("Print current page")
        print_action.triggered.connect(self.print_page)
        file_menu.addAction(print_action)

        # Create our system printer instance.
        self.printer = QPrinter()

        help_menu = self.menuBar().addMenu("&Help")

        about_action = QAction(
            QIcon(os.path.join("icons", "question.png")),
            "About Mozzarella Ashbadger",
            self,
        )
        about_action.setStatusTip(
            "Find out more about Mozzarella Ashbadger")  # Hungry!
        about_action.triggered.connect(self.about)
        help_menu.addAction(about_action)

        navigate_mozarella_action = QAction(
            QIcon(os.path.join("icons", "lifebuoy.png")),
            "Mozzarella Ashbadger Homepage",
            self,
        )
        navigate_mozarella_action.setStatusTip(
            "Go to Mozzarella Ashbadger Homepage")
        navigate_mozarella_action.triggered.connect(self.navigate_mozarella)
        help_menu.addAction(navigate_mozarella_action)

        self.add_new_tab(QUrl("http://www.google.com"), "Homepage")

        self.show()

        self.setWindowTitle("Mozzarella Ashbadger")
        self.setWindowIcon(QIcon(os.path.join("icons", "ma-icon-64.png")))
Beispiel #36
0
from PySide2.QtWidgets import *
from PySide2.QtGui import QPixmap

app = QApplication([])
window = QWidget()

#Add a Label:
label = QLabel()

#Add a pixmap instance to the label:
label.setPixmap(QPixmap("./4.png"))
layout = QVBoxLayout()

layout.addWidget(label)
window.setLayout(layout)
window.show()
app.exec_()
Beispiel #37
0
 def ShowUserImg(self, data, st):
     if st == Status.Ok:
         a = QPixmap()
         a.loadFromData(data)
         self.owner().userForm.icon.setPixmap(a)
    def showDetails(self, info: dict):
        if not self.isVisible():
            self.setVisible(True)
            self.tab.setCurrentIndex(0)  # Show details tab initially
        if self.editDetailsButton.isChecked():
            self.editDetailsButton.setChecked(False)
        self.stackedLayout.setCurrentIndex(0)  # Show info layout initially

        self._id = info["id"]
        self._imagedata = ""
        pixmap = path.join(self._coverdir, "none.png")
        if path.exists(path.join(self._coverdir, str(self._id) + ".jpg")) and info["table"] == "games":
            pixmap = path.join(self._coverdir, str(self._id) + ".jpg")
        p = QPixmap(pixmap)
        w = self.cover.width()
        h = self.cover.height()
        self.cover.setPixmap(p.scaled(w, h, Qt.KeepAspectRatio, Qt.SmoothTransformation))

        # Price data is stored in form $x,$x,$x,$x [paid, loose, cib, new]
        paidPrice, loosePrice, cibPrice, newPrice = info["price"].split(",")

        self.nameDataLabel.setText(info["name"])
        self.platformDataLabel.setText(info["platform"])
        self.regionDataLabel.setText(info["region"])
        self.boxDataLabel.setText(info["box"])
        self.manualDataLabel.setText(info["manual"])
        self.yearDataLabel.setText(str(info["year"]))
        self.commentDataLabel.setText(info["comment"])
        self.paidPriceDataLE.setText(paidPrice)
        self.loosePriceDataLabel.setText(loosePrice)
        self.cibPriceDataLabel.setText(cibPrice)
        self.newPriceDataLabel.setText(newPrice)
        if info["table"] == "games":
            self.publisherDataLabel.setText(info["publisher"])
            self.developerDataLabel.setText(info["developer"])
            self.genreInfoLabel.setText("Genre:")
            self.genreEditLabel.setText("Genre:")
            self.genreDataLabel.setText(info["genre"])
            self.codeInfoLabel.setText("Code:")
            self.codeInfoLabel.setVisible(True)
            self.codeEditLabel.setText("Code")
            self.codeEditLabel.setVisible(True)
            self.codeDataLabel.setText(info["code"])
            self.codeDataLabel.setVisible(True)
            self.codeDataLE.setVisible(True)
            self.itemInfoLabel.setText("Game:")
            self.itemEditLabel.setText("Game:")
            self.itemDataLabel.setText(info["game"])
            self.platformsDataLabel.setText(info["platforms"])
            self.platformsDataLabel.setVisible(True)
            self.platformsInfoLabel.setVisible(True)
            self.fetchInfoButton.setEnabled(True)
            self.fetchInfoButton.setVisible(True)
            self.fetchInfoButton.setToolTip("Try to fetch info from MobyGames")
            self.saveDetailsButton.setEnabled(True)
            self.saveDetailsButton.setVisible(True)
        elif info["table"] == "consoles":
            self.genreInfoLabel.setText("Country:")
            self.genreEditLabel.setText("Country:")
            self.genreDataLabel.setText(info["country"])
            self.codeInfoLabel.setText("Serial Number:")
            self.codeInfoLabel.setVisible(True)
            self.codeEditLabel.setText("Serial Number:")
            self.codeEditLabel.setVisible(True)
            self.codeDataLabel.setText(info["serial number"])
            self.codeDataLabel.setVisible(True)
            self.codeDataLE.setVisible(True)
            self.itemInfoLabel.setText("Console:")
            self.itemEditLabel.setText("Console:")
            self.itemDataLabel.setText(info["console"])
            self.platformsInfoLabel.setVisible(False)
            self.platformsDataLabel.setVisible(False)
            self.fetchInfoButton.setEnabled(False)
            self.fetchInfoButton.setToolTip("Not available for Consoles tab")
        elif info["table"] == "accessories":
            self.genreInfoLabel.setText("Country:")
            self.genreEditLabel.setText("Country:")
            self.genreDataLabel.setText(info["country"])
            self.itemInfoLabel.setText("Accessory:")
            self.itemEditLabel.setText("Accessory:")
            self.itemDataLabel.setText(info["accessory"])
            self.codeInfoLabel.setVisible(False)
            self.codeEditLabel.setVisible(False)
            self.codeDataLabel.setVisible(False)
            self.codeDataLE.setVisible(False)
            self.platformsInfoLabel.setVisible(False)
            self.platformsDataLabel.setVisible(False)
            self.fetchInfoButton.setEnabled(False)
            self.fetchInfoButton.setToolTip("Not avaiable for Accessories tab")
Beispiel #39
0
    def setupUi(self, MainWindow):
        if not MainWindow.objectName():
            MainWindow.setObjectName(u"MainWindow")
        MainWindow.resize(1009, 734)
        self.centralwidget = QWidget(MainWindow)
        self.centralwidget.setObjectName(u"centralwidget")
        self.label = QLabel(self.centralwidget)
        self.label.setObjectName(u"label")
        self.label.setGeometry(QRect(10, 80, 1000, 581))
        self.label.setPixmap(
            QPixmap(u"../\ub2e4\uc6b4\ub85c\ub4dc/stadium.jpg"))
        self.label.setAlignment(Qt.AlignCenter)
        self.layoutWidget = QWidget(self.centralwidget)
        self.layoutWidget.setObjectName(u"layoutWidget")
        self.layoutWidget.setGeometry(QRect(270, 130, 216, 71))
        self.gridLayout_2 = QGridLayout(self.layoutWidget)
        self.gridLayout_2.setObjectName(u"gridLayout_2")
        self.gridLayout_2.setContentsMargins(0, 0, 0, 0)
        self.label_3 = QLabel(self.layoutWidget)
        self.label_3.setObjectName(u"label_3")
        font = QFont()
        font.setPointSize(12)
        font.setBold(True)
        font.setWeight(75)
        self.label_3.setFont(font)

        self.gridLayout_2.addWidget(self.label_3, 0, 0, 1, 1)

        self.lineEdit_2 = QLineEdit(self.layoutWidget)
        self.lineEdit_2.setObjectName(u"lineEdit_2")
        font1 = QFont()
        font1.setPointSize(12)
        self.lineEdit_2.setFont(font1)

        self.gridLayout_2.addWidget(self.lineEdit_2, 1, 0, 1, 1)

        self.pushButton_2 = QPushButton(self.layoutWidget)
        self.pushButton_2.setObjectName(u"pushButton_2")

        self.gridLayout_2.addWidget(self.pushButton_2, 1, 1, 1, 1)

        self.label_4 = QLabel(self.centralwidget)
        self.label_4.setObjectName(u"label_4")
        self.label_4.setGeometry(QRect(40, 200, 141, 51))
        font2 = QFont()
        font2.setPointSize(14)
        font2.setBold(True)
        font2.setWeight(75)
        self.label_4.setFont(font2)
        self.textEdit = QTextEdit(self.centralwidget)
        self.textEdit.setObjectName(u"textEdit")
        self.textEdit.setGeometry(QRect(40, 250, 441, 371))
        self.textEdit_2 = QTextEdit(self.centralwidget)
        self.textEdit_2.setObjectName(u"textEdit_2")
        self.textEdit_2.setGeometry(QRect(520, 250, 441, 371))
        self.label_5 = QLabel(self.centralwidget)
        self.label_5.setObjectName(u"label_5")
        self.label_5.setGeometry(QRect(520, 210, 171, 51))
        self.label_5.setFont(font2)
        self.pushButton_3 = QPushButton(self.centralwidget)
        self.pushButton_3.setObjectName(u"pushButton_3")
        self.pushButton_3.setGeometry(QRect(540, 130, 171, 71))
        self.pushButton_3.setFont(font)
        self.pushButton_4 = QPushButton(self.centralwidget)
        self.pushButton_4.setObjectName(u"pushButton_4")
        self.pushButton_4.setGeometry(QRect(750, 130, 171, 71))
        font3 = QFont()
        font3.setPointSize(11)
        font3.setBold(True)
        font3.setWeight(75)
        self.pushButton_4.setFont(font3)
        self.widget = QWidget(self.centralwidget)
        self.widget.setObjectName(u"widget")
        self.widget.setGeometry(QRect(40, 130, 216, 71))
        self.gridLayout = QGridLayout(self.widget)
        self.gridLayout.setObjectName(u"gridLayout")
        self.gridLayout.setContentsMargins(0, 0, 0, 0)
        self.label_2 = QLabel(self.widget)
        self.label_2.setObjectName(u"label_2")
        self.label_2.setFont(font)

        self.gridLayout.addWidget(self.label_2, 0, 0, 1, 1)

        self.lineEdit = QLineEdit(self.widget)
        self.lineEdit.setObjectName(u"lineEdit")
        self.lineEdit.setFont(font1)

        self.gridLayout.addWidget(self.lineEdit, 1, 0, 1, 1)

        self.pushButton = QPushButton(self.widget)
        self.pushButton.setObjectName(u"pushButton")

        self.gridLayout.addWidget(self.pushButton, 1, 1, 1, 1)

        MainWindow.setCentralWidget(self.centralwidget)
        self.statusbar = QStatusBar(MainWindow)
        self.statusbar.setObjectName(u"statusbar")
        MainWindow.setStatusBar(self.statusbar)

        self.retranslateUi(MainWindow)

        QMetaObject.connectSlotsByName(MainWindow)
Beispiel #40
0
    def setupUi(self, Form):
        if not Form.objectName():
            Form.setObjectName(u"Form")
        Form.resize(587, 139)
        Form.setWindowTitle("Attention")
        Form.setStyleSheet("* {background-color: Lightblue}")

        self.widget = QWidget(Form)
        self.widget.setObjectName(u"widget")
        self.widget.setGeometry(QRect(10, 10, 571, 121))
        self.verticalLayout = QVBoxLayout(self.widget)
        self.verticalLayout.setObjectName(u"verticalLayout")
        self.verticalLayout.setContentsMargins(0, 0, 0, 0)
        self.horizontalLayout_2 = QHBoxLayout()
        self.horizontalLayout_2.setSpacing(10)
        self.horizontalLayout_2.setObjectName(u"horizontalLayout_2")
        self.horizontalLayout_2.setSizeConstraint(QLayout.SetDefaultConstraint)
        self.horizontalLayout_2.setContentsMargins(0, 0, 0, 0)
        self.horizontalSpacer_4 = QSpacerItem(40, 20, QSizePolicy.Expanding,
                                              QSizePolicy.Minimum)

        self.horizontalLayout_2.addItem(self.horizontalSpacer_4)

        self.label = QLabel(self.widget)
        self.label.setObjectName(u"label")
        self.label.setPixmap(
            QPixmap(':/img/img/danger_ready.png').scaled(95, 95))

        self.horizontalLayout_2.addWidget(self.label)

        self.label_2 = QLabel(self.widget)
        self.label_2.setObjectName(u"label_2")

        self.horizontalLayout_2.addWidget(self.label_2)

        self.horizontalSpacer = QSpacerItem(40, 20, QSizePolicy.Expanding,
                                            QSizePolicy.Minimum)

        self.horizontalLayout_2.addItem(self.horizontalSpacer)

        self.verticalLayout.addLayout(self.horizontalLayout_2)

        self.horizontalLayout = QHBoxLayout()
        self.horizontalLayout.setObjectName(u"horizontalLayout")
        self.horizontalSpacer_2 = QSpacerItem(150, 20, QSizePolicy.Fixed,
                                              QSizePolicy.Minimum)

        self.horizontalLayout.addItem(self.horizontalSpacer_2)

        self.pushButton = QPushButton(self.widget)
        self.pushButton.setObjectName(u"pushButton")
        sizePolicy = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.pushButton.sizePolicy().hasHeightForWidth())
        self.pushButton.setSizePolicy(sizePolicy)
        self.pushButton.setMinimumSize(QSize(0, 0))
        self.pushButton.setBaseSize(QSize(0, 0))
        self.pushButton.setIconSize(QSize(50, 25))
        self.pushButton.setCursor(Qt.PointingHandCursor)
        self.pushButton.setStyleSheet("* { background-color: yellow;"
                                      "color: Darkred;"
                                      "border-style: outset;"
                                      "border-width: 2px;"
                                      "border-radius: 10px;"
                                      "border-color: black;"
                                      "font: bold;"
                                      "padding: 5px;}")

        self.horizontalLayout.addWidget(self.pushButton)

        self.pushButton_2 = QPushButton(self.widget)
        self.pushButton_2.setObjectName(u"pushButton_2")
        self.pushButton_2.setCursor(Qt.PointingHandCursor)

        # self.pushButton_2.setPalette(Qt.red)  # -- and this is work, too
        self.pushButton_2.setStyleSheet(
            "* { background-color: rgb(255,125,100);"
            "color: blue;"
            "border-style: outset;"
            "border-width: 2px;"
            "border-radius: 10px;"
            "border-color: black;"
            "font: bold;"
            "padding: 5px;}")  # -- it's work
        self.pushButton_2.setText(u"\u041e\u0442\u043c\u0435\u043d\u0430")

        sizePolicy.setHeightForWidth(
            self.pushButton_2.sizePolicy().hasHeightForWidth())
        self.pushButton_2.setSizePolicy(sizePolicy)
        self.pushButton_2.setMinimumSize(QSize(0, 0))
        self.pushButton_2.setBaseSize(QSize(0, 0))
        self.pushButton_2.setIconSize(QSize(50, 25))

        self.horizontalLayout.addWidget(self.pushButton_2)

        self.horizontalSpacer_3 = QSpacerItem(150, 20, QSizePolicy.Fixed,
                                              QSizePolicy.Minimum)

        self.horizontalLayout.addItem(self.horizontalSpacer_3)

        self.verticalLayout.addLayout(self.horizontalLayout)

        self.retranslateUi(Form)

        QMetaObject.connectSlotsByName(Form)
Beispiel #41
0
 def __init__(self):
     QWidget.__init__(self)
     label = QLabel(self)
     pixmap = QPixmap('images/stream-deck.jpg')
     label.setPixmap(pixmap)
class Widget(QWidget):
    def __init__(self):
        QWidget.__init__(self)

        self.index_districts = index_districts

        self.x1 = ""
        self.x3 = ""
        self.y1 = ""
        self.y3 = ""

        self.scene = QGraphicsScene()
        self.image = QGraphicsView(self.scene)
        self.image.show()
        self.submitButton = QPushButton("Submit")
        self.undoButton = QPushButton("Undo")
        self.nextReport = QPushButton("Next Report")
        self.badButton = QPushButton("BAD")
        self.goodButton = QPushButton("Good")
        self.noDataButton = QPushButton("No Data")
        self.districtText = QLineEdit("")
        self.cattleLabel = QLineEdit("Cattle:")
        self.top = QHBoxLayout()
        self.top.addWidget(self.cattleLabel)
        self.prevPageButton = QPushButton("Previous Page")
        self.nextPageButton = QPushButton("Next Page")
        self.middle = QVBoxLayout()
        self.left = QHBoxLayout()
        self.middle.setMargin(10)
        self.middle.addWidget(self.image)
        self.middle.addLayout(self.top)
        self.middle.addLayout(self.left)
        self.bottom = QHBoxLayout()
        self.left.addWidget(self.prevPageButton)
        self.left.addWidget(self.nextPageButton)
        self.middle.addWidget(self.districtText)
        self.bottom.addWidget(self.badButton)
        self.bottom.addWidget(self.noDataButton)
        self.bottom.addWidget(self.goodButton)
        self.bottom.addWidget(self.nextReport)
        self.bottom.addWidget(self.undoButton)
        self.bottom.addWidget(self.submitButton)
        self.middle.addLayout(self.bottom)

        # QWidget Layout

        self.layout = QHBoxLayout()
        self.layout.addLayout(self.middle)

        # Set the layout to the QWidget
        self.setLayout(self.layout)

        # second
        # self.data_path = "../Crop_Reports/Manual Check Crop Reports/crop_reports_verified.csv"
        # self.data = pd.read_csv(self.data_path)
        self.dir_path = "../Crop_Reports/Bengal Crop Reports PNG/"
        # connect functions
        self.nextReport.clicked.connect(self.ignore)
        self.submitButton.clicked.connect(self.submit)
        self.undoButton.clicked.connect(self.undo)
        self.nextPageButton.clicked.connect(self.nextImage)
        self.prevPageButton.clicked.connect(self.prevImage)

        self.crop_index = 0
        self.page_index = 0
        self.zoom = .2

        self.out_folder = "../Crop_Reports/Bengal Famine Data/"
        self.finished = os.listdir(self.out_folder)
        self.data = pd.read_csv("../Crop_Reports/Manual Check Crop Reports/crop_reports_verified_cleaned_is_good.csv")
        self.data.Date = pd.to_datetime(self.data.Date)
        self.data = self.data[(self.data.Date > start_date) & (self.data.Date < end_date)]

        self.columns = ["District","Date","famine_code"]
        self.bound_data = pd.DataFrame(columns = self.columns)
        self.bound_data_text = ""

        self.ocr_data_list = list()

        data = self.data
        for string in self.finished:
            string = string.split(".")[0]
            data = data[data.Path != string]



        self.reports = list(data.Path)
        self.dates = list(data.Date)
        print(u"Data index:",data.index)


        self.remain_string = "remaining folders " + str(len(self.reports))
        self.remainingLabel = QLabel(self.remain_string)
        self.left.addWidget(self.remainingLabel)

        temp_path = os.path.join(self.dir_path, self.reports[self.crop_index])
        self.report = os.listdir(temp_path)
        #self.forceLastImage()
        self.postImage()



        # Sets up drawing capabilities:
        self.image.setMouseTracking(True)
        self.image.viewport().installEventFilter(self)
        self.start = None
        self.end = None

        #something
        #self.draw_boxes()

    # error here, disregarded bc why not? :)
    def eventFilter(self, source, event):
        if event.type() == QtCore.QEvent.MouseButtonRelease and source is self.image.viewport():
            if event.button() == Qt.RightButton:
                self.nextImage()

            if event.button() == Qt.MidButton:
                self.ignore()

            if event.button() == Qt.LeftButton:
                self.draw_bounding_box()

            #print(event.pos())
            #print(self.image.mapToScene(event.pos()))






    @Slot()
    def submit(self, famine_code):
        self.postImage()


        ["District", "x1", "y1", "x3", "y3", "Date", "Raw_Text"]
        row = {'District':self.districtText.text(),'Date':self.date,'famine_code': famine_code}
        self.bound_data = self.bound_data.append(row, ignore_index= True)
        print(self.bound_data)

        self.districtText.setText("")
        cattle_label_text = "Length: " + str(len(self.bound_data.famine_code)) + ". " + str(list(self.bound_data.famine_code))
        self.cattleLabel.setText(cattle_label_text)

    @Slot()
    def undo(self):
        print(self.bound_data)
        self.bound_data.drop(self.bound_data.tail(1).index, inplace=True)

        cattle_label_text = "Length: " + str(len(self.bound_data.famine_code)) + ". " + str(list(self.bound_data.famine_code))
        self.cattleLabel.setText(cattle_label_text)

        print(self.bound_data)

    @Slot()
    def ignore(self):
        self.remain_string = "remaining folders " + str(len(self.reports)-self.crop_index-1)
        self.remainingLabel.setText(self.remain_string)

        path = self.out_folder + self.reports[self.crop_index] + ".csv"
        print(u"out path:",path)

        self.bound_data.District = self.index_districts
        self.bound_data.to_csv(path, index= False)
        self.bound_data = pd.DataFrame(columns = self.columns)


        self.crop_index = self.crop_index + 1
        self.page_index = 0
        self.postImage()
        #self.forceLastImage()
        self.postImage()






    @Slot()
    def nextImage(self):
        if ((len(self.report) - 1) > self.page_index):
            self.page_index = self.page_index + 1
        else:
            self.page_index = 0

        self.postImage()

    @Slot()
    def forceLastImage(self):
        self.page_index = (len(self.report) - 1)

    @Slot()
    def prevImage(self):
        if (1 > self.page_index):
            self.page_index = len(self.report) - 1
        else:
            self.page_index = self.page_index - 1

        self.postImage()

    def postImage(self):
        self.date = self.dates[self.crop_index]
        print(u"Date:",self.date)
        print(self.dates)
        temp_path = os.path.join(self.dir_path, self.reports[self.crop_index])
        report = os.listdir(temp_path)
        dt.sort_nicely(report)
        self.report = report
        self.ocr_data_list = dt.report_to_data(self.reports[self.crop_index])

        if (len(self.report) > 0):
            self.page = self.report[self.page_index]
            self.page_df = self.ocr_data_list[self.page_index]
            temp_path = os.path.join(self.dir_path, self.reports[self.crop_index], self.page)
            self.scene.clear()
            self.pixmap = QPixmap(temp_path)
            # adjusts zoom
            self.pixmap = self.pixmap.scaled(self.pixmap.size().width() * self.zoom,
                                             self.pixmap.size().height() * self.zoom,
                                             Qt.KeepAspectRatio)
            self.scene.addPixmap(self.pixmap)
            self.draw_bounding_box()



    # def draw_bounding_box(self, x1, y1, x3, y3):
    #
    #     start = self.image.mapToScene(x1,y1)
    #     end = self.image.mapToScene(x3,y3)
    #     len_x = end.x()-start.x()
    #     len_y = end.y()-start.y()
    #     rectItem = QGraphicsRectItem(start.x(), start.y(), len_x, len_y)
    #     self.scene.addItem(rectItem)



    def draw_bounding_box(self):
        df = self.page_df

        scale = self.zoom
        no_df = df[df.word=="redroverr2"]
        tle_df = df[df.word.str.contains("suf", na = False)]
        catt_df = df[df.word.str.contains("insuf", na=False)]
        rinder_df = df[df.word.str.contains("ind1111er", na=False)]

        for index, row in no_df.iterrows():
            print(row)
            x1 = row.x1*scale
            y1 = row.y1*scale
            x3= row.x3*scale
            y3 = row.y3*scale
            diff_x = x3-x1
            diff_y = y3-y1
            rectItem = QGraphicsRectItem(x1,y1,diff_x,diff_y)
            rectItem.setBrush(QBrush(Qt.green))
            #rectItem = QGraphicsRectItem(0, 0, 100, 100)
            self.scene.addItem(rectItem)

        for index, row in tle_df.iterrows():
            print(row)
            x1 = row.x1 * scale
            y1 = row.y1 * scale
            x3 = row.x3 * scale
            y3 = row.y3 * scale
            diff_x = x3 - x1
            diff_y = y3 - y1
            rectItem = QGraphicsRectItem(x1, y1, diff_x, diff_y)
            rectItem.setBrush(QBrush(Qt.green))
            # rectItem = QGraphicsRectItem(0, 0, 100, 100)
            self.scene.addItem(rectItem)

        for index, row in rinder_df.iterrows():
            print(row)
            x1 = row.x1 * scale
            y1 = row.y1 * scale
            x3 = row.x3 * scale
            y3 = row.y3 * scale
            diff_x = x3 - x1
            diff_y = y3 - y1
            rectItem = QGraphicsRectItem(x1, y1, diff_x, diff_y)
            rectItem.setBrush(QBrush(Qt.red))
            # rectItem = QGraphicsRectItem(0, 0, 100, 100)
            self.scene.addItem(rectItem)

        for index, row in catt_df.iterrows():
            print(row)
            x1 = row.x1 * scale
            y1 = row.y1 * scale
            x3 = row.x3 * scale
            y3 = row.y3 * scale
            diff_x = x3 - x1
            diff_y = y3 - y1
            rectItem = QGraphicsRectItem(x1, y1, diff_x, diff_y)
            rectItem.setBrush(QBrush(Qt.red))
            # rectItem = QGraphicsRectItem(0, 0, 100, 100)
            self.scene.addItem(rectItem)

        # divider_x = (max(df.x3)-min(df.x1))/2
        # week_df = df[df.word.str.contains("icient", na=False)]
        # for index, row in week_df.iterrows():
        #     week_anchor = row
        #
        #     x1 = week_anchor.x1 * scale
        #     y1 = week_anchor.y1 * scale
        #     x3 = week_anchor.x3 * scale
        #     y3 = week_anchor.y3 * scale
        #     diff_x = x3 - x1
        #     diff_y = y3 - y1
        #     rectItem = QGraphicsRectItem(x1, y1, diff_x, diff_y)
        #     rectItem.setBrush(QBrush(Qt.blue))
        #     self.scene.addItem(rectItem)

        # right_df = df[df.x1 > divider_x]
        # right_df = right_df[right_df.y1 > week_anchor.y3]
        # for index, row in right_df.iterrows():
        #     x1 = row.x1 * scale
        #     y1 = row.y1 * scale
        #     x3 = row.x3 * scale
        #     y3 = row.y3 * scale
        #     diff_x = x3 - x1
        #     diff_y = y3 - y1
        #
        #     rectItem = QGraphicsRectItem(x1, y1, diff_x, diff_y)
        #     rectItem.setBrush(QBrush(Qt.red))
        #
        #     self.scene.addItem(rectItem)

        # for district in self.index_districts:
        #     print(district)
        #     row = df[df.word.str.contains(district, na=False)]
        #
        #     if (len(row.word) != 0):
        #         x1 = row.x1 * scale
        #         y1 = row.y1 * scale
        #         x3 = row.x3 * scale
        #         y3 = row.y3 * scale
        #         diff_x = x3 - x1
        #         diff_y = y3 - y1
        #
        #         rectItem = QGraphicsRectItem(x1, y1, diff_x, diff_y)
        #         rectItem.setBrush(QBrush(Qt.red))
        #
        #         self.scene.addItem(rectItem)









    # def write_to_csv(self):
    #     new_row = {'ocr_report_path': self.reports[self.crop_index], 'date': self.districtText.text()}
    #     self.data = self.data.append(new_row, ignore_index=True)
    #     self.data.to_csv(self.data_path, index=False)

    # reformat first half of year 1910 before 10/6
    def keyPressEvent(self, event):

        if event.key() == Qt.Key_A:
            #disease
            self.submit("bad")

        if event.key() == Qt.Key_W:
            # no mention
            self.submit("NR")

        if event.key() == Qt.Key_D:
            ##not bad
            self.submit("not_bad")
Beispiel #43
0
    def setupUi(self, Dialog):
        if not Dialog.objectName():
            Dialog.setObjectName(u"Dialog")
        Dialog.resize(500, 450)
        self.stackedWidget = QStackedWidget(Dialog)
        self.stackedWidget.setObjectName(u"stackedWidget")
        self.stackedWidget.setGeometry(QRect(0, 0, 500, 450))
        self.stackedWidget.setStyleSheet(u"")
        self.page_4 = QWidget()
        self.page_4.setObjectName(u"page_4")
        self.fondo_1 = QLabel(self.page_4)
        self.fondo_1.setObjectName(u"fondo_1")
        self.fondo_1.setGeometry(QRect(0, 0, 500, 450))
        self.fondo_1.setPixmap(QPixmap(u"fondos/1234.png"))
        self.fondo_1.setScaledContents(True)
        self.frame = QFrame(self.page_4)
        self.frame.setObjectName(u"frame")
        self.frame.setGeometry(QRect(80, 90, 341, 251))
        self.frame.setStyleSheet(u"background-color: rgb(255, 255, 255);")
        self.frame.setFrameShape(QFrame.Box)
        self.frame.setFrameShadow(QFrame.Plain)
        self.frame.setLineWidth(2)
        self.la_usuario = QLabel(self.frame)
        self.la_usuario.setObjectName(u"la_usuario")
        self.la_usuario.setGeometry(QRect(20, 90, 81, 31))
        self.la_usuario.setStyleSheet(u"font: 75 14pt \"Verdana\";")
        self.la_contrasena = QLabel(self.frame)
        self.la_contrasena.setObjectName(u"la_contrasena")
        self.la_contrasena.setGeometry(QRect(20, 150, 111, 41))
        self.la_contrasena.setStyleSheet(u"font: 75 14pt \"Verdana\";")
        self.usuario = QLineEdit(self.frame)
        self.usuario.setObjectName(u"usuario")
        self.usuario.setGeometry(QRect(170, 90, 151, 31))
        self.usuario.setEchoMode(QLineEdit.Normal)
        self.contrasena = QLineEdit(self.frame)
        self.contrasena.setObjectName(u"contrasena")
        self.contrasena.setGeometry(QRect(170, 150, 151, 31))
        self.contrasena.setEchoMode(QLineEdit.Password)
        self.entrar = QPushButton(self.frame)
        self.entrar.setObjectName(u"entrar")
        self.entrar.setGeometry(QRect(200, 200, 121, 31))
        self.entrar.setStyleSheet(u"background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0.141243 rgba(18, 102, 139, 255), stop:1 rgba(255, 255, 255, 255));")
        self.la_titulo = QLabel(self.frame)
        self.la_titulo.setObjectName(u"la_titulo")
        self.la_titulo.setGeometry(QRect(130, 20, 71, 51))
        self.la_titulo.setStyleSheet(u"font: 75 italic 28pt \"Artifakt Element\";")
        self.stackedWidget.addWidget(self.page_4)
        self.page = QWidget()
        self.page.setObjectName(u"page")
        self.titulo_p2 = QLabel(self.page)
        self.titulo_p2.setObjectName(u"titulo_p2")
        self.titulo_p2.setGeometry(QRect(125, 20, 250, 71))
        self.titulo_p2.setStyleSheet(u"font: 75 italic 28pt \"Artifakt Element\";")
        self.mover_r = QPushButton(self.page)
        self.mover_r.setObjectName(u"mover_r")
        self.mover_r.setGeometry(QRect(270, 220, 161, 101))
        self.mover_r.setStyleSheet(u"background-color: rgb(255, 255, 255);")
        self.herramienta = QPushButton(self.page)
        self.herramienta.setObjectName(u"herramienta")
        self.herramienta.setGeometry(QRect(70, 220, 161, 101))
        self.herramienta.setStyleSheet(u"background-color: rgb(255, 255, 255);")
        self.fondo_2 = QLabel(self.page)
        self.fondo_2.setObjectName(u"fondo_2")
        self.fondo_2.setGeometry(QRect(0, 0, 500, 450))
        self.fondo_2.setPixmap(QPixmap(u"fondos/123.jpg"))
        self.fondo_2.setScaledContents(True)
        self.stackedWidget.addWidget(self.page)
        self.fondo_2.raise_()
        self.titulo_p2.raise_()
        self.mover_r.raise_()
        self.herramienta.raise_()
        self.page_2 = QWidget()
        self.page_2.setObjectName(u"page_2")
        self.titulo_p3 = QLabel(self.page_2)
        self.titulo_p3.setObjectName(u"titulo_p3")
        self.titulo_p3.setGeometry(QRect(100, 0, 311, 61))
        font = QFont()
        font.setFamily(u"Consolas")
        font.setPointSize(16)
        font.setBold(True)
        font.setWeight(75)
        self.titulo_p3.setFont(font)
        self.titulo_p3.setStyleSheet(u"")
        self.nodo_E = QRadioButton(self.page_2)
        self.nodo_E.setObjectName(u"nodo_E")
        self.nodo_E.setGeometry(QRect(200, 110, 100, 40))
        font1 = QFont()
        font1.setFamily(u"Consolas")
        font1.setPointSize(10)
        self.nodo_E.setFont(font1)
        self.nodo_E.setStyleSheet(u"background-color: rgb(255, 255, 255);")
        self.nodo_G = QRadioButton(self.page_2)
        self.nodo_G.setObjectName(u"nodo_G")
        self.nodo_G.setGeometry(QRect(200, 160, 100, 40))
        self.nodo_G.setFont(font1)
        self.nodo_G.setStyleSheet(u"background-color: rgb(255, 255, 255);")
        self.nodo_B = QRadioButton(self.page_2)
        self.nodo_B.setObjectName(u"nodo_B")
        self.nodo_B.setGeometry(QRect(200, 60, 100, 40))
        self.nodo_B.setFont(font1)
        self.nodo_B.setStyleSheet(u"background-color: rgb(255, 255, 255);\n"
"")
        self.nodo_H = QRadioButton(self.page_2)
        self.nodo_H.setObjectName(u"nodo_H")
        self.nodo_H.setGeometry(QRect(60, 160, 100, 40))
        self.nodo_H.setFont(font1)
        self.nodo_H.setStyleSheet(u"background-color: rgb(255, 255, 255);")
        self.nodo_C = QRadioButton(self.page_2)
        self.nodo_C.setObjectName(u"nodo_C")
        self.nodo_C.setGeometry(QRect(330, 60, 100, 40))
        self.nodo_C.setFont(font1)
        self.nodo_C.setStyleSheet(u"background-color: rgb(255, 255, 255);")
        self.nodo_D = QRadioButton(self.page_2)
        self.nodo_D.setObjectName(u"nodo_D")
        self.nodo_D.setGeometry(QRect(60, 110, 100, 40))
        self.nodo_D.setFont(font1)
        self.nodo_D.setStyleSheet(u"background-color: rgb(255, 255, 255);")
        self.nodo_F = QRadioButton(self.page_2)
        self.nodo_F.setObjectName(u"nodo_F")
        self.nodo_F.setGeometry(QRect(330, 110, 100, 40))
        self.nodo_F.setFont(font1)
        self.nodo_F.setStyleSheet(u"background-color: rgb(255, 255, 255);")
        self.nodo_I = QRadioButton(self.page_2)
        self.nodo_I.setObjectName(u"nodo_I")
        self.nodo_I.setGeometry(QRect(330, 160, 100, 40))
        self.nodo_I.setFont(font1)
        self.nodo_I.setStyleSheet(u"background-color: rgb(255, 255, 255);\n"
"")
        self.nodo_A = QRadioButton(self.page_2)
        self.nodo_A.setObjectName(u"nodo_A")
        self.nodo_A.setGeometry(QRect(60, 60, 100, 40))
        self.nodo_A.setFont(font1)
        self.nodo_A.setStyleSheet(u"background-color: rgb(255, 255, 255);")
        self.boton_inicio = QPushButton(self.page_2)
        self.boton_inicio.setObjectName(u"boton_inicio")
        self.boton_inicio.setGeometry(QRect(60, 250, 91, 41))
        self.boton_inicio.setAutoFillBackground(False)
        self.boton_inicio.setStyleSheet(u"border-color: rgb(0, 0, 0);\n"
"background-color: rgb(255, 255, 0);\n"
"font: 9pt \"Consolas\";")
        self.boton_fin = QPushButton(self.page_2)
        self.boton_fin.setObjectName(u"boton_fin")
        self.boton_fin.setGeometry(QRect(60, 300, 91, 41))
        self.boton_fin.setStyleSheet(u"border-color: rgb(0, 0, 0);\n"
"background-color: rgb(255, 255, 0);\n"
"font: 9pt \"Consolas\";")
        self.opc_inicio = QLineEdit(self.page_2)
        self.opc_inicio.setObjectName(u"opc_inicio")
        self.opc_inicio.setGeometry(QRect(160, 260, 113, 20))
        self.opc_inicio.setStyleSheet(u"border-color: rgb(0, 0, 0);\n"
"background-color: rgb(255, 255, 255);")
        self.opc_fin = QLineEdit(self.page_2)
        self.opc_fin.setObjectName(u"opc_fin")
        self.opc_fin.setGeometry(QRect(160, 310, 113, 20))
        self.opc_fin.setStyleSheet(u"border-color: rgb(0, 0, 0);\n"
"background-color: rgb(255, 255, 255);")
        self.btn_clear = QPushButton(self.page_2)
        self.btn_clear.setObjectName(u"btn_clear")
        self.btn_clear.setGeometry(QRect(330, 290, 131, 51))
        font2 = QFont()
        font2.setFamily(u"Consolas")
        font2.setPointSize(10)
        font2.setBold(True)
        font2.setWeight(75)
        font2.setStrikeOut(False)
        self.btn_clear.setFont(font2)
        self.btn_clear.setStyleSheet(u"\n"
"background-color: rgb(0, 255, 255);")
        self.confirmar_n = QPushButton(self.page_2)
        self.confirmar_n.setObjectName(u"confirmar_n")
        self.confirmar_n.setGeometry(QRect(330, 370, 121, 51))
        self.confirmar_n.setStyleSheet(u"background-color: rgb(0, 255, 0);\n"
"font: 75 italic 10pt \"Consolas\";\n"
"")
        self.mostrar_grafico = QPushButton(self.page_2)
        self.mostrar_grafico.setObjectName(u"mostrar_grafico")
        self.mostrar_grafico.setGeometry(QRect(60, 370, 111, 51))
        self.mostrar_grafico.setStyleSheet(u"border-color: rgb(0, 0, 0);\n"
"background-color: rgb(87, 86, 86);\n"
"font: 9pt \"Consolas\";")
        self.back = QPushButton(self.page_2)
        self.back.setObjectName(u"back")
        self.back.setGeometry(QRect(190, 370, 111, 51))
        self.back.setStyleSheet(u"background-color: rgb(170, 170, 255);\n"
"font: 10pt \"Consolas\";")
        self.fondo_3 = QLabel(self.page_2)
        self.fondo_3.setObjectName(u"fondo_3")
        self.fondo_3.setGeometry(QRect(0, 0, 500, 450))
        self.fondo_3.setPixmap(QPixmap(u"fondos/123.jpg"))
        self.fondo_3.setScaledContents(True)
        self.stackedWidget.addWidget(self.page_2)
        self.fondo_3.raise_()
        self.titulo_p3.raise_()
        self.nodo_E.raise_()
        self.nodo_G.raise_()
        self.nodo_B.raise_()
        self.nodo_H.raise_()
        self.nodo_C.raise_()
        self.nodo_D.raise_()
        self.nodo_F.raise_()
        self.nodo_I.raise_()
        self.nodo_A.raise_()
        self.boton_inicio.raise_()
        self.boton_fin.raise_()
        self.opc_inicio.raise_()
        self.opc_fin.raise_()
        self.btn_clear.raise_()
        self.confirmar_n.raise_()
        self.mostrar_grafico.raise_()
        self.back.raise_()
        self.page_3 = QWidget()
        self.page_3.setObjectName(u"page_3")
        self.titulo_p4 = QLabel(self.page_3)
        self.titulo_p4.setObjectName(u"titulo_p4")
        self.titulo_p4.setGeometry(QRect(110, 0, 241, 41))
        font3 = QFont()
        font3.setFamily(u"MS Shell Dlg 2")
        font3.setPointSize(24)
        font3.setBold(False)
        font3.setItalic(False)
        font3.setWeight(50)
        self.titulo_p4.setFont(font3)
        self.titulo_p4.setStyleSheet(u"font: 24pt \"MS Shell Dlg 2\";")
        self.titulo_p4.setAlignment(Qt.AlignCenter)
        self.irconfimov = QPushButton(self.page_3)
        self.irconfimov.setObjectName(u"irconfimov")
        self.irconfimov.setGeometry(QRect(390, 390, 91, 41))
        self.irconfimov.setStyleSheet(u"background-color: rgb(255, 85, 0);\n"
"font: 75 10pt \"Consolas\";")
        self.imagen = QLabel(self.page_3)
        self.imagen.setObjectName(u"imagen")
        self.imagen.setGeometry(QRect(90, 40, 301, 161))
        self.imagen.setFrameShape(QFrame.Box)
        self.fondo_4 = QLabel(self.page_3)
        self.fondo_4.setObjectName(u"fondo_4")
        self.fondo_4.setGeometry(QRect(0, 0, 500, 450))
        self.fondo_4.setPixmap(QPixmap(u"fondos/123.jpg"))
        self.fondo_4.setScaledContents(True)
        self.verificacion = QLineEdit(self.page_3)
        self.verificacion.setObjectName(u"verificacion")
        self.verificacion.setGeometry(QRect(10, 310, 201, 31))
        self.label = QLabel(self.page_3)
        self.label.setObjectName(u"label")
        self.label.setGeometry(QRect(10, 270, 201, 31))
        self.label.setStyleSheet(u"font: 75 14pt \"Consolas\";")
        self.lista_nodos = QLineEdit(self.page_3)
        self.lista_nodos.setObjectName(u"lista_nodos")
        self.lista_nodos.setGeometry(QRect(10, 240, 201, 31))
        self.label_3 = QLabel(self.page_3)
        self.label_3.setObjectName(u"label_3")
        self.label_3.setGeometry(QRect(10, 210, 151, 21))
        self.label_3.setStyleSheet(u"font: 75 14pt \"Consolas\";")
        self.label_5 = QLabel(self.page_3)
        self.label_5.setObjectName(u"label_5")
        self.label_5.setGeometry(QRect(10, 350, 121, 21))
        self.label_5.setStyleSheet(u"font: 75 14pt \"Consolas\";")
        self.direccion = QLineEdit(self.page_3)
        self.direccion.setObjectName(u"direccion")
        self.direccion.setGeometry(QRect(10, 380, 201, 41))
        self.stackedWidget.addWidget(self.page_3)
        self.fondo_4.raise_()
        self.titulo_p4.raise_()
        self.irconfimov.raise_()
        self.imagen.raise_()
        self.verificacion.raise_()
        self.label.raise_()
        self.lista_nodos.raise_()
        self.label_3.raise_()
        self.label_5.raise_()
        self.direccion.raise_()

        self.retranslateUi(Dialog)

        self.stackedWidget.setCurrentIndex(3)


        QMetaObject.connectSlotsByName(Dialog)
Beispiel #44
0
 def pixmap(self, size=QSize(512, 512), mode=None, state=None):
     pm = QPixmap(size)
     pm.fill(Qt.transparent)
     self.paint(QPainter(pm), QRect(QPoint(0, 0), size), mode, state)
     return pm
Beispiel #45
0
    def update_scene(self, meta_frame):
        """
        Updates the image_label with a new opencv image.

        Args:
            meta_frame: MetaFrame Object
        """

        # Get frame and other data from meta_frame
        frame = meta_frame.frame
        peaks = meta_frame.peaks
        tracks = meta_frame.tracks

        # Get display_options from main_window
        display_options = self.main_window.display_options

        # Get display dimensions
        self.display_height = self.image_label.height()
        self.display_width = self.image_label.width()

        # Adjust the scale factor
        scale_factor = self.display_height / 256

        # Convert frame to qt image
        pm_img = convert_cv_qt(frame, self.display_width, self.display_height)

        # Start painter
        painter = QPainter()
        painter.begin(pm_img)

        # Create pen
        pen = QtGui.QPen()
        pen.setWidth(2)
        pen.setColor(QtGui.QColor(204, 0, 0))  # r, g, b
        painter.setPen(pen)

        if display_options["show_tracks"] == True:
            # Plot peaks with centered
            for point in peaks:
                painter.drawEllipse((point[0] * scale_factor) - 4,
                                    (point[1] * scale_factor) - 4, 8, 8)

        pen.setWidth(2)
        pen.setColor(QtGui.QColor(0, 0, 255))

        if display_options["show_labels"] == True:
            # Draw tracked objects labels
            for label, trace in tracks.items():
                if len(trace) > 1:
                    # Assign random color for different tracks.
                    color = get_random_color(int(label))
                    qcolor = QColor()
                    qcolor.setNamedColor(color)
                    pen.setColor(qcolor)
                    painter.setPen(pen)
                    label = label
                    label_pos_x = trace[-1][0][0] * scale_factor + 10
                    label_pos_y = trace[-1][0][1] * scale_factor + 10
                    painter.drawText(label_pos_x, label_pos_y, label)

        if display_options["show_traces"] == True:
            # For identified object tracks draw tracking line
            # Use various colors to indicate different track_id
            for label, trace in tracks.items():
                if len(trace) > 1:
                    # Assign random color for different tracks.
                    color = get_random_color(int(label))
                    qcolor = QColor()
                    qcolor.setNamedColor(color)
                    pen.setColor(qcolor)
                    painter.setPen(pen)
                    limit = 0
                    if len(trace) > 200:
                        limit = len(trace) - 200
                    for j in range(limit, len(trace) - 1):
                        # Draw trace line
                        x1 = trace[j][0][0] * scale_factor
                        y1 = trace[j][0][1] * scale_factor
                        x2 = trace[j + 1][0][0] * scale_factor
                        y2 = trace[j + 1][0][1] * scale_factor
                        painter.drawLine(int(x1), int(y1), int(x2), int(y2))

        painter.setCompositionMode(QPainter.CompositionMode_SourceOver)
        # painter.drawImage(0, 0, pix_map)
        painter.end()
        # label = QLabel()
        self.image_label.setPixmap(QPixmap.fromImage(pm_img))
Beispiel #46
0
    def __set_interface(self):
        self.button_width = 0.35
        self.button_height = 0.05

        self.setWindowTitle("GSI-RADS")
        self.__getScreenDimensions()

        self.setGeometry(self.left, self.top, self.width, self.height)
        self.setMaximumWidth(self.width)
        #self.setMaximumHeight(self.height)
        self.setMinimumWidth(self.width)
        self.setMinimumHeight(self.height)
        self.move(self.width / 2, self.height / 2)

        self.menu_bar = QMenuBar(self)
        self.menu_bar.setNativeMenuBar(
            False
        )  # https://stackoverflow.com/questions/25261760/menubar-not-showing-for-simple-qmainwindow-code-qt-creator-mac-os
        self.file_menu = self.menu_bar.addMenu('File')
        self.import_dicom_action = QAction(
            QIcon(
                os.path.join(os.path.dirname(os.path.realpath(__file__)),
                             'images/database-icon.png')), 'Import DICOM',
            self)
        self.import_dicom_action.setShortcut('Ctrl+D')
        self.file_menu.addAction(self.import_dicom_action)
        self.quit_action = QAction('Quit', self)
        self.quit_action.setShortcut("Ctrl+Q")
        self.file_menu.addAction(self.quit_action)

        self.settings_menu = self.menu_bar.addMenu('Settings')
        self.settings_seg_menu = self.settings_menu.addMenu("Segmentation...")
        self.settings_seg_preproc_menu = self.settings_seg_menu.addMenu(
            "Preprocessing...")
        self.settings_seg_preproc_menu_p1_action = QAction(
            "Brain-masking off (P1)", checkable=True)
        self.settings_seg_preproc_menu_p2_action = QAction(
            "Brain-masking on (P2)", checkable=True)
        self.settings_seg_preproc_menu_p2_action.setChecked(True)
        self.settings_seg_preproc_menu.addAction(
            self.settings_seg_preproc_menu_p1_action)
        self.settings_seg_preproc_menu.addAction(
            self.settings_seg_preproc_menu_p2_action)

        self.help_menu = self.menu_bar.addMenu('Help')
        self.readme_action = QAction(
            QIcon(
                os.path.join(os.path.dirname(os.path.realpath(__file__)),
                             'images/readme-icon.jpeg')), 'Tutorial', self)
        self.readme_action.setShortcut("Ctrl+R")
        self.help_menu.addAction(self.readme_action)
        self.about_action = QAction(
            QIcon(
                os.path.join(os.path.dirname(os.path.realpath(__file__)),
                             'images/about-icon.png')), 'About', self)
        self.about_action.setShortcut("Ctrl+A")
        self.help_menu.addAction(self.about_action)
        self.help_action = QAction(
            QIcon.fromTheme("help-faq"), "Help", self
        )  # Default icons can be found here: https://specifications.freedesktop.org/icon-naming-spec/icon-naming-spec-latest.html#guidelines
        self.help_action.setShortcut("Ctrl+J")
        self.help_menu.addAction(self.help_action)

        self.input_image_lineedit = QLineEdit()
        self.input_image_lineedit.setFixedWidth(self.width *
                                                (0.93 - self.button_width / 2))
        self.input_image_lineedit.setFixedHeight(self.height *
                                                 self.button_height)
        self.input_image_lineedit.setReadOnly(True)
        self.input_image_pushbutton = QPushButton('Input MRI')
        self.input_image_pushbutton.setFixedWidth(self.height *
                                                  self.button_width)
        self.input_image_pushbutton.setFixedHeight(self.height *
                                                   self.button_height)

        self.input_segmentation_lineedit = QLineEdit()
        self.input_segmentation_lineedit.setReadOnly(True)
        self.input_segmentation_lineedit.setFixedWidth(
            self.width * (0.93 - self.button_width / 2))
        self.input_segmentation_lineedit.setFixedHeight(self.height *
                                                        self.button_height)
        self.input_segmentation_pushbutton = QPushButton('Input segmentation')
        self.input_segmentation_pushbutton.setFixedWidth(self.height *
                                                         self.button_width)
        self.input_segmentation_pushbutton.setFixedHeight(self.height *
                                                          self.button_height)

        self.output_folder_lineedit = QLineEdit()
        self.output_folder_lineedit.setReadOnly(True)
        self.output_folder_lineedit.setFixedWidth(
            self.width * (0.93 - self.button_width / 2))
        self.output_folder_lineedit.setFixedHeight(self.height *
                                                   self.button_height)
        self.output_folder_pushbutton = QPushButton('Output destination')
        self.output_folder_pushbutton.setFixedWidth(self.height *
                                                    self.button_width)
        self.output_folder_pushbutton.setFixedHeight(self.height *
                                                     self.button_height)

        self.run_button = QPushButton('Run diagnosis')
        self.run_button.setFixedWidth(self.height * self.button_width)
        self.run_button.setFixedHeight(self.height * self.button_height)

        self.main_display_tabwidget = QTabWidget()

        self.tutorial_textedit = QPlainTextEdit()
        self.tutorial_textedit.setReadOnly(True)
        self.tutorial_textedit.setFixedWidth(self.width * 0.97)
        self.tutorial_textedit.setPlainText(
            "HOW TO USE THE SOFTWARE: \n"
            "  1) Click 'Input MRI...' to select from your file explorer the MRI scan to process (unique file).\n"
            "  1*) Alternatively, Click File > Import DICOM... if you wish to process an MRI scan as a DICOM sequence.\n"
            "  2) Click 'Output destination' to choose a directory where to save the results \n"
            "  3) (OPTIONAL) Click 'Input segmentation' to choose a tumor segmentation mask file, if nothing is provided the internal model with generate the segmentation automatically \n"
            "  4) Click 'Run diagnosis' to perform the analysis. The human-readable version will be displayed in the interface.\n"
            " \n"
            "NOTE: \n"
            "The output folder is populated automatically with the following: \n"
            "  * The diagnosis results in human-readable text (report.txt) and Excel-ready format (report.csv).\n"
            "  * The automatic segmentation masks of the brain and the tumor in the original patient space (input_brain_mask.nii.gz and input_tumor_mask.nii.gz).\n"
            "  * The input volume and tumor segmentation mask in MNI space in the sub-directory named \'registration\'.\n"
        )
        self.main_display_tabwidget.addTab(self.tutorial_textedit, 'Tutorial')
        self.prompt_lineedit = QPlainTextEdit()
        self.prompt_lineedit.setReadOnly(True)
        self.prompt_lineedit.setFixedWidth(self.width * 0.97)
        self.main_display_tabwidget.addTab(self.prompt_lineedit, 'Logging')
        self.results_textedit = QPlainTextEdit()
        self.results_textedit.setReadOnly(True)
        self.results_textedit.setFixedWidth(self.width * 0.97)
        self.main_display_tabwidget.addTab(self.results_textedit, 'Results')

        self.sintef_logo_label = QLabel()
        self.sintef_logo_label.setPixmap(
            QPixmap(
                os.path.join(os.path.dirname(os.path.realpath(__file__)),
                             'images/sintef-logo.png')))
        self.sintef_logo_label.setFixedWidth(0.95 * (self.width / 3))
        self.sintef_logo_label.setFixedHeight(
            1 * (self.height * self.button_height))
        self.sintef_logo_label.setScaledContents(True)
        self.stolavs_logo_label = QLabel()
        self.stolavs_logo_label.setPixmap(
            QPixmap(
                os.path.join(os.path.dirname(os.path.realpath(__file__)),
                             'images/stolavs-logo.png')))
        self.stolavs_logo_label.setFixedWidth(0.95 * (self.width / 3))
        self.stolavs_logo_label.setFixedHeight(
            1 * (self.height * self.button_height))
        self.stolavs_logo_label.setScaledContents(True)
        self.amsterdam_logo_label = QLabel()
        self.amsterdam_logo_label.setPixmap(
            QPixmap(
                os.path.join(os.path.dirname(os.path.realpath(__file__)),
                             'images/amsterdam-logo.png')))
        self.amsterdam_logo_label.setFixedWidth(0.95 * (self.width / 3))
        self.amsterdam_logo_label.setFixedHeight(
            1 * (self.height * self.button_height))
        self.amsterdam_logo_label.setScaledContents(True)