Exemplo n.º 1
0
    def initUI(self):
        self.setWindowTitle(self.title)
        self.setGeometry(self.left, self.top, self.width, self.height)

        labelList = [QLabel(self) for i in range(9)]
        print(labelList)
        # pixmapList = [QPixmap('./images/' + str(i) + '.png') for i in range(9)]
        #
        # for i in range(9):
        #     pixmapList[i].scaledToHeight(200)
        #     pixmapList[i].scaledToWidth(200)
        #     labelList[i].setPixmap(pixmapList[i])

        label = QLabel(self)
        pixmap = QPixmap('./images/4.png')
        pixmap = pixmap.scaledToHeight(200)
        label.setPixmap(pixmap)

        label2 = QLabel(self)
        pixmap2 = QPixmap('./images/5.png')
        pixmap2 = pixmap2.scaledToHeight(200)
        label2.setPixmap(pixmap2)
        label2.move(200, 0)

        # count = 0
        # for i in range(3):
        #     for j in range(3):
        #         labelList[count].move(j * 200, i * 200)
        #         count += 1

        self.resize(600, 600)
        self.show()
Exemplo n.º 2
0
    def display_results(self, full, partial, table_results):

        for i in range(full):
            
            label = QLabel()
            label.setFixedSize(64, 64)
            label.setAlignment(Qt.AlignCenter)

            pixmap = QPixmap('icons/bingo.png')
            pixmap = pixmap.scaledToHeight(34)
            pixmap = pixmap.scaledToWidth(34)

            label.setPixmap(pixmap)

            table_results.setCellWidget(self.current_row, i, label)

        for i in range(partial):
            
            label = QLabel()
            label.setFixedSize(64, 64)
            label.setAlignment(Qt.AlignCenter)

            pixmap = QPixmap('icons/almost.png')
            pixmap = pixmap.scaledToHeight(34)
            pixmap = pixmap.scaledToWidth(34)

            label.setPixmap(pixmap)

            table_results.setCellWidget(self.current_row, i, label)
Exemplo n.º 3
0
 def testClick(self):
     path = self.searchBar.text()
     self.searchBar.setText("")
     self.saveURL = self.saveURL + path + "\n"
     url_data = urllib.request.urlopen(path).read()
     tmpPixmap = QPixmap()
     tmpPixmap.loadFromData(url_data)
     if(tmpPixmap.height() > self.height * 3 / 4):
         tmpPixmap = tmpPixmap.scaledToHeight(self.height * 3 / 4)
     if(tmpPixmap.width() > self.width * 3 / 4):
         tmpPixmap = tmpPixmap.scaledToWidth(self.width * 3 / 4)
     self.bigPixList.append(tmpPixmap)
     if(tmpPixmap.height() > self.height / 6 - 10):
         tmpPixmap = tmpPixmap.scaledToHeight(self.height / 6 - 10)
     if(tmpPixmap.width() > self.width / 6 - 10):
         tmpPixmap = tmpPixmap.scaledToWidth(self.width / 6 - 10)
     self.pixList.append(tmpPixmap)
     for i in range(-1,4,1):
         self.label[i + 1].setPixmap(self.pixList[i % len(self.pixList)])
     self.label[self.colorIndex].setStyleSheet('background-color: red')
     self.index = -1
     self.colorIndex = 0
     self.leftBreak = -1
     self.rightBreak = 3
     self.label[self.colorIndex].setStyleSheet('background-color: blue')
     self.tagLabels.append(self.tagLabels[i])
     self.tagLabels[-1 % len(self.pixList)].setText("")
     self.bigLabel.setPixmap(self.bigPixList[-1 % len(self.pixList)])
     self.setFocus()
Exemplo n.º 4
0
 def loadURLS(self):
     f = open('SavedURLS.txt','r')
     tempString = f.read()
     self.savedURLS = tempString
     tempString2 = tempString.split("\n")
     for i in range(0, len(tempString2)-1, 1):
         url_data = urllib.request.urlopen(tempString2[i]).read()
         tmpPixmap = QPixmap()
         tmpPixmap.loadFromData(url_data)
         if(tmpPixmap.height() > self.height * 3 / 4):
             tmpPixmap = tmpPixmap.scaledToHeight(self.height * 3 / 4)
         if(tmpPixmap.width() > self.width * 3 / 4):
             tmpPixmap = tmpPixmap.scaledToWidth(self.width * 3 / 4)
         self.bigPixList.append(tmpPixmap)
         if(tmpPixmap.height() > self.height / 6 - 10):
             tmpPixmap = tmpPixmap.scaledToHeight(self.height / 6 - 10)
         if(tmpPixmap.width() > self.width / 6 - 10):
             tmpPixmap = tmpPixmap.scaledToWidth(self.width / 6 - 10)
         self.pixList.append(tmpPixmap)
         self.tagLabels.append(QLabel(self))
         self.currentString.append("")
         self.tagLabels[len(self.pixList)-1].resize(self.width / 8, self.height)
         self.tagLabels[len(self.pixList)-1].move(self.width * 7 / 8, 0)
         self.tagLabels[len(self.pixList)-1].setStyleSheet('border-color: grey; border-style: outset; border-width: 5px; font:bold 14px; color: white')
         self.tagLabels[len(self.pixList)-1].setAlignment(Qt.AlignTop)
         self.tagLabels[len(self.pixList)-1].hide()
    def initUI(self):

        grid = QGridLayout()
        #hbox = QHBoxLayout()

        x_image = QLabel(self)
        x_pixmap = QPixmap("x_image.png")
        #x_image.setPixmap(x_pixmap)
        x_pixmap_resize = x_pixmap.scaledToHeight(300)
        x_image.setPixmap(x_pixmap_resize)

        y_image = QLabel(self)
        y_pixmap = QPixmap("y_image.png")
        #y_image.setPixmap(y_pixmap)
        y_pixmap_resize = y_pixmap.scaledToHeight(300)
        y_image.setPixmap(y_pixmap_resize)

        z_image = QLabel(self)
        z_pixmap = QPixmap("z_image.png")
        #z_image.setPixmap(z_pixmap)
        z_pixmap_resize = z_pixmap.scaledToHeight(300)
        z_image.setPixmap(z_pixmap_resize)

        #x_image.resize(0.5*x_pixmap.width(), 0.5*x_pixmap.height())
        #x_image.setFrameShape(QFrame.StyledPanel)
        #x_image.setLineWidth(3)
        grid.addWidget(x_image, 0, 0)
        grid.addWidget(y_image, 1, 0)
        grid.addWidget(z_image, 1, 1)

        self.setLayout(grid)
Exemplo n.º 6
0
    def _blackjack_show_cards(self):
        for key in ["cards1", "cards2"]:
            for widget in self.blackjack_game_widgets[key]:
                widget.setParent(None)

        cards1 = self.game_blackjack.get_dealer_cards()
        cards2 = self.game_blackjack.get_you_cards()
        dealer_len = len(cards1)
        for i in range(dealer_len):
            card_pic = QLabel(self)
            pix = QPixmap("../res/images/cards/" +
                          cards1[i].get_png_file_name())
            pix1 = pix.scaledToHeight(130)
            card_pic.setPixmap(pix1)
            card_pic.setGeometry(310 - 50 * dealer_len + i * 100, 180, 100,
                                 130)
            card_pic.show()
            self.blackjack_game_widgets["cards1"].append(card_pic)

        you_len = len(cards2)
        for i in range(you_len):
            card_pic = QLabel(self)
            pix = QPixmap("../res/images/cards/" +
                          cards2[i].get_png_file_name())
            pix1 = pix.scaledToHeight(130)
            card_pic.setPixmap(pix1)
            card_pic.setGeometry(310 - 50 * you_len + i * 100, 450, 100, 130)
            card_pic.show()
            self.blackjack_game_widgets["cards2"].append(card_pic)
Exemplo n.º 7
0
    def initUI(self):
        #Button
        self.howtoplayButton = QPushButton('How to Play the Game?')
        self.startButton = QPushButton('Start Game!')
        self.pluscoinButton = QPushButton('see adv to get COIN!')
        self.endButton = QPushButton('End Game')

        #gamename image
        self.gnimgLabel = QLabel()
        self.setMinimumHeight(95)
        self.setMinimumWidth(200)
        pm = QPixmap('gamename.png')
        pm = pm.scaledToHeight(95)
        self.gnimgLabel.setPixmap(pm)

        #coin image
        self.cimgLabel = QLabel()
        self.setMinimumHeight(95)
        self.setMinimumWidth(95)
        pixmap = QPixmap('coin.png')
        pixmap = pixmap.scaledToHeight(75)
        self.cimgLabel.setPixmap(pixmap)

        #coin text
        self.cLabel = QLabel()
        font = self.cLabel.font()
        font.setPointSize(font.pointSize() + 10)
        self.cLabel.setFont(font)
        self.cLabel.setStyleSheet('color:white')
        self.cLabel.setText("X {} ".format(self.text))

        #main : grid / coint : coinBox/ button : buttonGrid
        self.grid = QGridLayout()
        self.coinBox = QHBoxLayout()

        self.coinBox.addWidget(self.gnimgLabel)
        self.coinBox.addStretch(1)
        self.coinBox.addWidget(self.cimgLabel)
        self.coinBox.addWidget(self.cLabel)

        self.buttonGrid = QGridLayout()

        self.grid.addLayout(self.coinBox, 0, 1)
        self.grid.addLayout(self.buttonGrid, 1, 0, 4, 0)

        self.buttonGrid.addWidget(self.howtoplayButton, 0, 0, 2, 2)
        self.buttonGrid.addWidget(self.startButton, 1, 0, 2, 2)
        self.buttonGrid.addWidget(self.pluscoinButton, 2, 0, 2, 2)
        self.buttonGrid.addWidget(self.endButton, 3, 0, 2, 2)

        #button을 눌렀을 때
        self.howtoplayButton.clicked.connect(self.howtoplay)
        self.startButton.clicked.connect(self.next)
        self.pluscoinButton.clicked.connect(self.coin)
        self.endButton.clicked.connect(self.end)

        self.setLayout(self.grid)
        self.setGeometry(500, 150, 900, 700)
        self.setWindowTitle('Main')
        self.show()
Exemplo n.º 8
0
def add_image(widget,
              img_name,
              img_type,
              width=0,
              height=0,
              name=None,
              align=None):

    img_name = load_image(img_name, img_type)

    # robust check, if valid file name
    if not os.path.isfile(img_name):
        img_name = os.getcwd() + "/src/img/default.jpg"

    label = add_label(widget, "", name=name, align=align)

    dpm = 300 / 0.0254  # ~300 DPI

    pix_map = QPixmap(img_name)

    # Optional, resize window to image size
    if width and not height:
        pix_map = pix_map.scaledToWidth(width)
    elif not width and height:
        pix_map = pix_map.scaledToHeight(height)
    elif width and height:
        if width >= height:
            pix_map = pix_map.scaledToWidth(width)
        else:
            pix_map = pix_map.scaledToHeight(height)

    label.setPixmap(pix_map)

    return label
Exemplo n.º 9
0
    def getArticleImage(self, index):  #imagelinks = getImageLinks
        targetImageLink = self.getImageLinks(self.getArticleLink())[index]
        imageFromWeb = urllib.request.urlopen(targetImageLink).read() #웹 이미지 url을 읽어서 파일로 열기
        ArticleImage = QPixmap()
        ArticleImage.loadFromData(imageFromWeb)
        ArticleImage.scaledToHeight(160)

        return ArticleImage
Exemplo n.º 10
0
 def CambiarImagenOriginal(self, costa):
     if costa != None:
         imagen = QPixmap('Recursos/' + costa)
     else:
         imagen = QPixmap('')
     imagen.scaledToWidth(371)
     imagen.scaledToHeight(321)
     self.labelImagenOriginal.setPixmap(imagen)
    def centralWindow(self):
        # Read image, resize to fit into window then add to GroupBox
        # Frontal plane image
        groupBox1 = QGroupBox("Sagittal Plane:")
        x_image = QLabel(self)
        x_pixmap = QPixmap("x_image.png")
        x_pixmap_resize = x_pixmap.scaledToHeight(256)
        x_image.setPixmap(x_pixmap_resize)
        x_image.setCursor(QCursor(Qt.CrossCursor))  # To change shape of cursor
        vbox1 = QVBoxLayout()
        vbox1.addWidget(x_image)
        groupBox1.setLayout(vbox1)

        # Sagittal plane image
        groupBox2 = QGroupBox("Frontal Plane:")
        y_image = QLabel(self)
        y_pixmap = QPixmap("y_image.png")
        y_pixmap_resize = y_pixmap.scaledToHeight(256)
        y_image.setPixmap(y_pixmap_resize)
        y_image.setCursor(QCursor(Qt.CrossCursor))
        vbox2 = QVBoxLayout()
        vbox2.addWidget(y_image)
        groupBox2.setLayout(vbox2)

        # Transverse plane image
        groupBox3 = QGroupBox("Transverse Plane:")
        z_image = QLabel(self)
        z_pixmap = QPixmap("z_image.png")
        z_pixmap_resize = z_pixmap.scaledToHeight(256)
        z_image.setPixmap(z_pixmap_resize)
        z_image.setCursor(QCursor(Qt.CrossCursor))
        vbox3 = QVBoxLayout()
        vbox3.addWidget(z_image)
        groupBox3.setLayout(vbox3)

        # Extract patient details from medical image dataset
        groupBox4 = QGroupBox("Patient Details:")
        patient_name = QLabel("Patient's Name...: ")
        patient_id = QLabel("Patient's ID.......: ")
        data_size = QLabel("Pixel Data Size....: ")

        vbox4 = QVBoxLayout()
        vbox4.addWidget(patient_name)
        vbox4.addWidget(patient_id)
        vbox4.addWidget(data_size)
        vbox4.addStretch(2)
        groupBox4.setLayout(vbox4)

        # Display all GroupBox in grid
        grid = QGridLayout()
        grid.addWidget(groupBox1, 1, 1)
        grid.addWidget(groupBox2, 1, 0)
        grid.addWidget(groupBox3, 0, 0)
        grid.addWidget(groupBox4, 0, 1)

        self.setLayout(grid)
Exemplo n.º 12
0
 def set_image(self):
     pixmap1 = QPixmap(self.file_path)
     pixmap1.scaledToWidth(400)
     pixmap1.scaledToHeight(540)
     self.IMG1.setPixmap(pixmap1)
     frame = cv2.cvtColor(self.image, cv2.COLOR_BGR2RGB)
     image = QImage(frame, frame.shape[1], frame.shape[0], frame.strides[0],
                    QImage.Format_RGB888)
     format_image = QPixmap.fromImage(image)
     format_image.scaledToWidth(400)
     self.IMG2.setPixmap(format_image)
Exemplo n.º 13
0
    def __init__(self, project, table_data_browser):
        super().__init__()
        self.project = project
        self.table_data_browser = table_data_browser

        self.setModal(True)

        # values_list will contain the different values of each selected tag
        self.values_list = [[], []]
        self.list_tags = []

        self.label_tags = QLabel('Tags: ')

        # Each push button will allow the user to add a tag to the count table
        push_button_tag_1 = QPushButton()
        push_button_tag_1.setText("Tag n°1")
        push_button_tag_1.clicked.connect(lambda: self.select_tag(0))

        push_button_tag_2 = QPushButton()
        push_button_tag_2.setText("Tag n°2")
        push_button_tag_2.clicked.connect(lambda: self.select_tag(1))

        # The list of all the push buttons (the user can add as many as he or she wants)
        self.push_buttons = []
        self.push_buttons.insert(0, push_button_tag_1)
        self.push_buttons.insert(1, push_button_tag_2)

        # Labels to add/remove a tag (a push button)
        self.remove_tag_label = ClickableLabel()
        remove_tag_picture = QPixmap(os.path.relpath(os.path.join("..", "sources_images", "red_minus.png")))
        remove_tag_picture = remove_tag_picture.scaledToHeight(20)
        self.remove_tag_label.setPixmap(remove_tag_picture)
        self.remove_tag_label.clicked.connect(self.remove_tag)

        self.add_tag_label = ClickableLabel()
        self.add_tag_label.setObjectName('plus')
        add_tag_picture = QPixmap(os.path.relpath(os.path.join("..", "sources_images", "green_plus.png")))
        add_tag_picture = add_tag_picture.scaledToHeight(15)
        self.add_tag_label.setPixmap(add_tag_picture)
        self.add_tag_label.clicked.connect(self.add_tag)

        # Combobox to choose if the sort order is ascending or descending
        self.combo_box = QComboBox()
        self.combo_box.addItems(["Ascending", "Descending"])

        # Push button that is pressed to launch the computations
        self.push_button_sort = QPushButton()
        self.push_button_sort.setText('Sort scans')
        self.push_button_sort.clicked.connect(self.sort_scans)

        # Layouts
        self.v_box_final = QVBoxLayout()
        self.setLayout(self.v_box_final)
        self.refresh_layout()
Exemplo n.º 14
0
 def image_resize(pixmap: QPixmap, min_size, max_size) -> QPixmap:
     from_width, from_height = pixmap.width(), pixmap.height()
     if max(from_width, from_height) > max_size:
         if from_height > from_width:
             pixmap = pixmap.scaledToHeight(max_size)
         else:
             pixmap = pixmap.scaledToWidth(max_size)
     if min(from_height, from_width) < min_size:
         if from_height > from_width:
             pixmap = pixmap.scaledToWidth(min_size)
         else:
             pixmap = pixmap.scaledToHeight(min_size)
     return pixmap
Exemplo n.º 15
0
 def load_image_decode(self):
     dialog = QFileDialog()
     fname = dialog.getOpenFileName(None, "Window name", "",
                                    "Image (*.bmp *.png)")
     self.img_decode_path = fname[0]
     self.inputFileDecode.setText(self.img_decode_path)
     # show msg
     pix = QPixmap(self.img_decode_path)
     pix.scaledToHeight(10)
     item = QGraphicsPixmapItem(pix)
     scene = QGraphicsScene(self)
     scene.addItem(item)
     self.imagePreview.setScene(scene)
Exemplo n.º 16
0
    def selectImage(self):
        """Prompts for image selection and runs OCR"""
        filename, _ = QFileDialog.getOpenFileName(self, "Open file", "",
                                                  "Image file (*.jpg *.png)")
        pixmap = QPixmap(filename)
        if pixmap.height() > 500:
            pixmap = pixmap.scaledToHeight(500)
        if pixmap.width() > 500:
            pixmap = pixmap.scaledToHeight(500)

        self.label.setPixmap(pixmap)
        self.resize(pixmap.width(), pixmap.height())

        self.inputText.clear()
        self.inputText.setText(imageToText(filename))
Exemplo n.º 17
0
    def __init__(self):
        super(MainWindow, self).__init__()
        
        layout = QVBoxLayout()
    
        self.treble_clef_label = QLabel()
        treble_clef_pix = QPixmap('./treble_clef.jpg')
        treble_clef_pix = treble_clef_pix.scaledToHeight(640)
        self.treble_clef_label.setPixmap(treble_clef_pix)
       
        layout.addWidget(self.treble_clef_label)
        
        self.quarter_note_label = QuarterNote(self.treble_clef_label)
        self.quarter_note_label.move(170, -1000)

        layout.setContentsMargins(200, 11, 200, 11)
        self.treble_clef_label.setScaledContents(True)
        self.setLayout(layout)
        
        self.target_line_number = -1000

        self.threadpool = QThreadPool()

        self.midi_worker = MidiWorker()
        self.midi_worker.signal.note_recieved.connect(self.checkIfCorrect)

        self.note_generator = GenerateNoteWorker('C', "medium")
        self.note_generator.signal.note_generated.connect(self.setTargetLineNumber)
        
        self.threadpool.start(self.midi_worker)
        self.threadpool.start(self.note_generator)

        for synth in self.midi_worker.synths:
            self.threadpool.start(synth)
Exemplo n.º 18
0
    def captur(self):
        if self.debug: print('Captur')
        if self.nocam:
            crop_img = cv2.imread("und.png", 0)
            crop_img = self.rotator(crop_img, self.gradus)
            if self.debug: print(crop_img.shape)
        else:
            hostname = self.lineEdit.text()
            # if self.debug: print(hostname)
            # response = os.system("ping -n 1 " + hostname)
            # if self.debug: print(response)
            # if response == 0:
            cap = cv2.VideoCapture(
                'rtsp://' + hostname +
                ':554/user=admin&password=&channel=1&stream=0?.sdp')
            # if(cap.isOpened()):
            ret, frame = cap.read()
            gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
            if self.debug: print(gray.shape)
            gray = self.rotator(gray, self.gradus)
            gray = self.radial(gray)
            if self.debug: print(gray.shape)
            crop_img = gray[120:520, 500:900]
            if self.debug: print(crop_img.shape)
            cv2.imwrite("und.png", crop_img)
            crop_img = np.array(crop_img[:, :, 0], dtype=np.uint8)
            if self.debug: print(crop_img.shape)

        qimage = QImage(crop_img, crop_img.shape[0], crop_img.shape[1],
                        QImage.Format_Indexed8)
        pixmap = QPixmap(qimage)  #QPixmap('und.png')
        pixmap = pixmap.scaledToHeight(256)
        self.label.setPixmap(pixmap)
Exemplo n.º 19
0
    def showChannelInfo(self, channelData):
        if channelData is None: return
        try:
            self.channelData = channelData
            pixmap = QPixmap(self.channelData.iconPath)
            pixmap = pixmap.scaledToHeight(64)
            self.window.channelIcon.setPixmap(pixmap)
            self.window.channelName.setText(self.channelData.channelName)
            self.window.channelSubCount.setText(self.channelData.subsCount)
            # clear list
            list = self.window.videoElementsList
            list.clear()
            for videoData in self.channelData.videosData:
                newElement = VideoElementView()
                newElement.setVideoName(videoData.videoName)

                myQListWidgetItem = QtWidgets.QListWidgetItem(self.window.videoElementsList)
                myQListWidgetItem.setSizeHint(newElement.sizeHint())

                list.setItemWidget(myQListWidgetItem, newElement)
                list.insertItem(list.count(), myQListWidgetItem)
                newElement.analyzeButton.clicked.connect(
                    partial(self.downloadComments, videoData.videoName,
                            videoData.videoUrl, videoData.commentsPath, newElement))
                #  https://stackoverflow.com/questions/6784084/how-to-pass-arguments-to-functions-by-the-click-of-button-in-pyqt/42945033
        except Exception as e:
            print(e)
Exemplo n.º 20
0
def png_asset(filename,
              set_to=None,
              size=32,
              color=(255, 255, 255),
              mask_color=(
                  0,
                  0,
                  0,
              ),
              **kw):

    fp = os.path.abspath(filename)
    if os.path.exists(fp):
        raise FileNotFoundError(fp)

    icon = QPixmap(fp)
    #icon.setStyleSheet("text-color: red")
    # scaled_icon = icon.scaled(30, 30, Qt.KeepAspectRatio & Qt.SmoothTransformation)
    mask = icon.createMaskFromColor(QColor(*mask_color), Qt.MaskOutColor)

    p = QPainter()
    p.begin(icon)
    p.setPen(QColor(*color))
    p.drawPixmap(icon.rect(), mask, mask.rect())
    p.end()

    scaled_icon = icon.scaledToHeight(size, Qt.SmoothTransformation)
    #scaled_icon.drawPixmap(pix.rect(), mask, mask.rect())

    if set_to is not None:
        set_to.setPixmap(scaled_icon)

    return scaled_icon
Exemplo n.º 21
0
def show():

    message = "{0}  {1} ".format(appinfo.appname, appinfo.version)
    pixmap = QPixmap(os.path.join(__path__[0], 'splash3.png'))
    if QApplication.desktop().screenGeometry().height() < 640:
        fontsize = 23
        pixmap = pixmap.scaledToHeight(240, Qt.SmoothTransformation)
    else:
        fontsize = 40

    splash = QSplashScreen(pixmap, Qt.SplashScreen)

    font = splash.font()
    font.setPixelSize(fontsize)
    font.setWeight(QFont.Bold)
    splash.setFont(font)

    splash.showMessage(message, Qt.AlignRight | Qt.AlignTop, Qt.white)
    splash.show()
    QApplication.processEvents()

    def hide():
        splash.deleteLater()
        app.appStarted.disconnect(hide)

    app.appStarted.connect(hide)
Exemplo n.º 22
0
    def open_image(self):
        """
        打开图片,并输入模型进行识别,界面更新处理结果
        :return:
        """
        # 停止正在工作的可视化线程
        # self.stop_fer_vir_threads()
        # 打开并展示一张图片
        img_path, _ = QFileDialog.getOpenFileName(None, "打开图片", "", "*.png;*.jpg;;All Files(*)")
        if len(img_path) <= 0:
            return
        print("get image path: ", img_path)
        img_origin = QPixmap(img_path)
        if img_origin.width() > img_origin.height():
            img_origin = img_origin.scaledToWidth(self.show_pic_label.width())
        else:
            img_origin = img_origin.scaledToHeight(self.show_pic_label.height())
        self.show_pic_label.setPixmap(img_origin)
        self.show_res_label.setText("识别中...")
        for i in range(self.n_features_conv):
            self.vir_labels[i].clear()
            self.vir_labels[i].setText("可视化图片")
            self.vir_fl_labels[i].clear()
            self.vir_fl_labels[i].setText("可视化图片")
        self.vir_softmax_rate_label.clear()
        self.vir_softmax_rate_label.setText("结果")
        self.vir_fl_softmax_rate_label.clear()
        self.vir_fl_softmax_rate_label.setText("结果")
        QApplication.processEvents()

        # 调用人脸识别的线程进行工作
        self.vir_index += 1
        self.fer_worker_thread = FERWorkerThread(self.model_controller, img_origin, self.vir_index)
        self.fer_worker_thread.signal.connect(self.fer_worker_thread_slot)
        self.fer_worker_thread.start()
Exemplo n.º 23
0
    def get_file_name(self):

        filename = QFileDialog.getOpenFileName()
        self.lb.setText(filename[0])
        pixmap = QPixmap(filename[0])
        pixmap = pixmap.scaledToHeight(240)
        self.lb_1.setPixmap(pixmap)
Exemplo n.º 24
0
    def setup_table_selection(self, table_selection, table_guesses, table_results):

        table_selection.setFixedSize(66, 514)
        table_selection.horizontalHeader().hide()
        table_selection.verticalHeader().hide()
        
        table_selection.setRowCount(8)
        table_selection.setColumnCount(1)

        table_selection.setColumnWidth(0, 64)

        for i in range(8):
            table_selection.setRowHeight(i, 64)

        table_selection.cellClicked.connect(
                lambda: self.on_table_selection_cell_clicked(
                        table_selection, table_guesses, table_results))


        for i in range(1, 9):

            label = QLabel()
            label.setFixedSize(64, 64)
            label.setAlignment(Qt.AlignCenter)

            pixmap = QPixmap('icons/{}.png'.format(i))
            pixmap = pixmap.scaledToHeight(34)
            pixmap = pixmap.scaledToWidth(34)

            label.setPixmap(pixmap)

            label.setProperty('element_id', i)

            table_selection.setCellWidget(i - 1, 0, label)
Exemplo n.º 25
0
def show():
    
    message = "{0}  {1} ".format(appinfo.appname, appinfo.version)
    pixmap = QPixmap(os.path.join(__path__[0], 'splash3.png'))
    if QApplication.desktop().screenGeometry().height() < 640:
        fontsize = 23
        pixmap = pixmap.scaledToHeight(240, Qt.SmoothTransformation)
    else:
        fontsize = 40

    splash = QSplashScreen(pixmap, Qt.SplashScreen)

    font = splash.font()
    font.setPixelSize(fontsize)
    font.setWeight(QFont.Bold)
    splash.setFont(font)

    splash.showMessage(message, Qt.AlignRight | Qt.AlignTop, Qt.white)
    splash.show()
    QApplication.processEvents()
    
    def hide():
        splash.deleteLater()
        app.appStarted.disconnect(hide)

    app.appStarted.connect(hide)
Exemplo n.º 26
0
def display_prediction():
    '''this function occurs each time the "Browse" button is pressed'''
    btn.setText("Loading...")  #notify the user that the app is loading

    #collect user input
    get_file = QFileDialog.getOpenFileName(btn, "Open File", "/home",
                                           "Images (*.png *.xpm *.jpg)")
    user_image = get_file[0]

    #get and display prediction
    flower_name = get_prediction(user_image)
    pred.setText("this is a " + flower_name)

    #display user image
    imgPixmap = QPixmap(user_image)
    if imgPixmap.height() > imgPixmap.width():
        #if image is vertical
        imgPixmap = imgPixmap.scaledToWidth(150)
    else:
        #if image is horizontal
        imgPixmap = imgPixmap.scaledToHeight(150)
    img.setPixmap(imgPixmap)
    img.setAlignment(Qt.AlignCenter)
    img.setStyleSheet("padding: 10px; margin: 10px;")
    btn.setText("Browse")  #set button back to 'browse'
Exemplo n.º 27
0
    def open_file(self):
        """
        Open image file for editing, scaling the smaller dimension and cropping the remainder.
        :return:
        """
        path, _ = QFileDialog.getOpenFileName(
            self, "Open file", "",
            "PNG image files (*.png); JPEG image files (*jpg); All files (*.*)"
        )

        if path:
            pixmap = QPixmap()
            pixmap.load(path)

            # We need to crop down to the size of our canvas. Get the size of the loaded image.
            iw = pixmap.width()
            ih = pixmap.height()

            # Get the size of the space we're filling.
            cw, ch = CANVAS_DIMENSIONS

            if iw / cw < ih / ch:  # The height is relatively bigger than the width.
                pixmap = pixmap.scaledToWidth(cw)
                hoff = (pixmap.height() - ch) // 2
                pixmap = pixmap.copy(
                    QRect(QPoint(0, hoff), QPoint(cw,
                                                  pixmap.height() - hoff)))

            elif iw / cw > ih / ch:  # The height is relatively bigger than the width.
                pixmap = pixmap.scaledToHeight(ch)
                woff = (pixmap.width() - cw) // 2
                pixmap = pixmap.copy(
                    QRect(QPoint(woff, 0), QPoint(pixmap.width() - woff, ch)))
            self.imagefilePath = path  # for the opened sketch files
            self.ui.Canvas.setPixmap(pixmap)
Exemplo n.º 28
0
    def loadDecoration(self, decoKey, pxW, pxH):
        """Load graphical decoration element based on the decoration
        map. This function always returns a QSwgWidget.
        """
        if decoKey not in self.DECO_MAP:
            logger.error("Decoration with name '%s' does not exist" % decoKey)
            return QPixmap()

        imgPath = os.path.join(self.mainConf.assetPath, "images",
                               self.DECO_MAP[decoKey])
        if not os.path.isfile(imgPath):
            logger.error("Decoration file '%s' not in assets folder" %
                         self.DECO_MAP[decoKey])
            return QPixmap()

        theDeco = QPixmap(imgPath)
        if pxW is not None and pxH is not None:
            return theDeco.scaled(pxW, pxH, Qt.IgnoreAspectRatio,
                                  Qt.SmoothTransformation)
        elif pxW is None and pxH is not None:
            return theDeco.scaledToHeight(pxH, Qt.SmoothTransformation)
        elif pxW is not None and pxH is None:
            return theDeco.scaledToWidth(pxW, Qt.SmoothTransformation)

        return theDeco
Exemplo n.º 29
0
    def getWidgetImage(self, mainWidget, scale):

        # layout of this widget => three columns
        image_layout = QHBoxLayout()

        # space between the three grids
        image_layout.setSpacing(1)

        # margin around the widget
        image_layout.setContentsMargins(0, 0, 0, 0)

        widget = self.getQLabelToHoldImage()
        widget.setStyleSheet('background: black')
        widget.setAlignment(Qt.AlignCenter)
        widget.setLayout(image_layout)

        pixmap = QPixmap(self.getPathOfImage())

        # if card image was not found
        if pixmap.isNull():

            # then a blank image appears
            smaller_pixmap = QPixmap(PANEL_HEIGHT * scale,
                                     PANEL_HEIGHT * scale)
            smaller_pixmap.fill(QColor('gray'))
        elif pixmap.width() >= pixmap.height():
            smaller_pixmap = pixmap.scaledToWidth(PANEL_HEIGHT * scale)
        else:
            smaller_pixmap = pixmap.scaledToHeight(PANEL_HEIGHT * scale)

        widget.setMinimumHeight(PANEL_HEIGHT * scale)
        widget.setMinimumWidth(PANEL_HEIGHT * scale)
        widget.setPixmap(smaller_pixmap)

        return widget
Exemplo n.º 30
0
    def openfile_button_connect(self):
        fname = QFileDialog.getOpenFileName(self, '打开文件', './')

        self.picpath = fname[0]
        MyUtils.getLogger(__name__).info("打开文件" + self.picpath)

        if len(self.picpath) < 4 or not (self.picpath[-4:] == '.png'
                                         or self.picpath[-4:] == '.jpg'):
            Alter_Dialog("警报", "请选择jpg或者png文件").exec_()
            return

        png = QPixmap(self.picpath)

        if png.isNull():
            Alter_Dialog("警报", "图片转换出现错误").exec_()
            return

        # 按与控件的比例,对图像进行缩放
        if png.width() / png.height() > self.ui.label.width(
        ) / self.ui.label.height():
            png = png.scaled(
                self.ui.label.width(),
                png.height() * self.ui.label.width() / png.width())
        else:
            png = png.scaledToHeight(
                png.width() * self.ui.label.height() / png.height(),
                self.ui.label.height())
        # 把图像放到控件中显示
        MyUtils.getLogger(__name__).info("展示图片" + self.picpath)
        self.ui.label.setPixmap(png)
Exemplo n.º 31
0
    def loadDecoration(self, decoKey, pxW=None, pxH=None):
        """Load graphical decoration element based on the decoration
        map or the icon map. This function always returns a QPixmap.
        """
        if decoKey in self._themeMap:
            imgPath = self._themeMap[decoKey]
        elif decoKey in self.IMAGE_MAP:
            imgPath = os.path.join(self.mainConf.assetPath, "images",
                                   self.IMAGE_MAP[decoKey])
        else:
            logger.error("Decoration with name '%s' does not exist", decoKey)
            return QPixmap()

        if not os.path.isfile(imgPath):
            logger.error("Asset '%s' not found", self.IMAGE_MAP[decoKey])
            return QPixmap()

        theDeco = QPixmap(imgPath)
        if pxW is not None and pxH is not None:
            return theDeco.scaled(pxW, pxH, Qt.IgnoreAspectRatio,
                                  Qt.SmoothTransformation)
        elif pxW is None and pxH is not None:
            return theDeco.scaledToHeight(pxH, Qt.SmoothTransformation)
        elif pxW is not None and pxH is None:
            return theDeco.scaledToWidth(pxW, Qt.SmoothTransformation)

        return theDeco
Exemplo n.º 32
0
Arquivo: tabs.py Projeto: MazeFX/pat
    def __init__(self, dbhelper, *args):
        super(HomeTab, self).__init__(*args)
        Lumberjack.info('spawning a << HomeTab >>')
        self.dbhelper = dbhelper

        self.setupUi(self)

        myPixmap = QPixmap(':/app_icons/rc/PAT_Logo.png')
        myScaledPixmap = myPixmap.scaledToHeight(200)
        self.LogoContainer.setPixmap(myScaledPixmap)
Exemplo n.º 33
0
 def set_image(self, image_filename):
     size = 800
     pixmap = QPixmap(image_filename)
     if pixmap.width() > pixmap.height():
         if pixmap.width() > size:
             pixmap = pixmap.scaledToWidth(size)
     else:
         if pixmap.height() > size:
             pixmap = pixmap.scaledToHeight(size)
     self.ui.label.setPixmap(pixmap)
     self.ui.label.setMask(pixmap.mask())
     self.ui.label.show()
Exemplo n.º 34
0
    def loadImage(self, path):
        self.markable_picture = QMarkablePicture(self)
        hbox = QHBoxLayout(self)
        picture = QPixmap(path)

        if picture.width() > self.maximumWidth():
            picture = picture.scaledToWidth(self.maximumWidth())
        if picture.height() > self.maximumHeight():
            picture = picture.scaledToHeight(self.maximumHeight())

        self.markable_picture.setPixmap(picture)
        hbox.addWidget(self.markable_picture)
        hbox.setContentsMargins(0, 0, 0, 0)
        self.setLayout(hbox)
Exemplo n.º 35
0
	def init(self):
		self.window = loadUi(os.path.join(get_ui_path(),"splash.ui"))
		self.window.setWindowFlags(Qt.FramelessWindowHint|Qt.WindowStaysOnTopHint)
		self.center()
		self.window.li.setText(notice()+"\n"+version())
		self.window.setModal(Qt.WindowModal)
		self.window.image.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
		self.window.image.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)

		window_h=self.window.height()
		window_w=self.window.width()
		r=random.randint(2, 3)
		image=QPixmap(os.path.join(get_image_file_path(),"splash"+str(r)+".png"))
		image.scaledToHeight(window_h)

		w=image.width()
		h=image.height()
		x_max=w-window_h-window_w/2

		hour=float(time.strftime("%H"))*60
		m=float(time.strftime("%m"))
		tot=hour+m
		my_max=float(24*60)

		value=tot/my_max

		xpos=int(x_max*value)+window_w/2
		print("xpos=",xpos)
		scene=QGraphicsScene();
		scene.setSceneRect(xpos, 0, 0, h)
		self.window.image.setScene(scene)

		self.window.show()

		scene.addPixmap(image);

		QTimer.singleShot(1500, self.callback_destroy)
Exemplo n.º 36
0
 def put_cv2_image(self, image, widget):
     height, width = image.shape[0:2]
     qImg = self.cv2toQImage(image)
     pixmap = QPixmap(qImg)
     if height > width:
         if height > self.preview_size:
             pixmap = pixmap.scaledToHeight(self.preview_size)
     else:
         if width > self.preview_size:
             pixmap = pixmap.scaledToWidth(self.preview_size)
     widget.setPixmap(pixmap)
     #give hints to DrawableLabel() and MyLabel()
     widget.perspective = self.perspective
     widget.focus = self.focus
     widget.slitpos = self.slitpos
     w = pixmap.width()
     h = pixmap.height()
     x = ( self.preview_size - w ) // 2
     y = ( self.preview_size - h ) // 2
     widget.geometry = x,y,w,h
Exemplo n.º 37
0
    def initUI(self):
        """Initialize GUI user interface elements"""
        self.db_view = self.create_DB()
        self.sessionID=self.get_SessionId()
        global maxHeight
        global maxWidth
        self.maxHeight=maxHeight
        self.maxWidth=maxWidth
        show_logs = QPushButton("Open Database",self)
        show_logs.clicked.connect(lambda:self.show_logs(self.db_view))
        export_db = QPushButton("Export Database",self)
        export_db.clicked.connect(lambda:self.savefile())

        pixmap = QPixmap("back.jpg")
        pixmap=pixmap.scaledToHeight(self.maxHeight)

        self.lbl = QLabel(self)
        self.lbl.setFixedHeight(self.maxHeight)
        self.lbl.setPixmap(pixmap)

        hbox = QVBoxLayout(self)
        hbox.setAlignment(Qt.AlignCenter);
        hbox.addWidget(self.lbl)

        parentVideoBox=QWidget(self)
        parentVideoBox.setStyleSheet("background-color:#121A21");
        parentVideoBox.setLayout(hbox)

        vbox = QHBoxLayout(self)
        tracking = QCheckBox(self.tracking)
        luggage= QCheckBox(self.luggage)
        actions = QCheckBox(self.actions)
        falling = QCheckBox(self.falling)

        vbox.addWidget(tracking)
        vbox.addWidget(luggage)
        vbox.addWidget(actions)
        vbox.addWidget(falling)

        vbox.addWidget(show_logs)
        vbox.addWidget(export_db)

        self.logs = QTextEdit(self)
        self.logs.setReadOnly(True)
        self.logs.setLineWrapMode(QTextEdit.NoWrap)
        self.logs.setMaximumHeight(200)

        vbox2 = QVBoxLayout(self)
        vbox2.addWidget(parentVideoBox)
        vbox2.addLayout(vbox)
        vbox2.addWidget(self.logs)

        parentBox=QWidget(self)
        parentBox.setLayout(vbox2)
        self.setCentralWidget(parentBox)
        tracking.stateChanged.connect(lambda:self.button_Pressed(tracking))
        luggage.stateChanged.connect(lambda:self.button_Pressed(luggage))
        actions.stateChanged.connect(lambda:self.button_Pressed(actions))
        falling.stateChanged.connect(lambda:self.button_Pressed(falling))

        openFile = QAction(QIcon('open.png'), 'Open', self)
        openFile.setShortcut('Ctrl+O')
        openFile.setStatusTip('Open new File')
        openFile.triggered.connect(self.open_video)

        showReport = QAction(QIcon('open.png'), 'Report', self)
        showReport.setShortcut('Ctrl+R')
        showReport.setStatusTip('Show Report')
        showReport.triggered.connect(self.showReport)

        menubar = self.menuBar()
        fileMenu = menubar.addMenu('&File')
        fileMenu.addAction(openFile)
        fileMenu.addAction(showReport)

        self.setGeometry(300, 20, 600, 700)
        self.setWindowTitle('Horas Surveillance System')
        self.show()
Exemplo n.º 38
0
class Inductor(element):
    def __init__(self, name, parent, value = 0.01):
        element.__init__(self, name, parent, value)
        self.Impedance = 1j *2 * np.pi * Current_src.freq * self.value

        # adding image to resistor(that is a QLabel object itself) as its symbol
        self.symbol = QPixmap()
        self.symbol.load('ind.png')
        self.symbol = self.symbol.scaledToWidth(100)
        self.resize(self.symbol.size())
        self.setPixmap(self.symbol)
        self.move(200, 100)

        self.valueText = QLineEdit(parent)
        self.valueText.move(self.x() + 30, self.y() + 40)
        self.valueText.resize(50, 15)
        self.valueText.setText(str(self.value) + '  H')

        self.idLabel = QLabel(parent)
        self.idLabel.move(self.x() + 45, self.y())
        self.idLabel.resize(20, 15)
        self.idLabel.setText(str(self.name))
        self.idLabel.show()

        self.nodeP = node(parent)
        self.nodeS = node(parent)
        self.nodeP.move(self.x(), self.y() + 22)
        self.nodeS.move(self.x() + 90, self.y() + 22)
        self.nodeP.show()
        self.nodeS.show()
        # first element tahr is connected to a ned is It's element.
        self.nodeP.connected_elements.add(self.name)
        self.nodeS.connected_elements.add(self.name)

        # When right click on element a menu pops on
        self.PropMenu = QMenu(parent)
        self.PropMenu.addAction('Change Value')
        self.PropMenu.addAction('Rotate')
        self.PropMenu.addAction('Delete')
        # Setting Geometry of menu
        self.PropMenu.move(parent.frameGeometry().left() + self.x() + 20,
                           parent.frameGeometry().top() + self.y() + 100)

        self.isHorizontal = True

        self.direction_label = QLabel(parent)
        self.direction = QPixmap()

        self.valueText.show()
        self.show()

    def mousePressEvent(self, event):
        self.__mousePressPos = None
        self.__mouseMovePos = None
        if event.button() == QtCore.Qt.LeftButton:
            self.__mousePressPos = event.globalPos()
            self.__mouseMovePos = event.globalPos()

        if event.button() == QtCore.Qt.RightButton:
            action = self.PropMenu.exec()

            if action is not None:
                if action.text() == 'Change Value':
                    print('Change Value clicked')
                    self.value = float(re.match('\d*(?:.\d*e?-?\d*)?', self.valueText.text()).group())
                    self.Impedance = 1j *2 * np.pi * Current_src.freq * self.value

                elif action.text() == 'Rotate':
                    print('Rotate clicked')
                    self.Rotate()

                elif action.text() == 'Delete':
                    print('Delete clicked')
                    self.deleteMe()
                    self.parent().elements.remove(self)

        super(Inductor, self).mousePressEvent(event)

    def mouseMoveEvent(self, event):
        if event.buttons() == QtCore.Qt.LeftButton:
            # adjust offset from clicked point to origin of widget
            currPos = self.mapToGlobal(self.pos())
            globalPos = event.globalPos()
            diff = globalPos - self.__mouseMovePos
            newPos = self.mapFromGlobal(currPos + diff)

            # Moving element to new position
            self.move(newPos)
            if self.isHorizontal:
                self.nodeP.move(newPos.x(), newPos.y() + 22)
                self.nodeS.move(newPos.x() + 90, newPos.y() + 22)
                self.valueText.move(newPos.x() + 30, newPos.y() + 40)
                self.idLabel.move(newPos.x() + 45, newPos.y())
                self.PropMenu.move(self.parent().frameGeometry().left() + newPos.x() + 20,
                                   self.parent().frameGeometry().top() + newPos.y() + 100)
            else:
                self.nodeP.move(newPos.x() + 18, newPos.y())
                self.nodeS.move(newPos.x() + 18, newPos.y() + 90)
                self.valueText.move(newPos.x() + 40, newPos.y() + 45)
                self.idLabel.move(newPos.x() + 40, newPos.y() + 25)
                self.PropMenu.move(self.parent().frameGeometry().left() + newPos.x() + 100,
                                   self.parent().frameGeometry().top() + newPos.y() + 20)

            self.__mouseMovePos = globalPos
        super(Inductor, self).mouseMoveEvent(event)

    def mouseReleaseEvent(self, event):
        if self.__mousePressPos is not None:
            moved = event.globalPos() - self.__mousePressPos
            if moved.manhattanLength() > 3:
                event.ignore()
                return

        super(Inductor, self).mouseReleaseEvent(event)

    def Rotate(self):
        if(self.isHorizontal):
            self.symbol = QPixmap()
            self.symbol.load('ind2.png')
            self.symbol = self.symbol.scaledToHeight(100)
            self.resize(self.symbol.size())
            self.setPixmap(self.symbol)

            self.valueText.move(self.x() + 40, self.y() + 45)
            self.idLabel.move(self.x() + 40, self.y() + 25)
            self.valueText.setText(str(self.value) + ' H')

            self.nodeP.move(self.x() + 18, self.y())
            self.nodeS.move(self.x() + 18, self.y() + 90)

            self.isHorizontal = False

        else:
            self.symbol = QPixmap()
            self.symbol.load('ind.png')
            self.symbol = self.symbol.scaledToWidth(100)
            self.resize(self.symbol.size())
            self.setPixmap(self.symbol)

            self.valueText.move(self.x() + 30, self.y() + 40)
            self.idLabel.move(self.x() + 45, self.y())
            self.valueText.setText(str(self.value) + ' H')

            self.nodeP.move(self.x(), self.y() + 22)
            self.nodeS.move(self.x() + 90, self.y() + 22)

            self.isHorizontal = True

    def deleteMe(self):
        self.hide()
        self.nodeP.hide()
        self.nodeS.hide()
        self.idLabel.hide()
        self.valueText.hide()

    def show_detail(self):
        self.setStyleSheet("background-color: yellow")
        if self.isHorizontal:
            self.direction.load('arrow_right.png')
            self.direction = self.direction.scaledToWidth(100)
            self.direction_label.resize(self.direction.size())
            self.direction_label.setPixmap(self.direction)
            self.direction_label.move(self.x(), self.y())
            self.direction_label.show()
        else:
            self.direction.load('arrow_down.png')
            self.direction = self.direction.scaledToHeight(100)
            self.direction_label.resize(self.direction.size())
            self.direction_label.setPixmap(self.direction)
            self.direction_label.move(self.x(), self.y())
            self.direction_label.show()

    def hide_detail(self):
        self.setStyleSheet("background-color: none")
        self.direction_label.hide()