def __init__(self, recipe, currentUser, profilePage ):
     QWidget.__init__(self,None)
     self.ui = Ui_Form()
     self.ui.setupUi(self)
     self.current_user = currentUser
     self.profile_page = profilePage
     self.ui.recipeLabel.setPixmap(QPixmap("app/UI/recipe-book.png"))
     self.ui.recipeLabel.setScaledContents(True)
     self.ui.previewButton.clicked.connect( self.viewButtonClick )
     self.ui.editButton.clicked.connect( self.editButtonClick )
     self.setFixedSize( 500, 150)
     self.recipe = recipe
     self.view = ViewRecipe( self.recipe, self.current_user )
     self.createRecipe = CreateRecipe( self.recipe.getCreator().getUsername())
     self.createRecipe.setRecipe( recipe )
     self.ui.recipenameLabel.setText("Recipe: %s"%(self.recipe.getName()))
     self.ui.ratingLabel.setText("Rating: %.1f" %(RATING_MODEL.getAverageRating( self.recipe.getId())))
     self.ui.levelLabel.setText( "Difficulty: %s" %(self.recipe.getDifficulty()))
     self.picture = RECIPE_MODEL.getImageById( self.recipe.getId() )
     if self.picture is not None:
         pix = QPixmap()
         pix.loadFromData( self.picture[0] )
         self.ui.recipeLabel.setScaledContents( True )
         self.ui.recipeLabel.setPixmap( pix )
     self.ui.deleteButton.clicked.connect( self.deleteButtonClick )
Beispiel #2
0
    def on_selection_moved(self):
        selected_pixmap = self.get_selected_pixmap()
        self.art_shuffler.draw(selected_pixmap)
        self.sliced_pixmap_item.setPixmap(QPixmap.fromImage(self.sliced_image))

        selected_pixmap = self.get_selected_pixmap()
        cell_width = (selected_pixmap.width() /
                      self.selection_grid.column_count)
        cell_height = (selected_pixmap.height() /
                       self.selection_grid.row_count)
        self.row_clues.clear()
        self.column_clues.clear()
        for i in range(self.selection_grid.row_count):
            clue_image = selected_pixmap.copy(0, i * cell_height, cell_width,
                                              cell_height)
            self.row_clues.append(clue_image)
        for j in range(self.selection_grid.column_count):
            clue_image = selected_pixmap.copy(j * cell_width, 0, cell_width,
                                              cell_height)
            self.column_clues.append(clue_image)
        self.symbols_shuffler.row_clues = self.row_clues
        self.symbols_shuffler.column_clues = self.column_clues

        self.symbols_shuffler.draw_grid(selected_pixmap)
        self.symbols_pixmap_item.setPixmap(
            QPixmap.fromImage(self.symbols_image))
        self.timer.start()
    def PreviewWindow(self):

        self.statusBar().showMessage('Tablecloth preview generated.')
        self.statusBar().removeWidget(self.progress_bar)
        # Now you can go back to rigging
        self.ChangeAppStatus(True)

        self.preview_wid = QWidget()
        self.preview_wid.resize(600, 600)
        self.preview_wid.setWindowTitle("Tablecloth preview")

        tablecloth = QPixmap(tempfile.gettempdir()+"\\Table_Dif.jpg")

        tablecloth_preview_title = QLabel(self)
        tablecloth_preview_title.setText("Tablecloth preview (1/4 scale)")
        tablecloth_preview = QLabel(self)
        tablecloth_preview.setPixmap(tablecloth.scaled(512,512))
        confirm = QPushButton(self)
        confirm.setText("Confirm")
        confirm.clicked.connect(self.GenerateImage)
        confirm.clicked.connect(self.preview_wid.close)

        vbox = QVBoxLayout()
        vbox.setAlignment(QtCore.Qt.AlignCenter)
        vbox.addWidget(tablecloth_preview_title)
        vbox.addWidget(tablecloth_preview)
        vbox.addWidget(confirm)
        self.preview_wid.setLayout(vbox)

        self.preview_wid.setWindowModality(QtCore.Qt.ApplicationModal)
        self.preview_wid.activateWindow()
        self.preview_wid.raise_()
        self.preview_wid.show()
    def __init__(self, recipe, currentUser):
        QWidget.__init__(self, None)
        self.ui = Ui_Form()
        self.ui.setupUi(self)
        self.recipe = recipe
        self.current_user = currentUser
        self.viewCommentPage = ViewComment(self.recipe)
        self.ui.creator_label.setText("Create by : %s" %
                                      self.recipe.getCreator().getUsername())
        self.ui.inCal_label.setText(
            QCoreApplication.translate(
                "Form",
                u"<html><head/><body><p><span style=\" color:#000000;\">%s KCAL</span></p></body></html>"
                % str(self.recipe.getCalories())))
        self.ui.inLevel_label.setText(
            QCoreApplication.translate(
                "Form",
                u"<html><head/><body><p><span style=\" color:#000000;\">%s</span></p></body></html>"
                % self.recipe.getDifficulty()))
        self.ui.name_label.setText(self.recipe.getName())
        self.ui.recipe_label.setText(self.recipe.getCookingStep())
        self.ui.recipe_label.setStyleSheet(u"color: black;")
        # self.ui.ingredients_label.setStyleSheet( u"color: black;")
        self.picture = RECIPE_MODEL.getImageById(self.recipe.getId())
        if self.picture is not None:
            pix = QPixmap()
            pix.loadFromData(self.picture[0])
            self.ui.picture_label.setScaledContents(True)
            self.ui.picture_label.setPixmap(pix)

        self.ingredients = INGREDIENT_MODEL.getIngredient(self.recipe.getId())
        print(self.ingredients)
        for i in self.ingredients:
            ing = "%s  %.2f  %s  : %.2f KCAL" % (i.getName(), i.getQty(),
                                                 i.getUnit(), i.getCalories())
            self.ui.ingredients_listWidget.addItem(ing)
        # self.ui.recipeLabel.setPixmap(QPixmap("app/UI/recipe-book.png"))
        # self.ui.recipeLabel.setScaledContents(True)
        if self.current_user.getUsername() == self.recipe.getCreator(
        ).getUsername():
            self.ui.rateButton.close()
            self.ui.rate_spinBox.close()
            self.ui.rating_label.close()
            self.ui.comment_lineEdit.close()
            self.ui.comment_label.close()
            self.ui.sendButton.close()
            self.ui.viewcomment.setGeometry(QRect(10, 400, 240, 31))
            self.ui.viewcomment.clicked.connect(self.viewComment)

        else:
            self.ui.sendButton.clicked.connect(self.sendComment)
            self.ui.viewcomment.clicked.connect(self.viewComment)
            current_rating = RATING_MODEL.getRating(
                self.current_user.getUsername(), self.recipe.getId())
            print("\n\n", current_rating, "\n\n")
            if current_rating is not None:
                self.ui.rateButton.clicked.connect(self.updateRate)
                self.ui.rate_spinBox.setValue(current_rating)
            else:
                self.ui.rateButton.clicked.connect(self.rate)
Beispiel #5
0
 def create_painter(self) -> typing.Iterator[QPainter]:
     white = QColor('white')
     pixmap = QPixmap(self.width, self.height)
     pixmap.fill(white)
     painter = QPainter(pixmap)
     try:
         yield painter
     finally:
         painter.end()
Beispiel #6
0
 def __init__(self, parent):
     super(ImageLabel, self).__init__(parent)
     self.setSizePolicy(QtWidgets.QSizePolicy.Ignored,
                        QtWidgets.QSizePolicy.Ignored)
     self.setText("")
     self.pix = QPixmap()
     self.setPixmap(self.pix)
     self.ResizeSignal.connect(self.resizeEvent)
     self.installEventFilter(self)
Beispiel #7
0
def get_figure_pixmap(fig):
    buf = io.BytesIO()
    fig.savefig(buf, format='png', transparent=True)
    buf.seek(0)

    pixmap = QPixmap()
    pixmap.loadFromData(buf.read())
    buf.close()

    return pixmap
Beispiel #8
0
def paint_with_opacity(pixmap: QPixmap, opacity: float):
    transparent_image = QImage(QSize(36, 36),
                               QImage.Format_ARGB32_Premultiplied)
    transparent_image.fill(Qt.transparent)
    painter = QPainter(transparent_image)
    painter.setOpacity(opacity)
    painter.drawPixmap(18 - pixmap.width() / 2, 18 - pixmap.height() / 2,
                       pixmap)
    painter.end()
    return QPixmap.fromImage(transparent_image)
Beispiel #9
0
    def __init__(self):
        super(MainWindow, self).__init__()
        self.title = "Image Viewer"
        self.setWindowTitle(self.title)

        label = QLabel(self)
        pixmap = QPixmap('close_16.png')
        label.setPixmap(pixmap)
        self.setCentralWidget(label)
        self.resize(pixmap.width(), pixmap.height())
Beispiel #10
0
    def paint(self, painter, option, index):
        super(Delegate, self).paint(painter, option, index)

        # HOVER
        if option.state & QStyle.State_MouseOver:
            painter.fillRect(option.rect, QColor("#F1F1F1"))
        else:
            painter.fillRect(option.rect, Qt.transparent)

        # SELECTED
        if option.state & QStyle.State_Selected:
            painter.fillRect(option.rect, QColor("#F1F1F1"))

        # DRAW ICON
        icon = QPixmap()
        icon.load(index.data()[1])
        icon = icon.scaled(24, 24, Qt.IgnoreAspectRatio,
                           Qt.SmoothTransformation)

        left = 24  # margin left
        icon_pos = QRect(left, ((self._height - icon.height()) / 2) +
                         option.rect.y(), icon.width(), icon.height())
        painter.setRenderHint(QPainter.Antialiasing)
        painter.setRenderHint(QPainter.SmoothPixmapTransform)
        painter.drawPixmap(icon_pos, icon)

        # DRAW TEXT
        font = QFont("Roboto Black", 12)
        text_pos = QRect((left * 2) + icon.width(), option.rect.y(),
                         option.rect.width(), option.rect.height())
        painter.setFont(font)
        painter.setPen(Qt.black)
        painter.drawText(text_pos, Qt.AlignVCenter, index.data()[0])
Beispiel #11
0
class ImageLabel(QtWidgets.QLabel):
    ResizeSignal = QtCore.Signal(int)

    def __init__(self, parent):
        super(ImageLabel, self).__init__(parent)
        self.setSizePolicy(QtWidgets.QSizePolicy.Ignored,
                           QtWidgets.QSizePolicy.Ignored)
        self.setText("")
        self.pix = QPixmap()
        self.setPixmap(self.pix)
        self.ResizeSignal.connect(self.resizeEvent)
        self.installEventFilter(self)

    def eventFilter(self, watched: QtCore.QObject,
                    event: QtCore.QEvent) -> bool:
        if (event.type() == QtCore.QEvent.Resize):
            if not self.pix.isNull():
                pixmap = self.pix.scaled(
                    self.width(), self.height(),
                    QtCore.Qt.AspectRatioMode.KeepAspectRatio,
                    QtCore.Qt.TransformationMode.SmoothTransformation)
                if pixmap.width() != self.width() or pixmap.height(
                ) != self.height():
                    self.ResizeSignal.emit(0)
        return super().eventFilter(watched, event)

    def resizeEvent(self, _):
        if not self.pix.isNull():
            size = self.size()
            self.setPixmap(
                self.pix.scaled(
                    size, QtCore.Qt.AspectRatioMode.KeepAspectRatio,
                    QtCore.Qt.TransformationMode.SmoothTransformation))

    #Paint event that is currently not needed
    # def paintEvent(self, event):
    #     if not self.pix.isNull():
    #         size = self.size()
    #         painter = QPainter()
    #         point = QtCore.QPoint(0, 0)
    #         scaledPix = self.setPixmap(self.pix.scaled(size, QtCore.Qt.AspectRatioMode.KeepAspectRatio, QtCore.Qt.TransformationMode.SmoothTransformation))
    #         point.setX((size.width() - scaledPix.width() / 2))
    #         point.setY((size.height() - scaledPix.height() / 2))
    #         painter.drawPixmap(point, scaledPix)

    def changePixmap(self, img):
        self.pix = img
        self.repaint()
        self.ResizeSignal.emit(1)

    def clearPixmap(self):
        self.pix = QPixmap()
        self.setPixmap(self.pix)
        self.repaint()
Beispiel #12
0
    def slotPrintPreview(self):
        pix = QPixmap(1000, 200)
        pix.fill(Qt.white)

        painter = QPainter(pix)
        view.print(painter, pix.rect())
        painter.end()

        label = QLabel(this)
        label.setPixmap(pix)
        label.show()
Beispiel #13
0
def fit_to_frame(pixmap: QPixmap, frame: QSize) -> QPixmap:
    """
    :param pixmap: The QPixmap to resize.
    :param frame: The frame within which the image should fit.
    :return: A pixmap fitting inside the given frame.
    """
    frame_width, frame_height = frame.toTuple()
    dw = abs(pixmap.width() - frame_width)
    dh = abs(pixmap.height() - frame_height)
    return pixmap.scaledToWidth(
        frame_width) if dw > dh else pixmap.scaledToHeight(frame_height)
    def importTeamFunction(self):
        file_dialog = QFileDialog(self)
        file_dialog = QFileDialog.getOpenFileName(
                                    filter="Team Files (*.json *.zip)",
                                    selectedFilter="Team Files (*.json *.zip)")

        if file_dialog[0] != "":
            if is_zipfile(file_dialog[0]):
                with ZipFile(file_dialog[0]) as zip_import:
                    list_of_files = zip_import.namelist()
                    for fimp in list_of_files:
                        if fimp.startswith('logos'):
                            zip_import.extract(fimp, path=THISDIR+'\\images\\')
                    imported_teams = zip_import.read('teams.json')
                    imported_teams = imported_teams.decode('utf-8')
            else:
                imported_teams = open(file_dialog[0], "r",
                                encoding="utf-8").read()
            json_teams = json.loads(imported_teams)
            self.teams = json_teams["teams"]
            self.players = json_teams["players"]

            new_teams = open(THISDIR + "\\config\\teams.json", "w+",
                            encoding="utf-8")
            new_teams.write(json.dumps(json_teams, indent=4))
            new_teams.close()

            old_config = open(THISDIR + "\\config\\config.json", "r",
                                encoding="utf-8").read()
            old_config = json.loads(old_config)
            old_config["total_teams"] = len(json_teams["teams"])
            self.config = old_config
            new_config = open(THISDIR + "\\config\\config.json", "w+",
                                encoding="utf-8")
            new_config.write(json.dumps(self.config, indent=4))
            new_config.close()

            self.UpdatePlayersList()

            self.image_east.setPixmap(QPixmap("images/logos/team1.png")\
                                       .scaled(100,100))
            self.cloth_east.setModel(self.players_combobox.model())
            self.image_south.setPixmap(QPixmap("images/logos/team1.png")\
                                       .scaled(100,100))
            self.cloth_south.setModel(self.players_combobox.model())
            self.image_west.setPixmap(QPixmap("images/logos/team1.png")\
                                       .scaled(100,100))
            self.cloth_west.setModel(self.players_combobox.model())
            self.image_north.setPixmap(QPixmap("images/logos/team1.png")\
                                       .scaled(100,100))
            self.cloth_north.setModel(self.players_combobox.model())
            self.statusBar().showMessage("Teams imported successfully.")
            self.teamcreation_wid.close()
Beispiel #15
0
    def assert_equal(self):
        __tracebackhide__ = True
        self.end()
        self.different_pixels = 0
        actual_image: QImage = self.actual.device().toImage()
        expected_image: QImage = self.expected.device().toImage()
        diff_pixmap = QPixmap(actual_image.width(), actual_image.height())
        diff = QPainter(diff_pixmap)
        try:
            white = QColor('white')
            diff.fillRect(0, 0, actual_image.width(), actual_image.height(),
                          white)
            for x in range(actual_image.width()):
                for y in range(actual_image.height()):
                    actual_colour = actual_image.pixelColor(x, y)
                    expected_colour = expected_image.pixelColor(x, y)
                    diff.setPen(
                        self.diff_colour(actual_colour, expected_colour, x, y))
                    diff.drawPoint(x, y)
        finally:
            diff.end()
        diff_image: QImage = diff.device().toImage()

        display_diff(actual_image, diff_image, expected_image,
                     self.different_pixels)

        if self.different_pixels == 0:
            return
        actual_image.save(str(self.work_dir / (self.name + '_actual.png')))
        expected_image.save(str(self.work_dir / (self.name + '_expected.png')))
        diff_path = self.work_dir / (self.name + '_diff.png')
        is_saved = diff_image.save(str(diff_path))
        diff_width = self.diff_max_x - self.diff_min_x + 1
        diff_height = self.diff_max_y - self.diff_min_y + 1
        diff_section = QImage(diff_width, diff_height, QImage.Format_RGB32)
        diff_section_painter = QPainter(diff_section)
        try:
            diff_section_painter.drawPixmap(0, 0, diff_width, diff_height,
                                            QPixmap.fromImage(diff_image),
                                            self.diff_min_x, self.diff_min_y,
                                            diff_width, diff_height)
        finally:
            diff_section_painter.end()
        # To see an image dumped in the Travis CI log, copy the text from the
        # log, and paste it in test_pixmap_differ.test_decode_image.
        print(f'Encoded image of differing section '
              f'({self.diff_min_x}, {self.diff_min_y}) - '
              f'({self.diff_max_x}, {self.diff_max_y}):')
        print(encode_image(diff_section))
        message = f'Found {self.different_pixels} different pixels, '
        message += f'see' if is_saved else 'could not write'
        message += f' {diff_path.relative_to(Path(__file__).parent.parent)}.'
        assert self.different_pixels == 0, message
Beispiel #16
0
 def save_png(self):
     pdf_folder = self.settings.value('pdf_folder')
     file_name, _ = QFileDialog.getSaveFileName(self,
                                                "Save an image file.",
                                                dir=pdf_folder,
                                                filter='Images (*.png)')
     if not file_name:
         return
     writer = QPixmap(1000, 2000)
     self.paint_puzzle(writer)
     writer.save(file_name)
     self.settings.setValue('pdf_folder', os.path.dirname(file_name))
 def _ShowImg(self, data):
     self.scaleCnt = 0
     self.pixMap = QPixmap()
     self.pixMap.loadFromData(data)
     self.show()
     self.graphicsItem.setPixmap(self.pixMap)
     self.graphicsView.setSceneRect(QRectF(QPointF(0, 0), QPointF(self.pixMap.width(), self.pixMap.height())))
     size = ToolUtil.GetDownloadSize(len(data))
     self.sizeLabel.setText(size)
     weight, height = ToolUtil.GetPictureSize(data)
     self.resolutionLabel.setText(str(weight) + "x" + str(height))
     self.ScalePicture()
Beispiel #18
0
    def setupUi(self):
        self.centralwidget = QWidget(self)
        with open(resource_path('style.css'), 'r') as file:
            self.centralwidget.setStyleSheet(file.read())
        self.layout_widget_about = QWidget(self.centralwidget)
        self.layout_widget_about.setGeometry(QRect(10, 10, 221, 81))
        self.layout_about = QVBoxLayout(self.layout_widget_about)
        self.layout_about.setContentsMargins(0, 0, 0, 0)

        self.label_logo = QLabel(self.layout_widget_about)
        self.pixmap = QPixmap(resource_path('icon.ico'))
        self.pixmap = self.pixmap.scaledToWidth(30, Qt.SmoothTransformation)
        self.label_logo.setPixmap(self.pixmap)
        self.layout_about.addWidget(self.label_logo, 0, Qt.AlignHCenter)

        self.title_font = QFont()
        self.title_font.setPointSize(13)
        self.font = QFont()
        self.font.setPointSize(10)

        self.label_title = QLabel(self.layout_widget_about)
        self.title_font.setStyleStrategy(QFont.PreferAntialias)
        self.label_title.setFont(self.title_font)
        self.label_title.setLayoutDirection(Qt.LeftToRight)
        self.layout_about.addWidget(self.label_title, 0, Qt.AlignHCenter)

        self.label_version = QLabel(self.layout_widget_about)
        self.label_version.setFont(self.font)
        self.label_version.setLayoutDirection(Qt.LeftToRight)
        self.layout_about.addWidget(self.label_version, 0, Qt.AlignHCenter)

        self.layout_widget_about_2 = QWidget(self.centralwidget)
        self.layout_widget_about_2.setGeometry(QRect(10, 100, 221, 81))
        self.layout_about_2 = QVBoxLayout(self.layout_widget_about_2)
        self.layout_about_2.setContentsMargins(0, 0, 0, 0)
        self.label_copyright = QLabel(self.layout_widget_about_2)
        self.label_copyright.setFont(self.font)
        self.label_copyright.setLayoutDirection(Qt.LeftToRight)
        self.layout_about_2.addWidget(self.label_copyright, 0, Qt.AlignHCenter)

        self.label_author = QLabel(self.layout_widget_about_2)
        self.label_author.setFont(self.font)
        self.label_author.setLayoutDirection(Qt.LeftToRight)
        self.layout_about_2.addWidget(self.label_author, 0, Qt.AlignHCenter)

        self.button_quit_about = QPushButton(self.layout_widget_about_2)
        self.layout_about_2.addWidget(self.button_quit_about)
        self.button_quit_about.setMinimumSize(100, 30)
        self.button_quit_about.setProperty('class', 'Aqua')

        self.setCentralWidget(self.centralwidget)
        self.retranslateUi()
        QMetaObject.connectSlotsByName(self)
Beispiel #19
0
    def paintEvent(self, event):
        super(Profile, self).paintEvent(event)

        # DRAW BACKGROUND IMAGE
        p = QPainter(self)
        p.setRenderHint(QPainter.Antialiasing)

        image = QPixmap()
        image.load("res/img/back.jpg")
        image = image.scaled(self.width(), self.height(), Qt.IgnoreAspectRatio,
                             Qt.SmoothTransformation)
        p.drawPixmap(self.rect(), image)
Beispiel #20
0
def get_figure_widget(fig):
    buf = io.BytesIO()
    fig.savefig(buf, format='png')
    buf.seek(0)

    pixmap = QPixmap()
    pixmap.loadFromData(buf.read())
    buf.close()

    fig_label = QLabel()
    fig_label.setPixmap(pixmap)

    return fig_label
Beispiel #21
0
 def __init__(self):
     QWidget.__init__(self, None)
     self.ui = Ui_Form()
     self.ui.setupUi(self)
     self.ui.Spoon.setPixmap(QPixmap("app/UI/spoon.png"))
     self.ui.Spoon.setScaledContents(True)
     self.ui.fork.setPixmap(QPixmap("app/UI/fork.png"))
     self.ui.fork.setScaledContents(True)
     self.ui.usernameLabel.setPixmap(QPixmap("app/UI/id-card.png"))
     self.ui.usernameLabel.setScaledContents(True)
     self.ui.passwordLabel.setPixmap(QPixmap("app/UI/padlock.png"))
     self.ui.passwordLabel.setScaledContents(True)
     # self.ui.logButton.clicked connect( self.login )
     self.setFixedSize(455, 305)
Beispiel #22
0
 def set(self, path):
     if path == SETTINGS_VALUES.MULTIPLE_VALUES:
         path = SETTINGS_VALUES.MULTIPLE_VALUES_IMG
     if path == self.image_path:
         return
     if self.setPixmap(QPixmap(path)):
         self.image_path = path
         self.imageChanged.emit(path)
     else:
         # set to default image
         path = APPLICATION_IMAGES[":/image/default.jpg"]
         self.setPixmap(QPixmap(path))
         self.image_path = path
         self.imageChanged.emit(path)
Beispiel #23
0
 def create_icon(player_colour: QColor) -> QPixmap:
     size = 200
     icon = QPixmap(size, size)
     icon.fill(Qt.transparent)
     painter = QPainter(icon)
     try:
         painter.setBrush(player_colour)
         pen = QPen()
         pen.setWidth(3)
         painter.setPen(pen)
         painter.drawEllipse(1, 1, size - 2, size - 2)
     finally:
         painter.end()
     return icon
Beispiel #24
0
    def printPreview(self):
        preview = QLabel(self, Qt.Window)
        preview.setAttribute(Qt.WA_DeleteOnClose)
        preview.setScaledContents(True)
        preview.setWindowTitle("Print Preview")
        pix = QPixmap(1000, 300)
        pix.fill(Qt.white)

        p = QPainter(pix)
        p.setRenderHints(QPainter.Antialiasing)
        self.ui.ganttView.print_(p, pix.rect())

        preview.setPixmap(pix)
        preview.show()
Beispiel #25
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 #26
0
 def __chose_image(self):
     dir = os.getcwd()
     path = QFileDialog.getOpenFileName(
         self, 'Open Image', dir, "Image Files (*.png *.jpg *.bmp *.jpeg)")
     if path[0] != '':
         self.image = path[0].split(
             '/')[-1] if path[0] != '' else self.image
         im = cv2.imread(self.image, 0)
         ret, trash = cv2.threshold(im, 240, 255, cv2.THRESH_BINARY)
         self.image_bw = self.image.split('.')[0] + '_binary.jpg'
         cv2.imwrite(self.image_bw, trash)
         image = QPixmap(self.image_bw)
         new_image = image.scaled(540, 249, Qt.KeepAspectRatio,
                                  Qt.FastTransformation)
         self.put_image(widget=self.ui.sourceLabel, image=new_image)
Beispiel #27
0
 def header_check_box_clicked(self, col):
     '''由表头中的全选框触发'''
     if col == 0:
         if self.tableWidget.horizontalHeaderItem(
                 0).icon().cacheKey() == self.unchecked_cachekey:
             self.tableWidget.horizontalHeaderItem(0).setIcon(
                 QIcon(QPixmap(self.checked_img)))
             self.select_all()
         else:
             self.tableWidget.horizontalHeaderItem(0).setIcon(
                 QIcon(QPixmap(self.unchecked_img)))
             self.unchecked_cachekey = self.tableWidget.horizontalHeaderItem(
                 0).icon().cacheKey()
             # unchecked_cachekey会变化
             self.unselect_all()
Beispiel #28
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)
    def setThemeHack(self):
        main.Settings.BTN_LEFT_BOX_COLOR = "background-color: #495474;"
        main.Settings.BTN_RIGHT_BOX_COLOR = "background-color: #495474;"
        main.Settings.MENU_SELECTED_STYLESHEET = MENU_SELECTED_STYLESHEET = """
        border-left: 22px solid qlineargradient(spread:pad, x1:0.034, y1:0, x2:0.216, y2:0, stop:0.499 rgba(255, 121, 198, 255), stop:0.5 rgba(85, 170, 255, 0));
        background-color: #566388;
        """

        cwd = os.getcwd()
        # SET MANUAL STYLES
        self.ui.output_text.clear()
        self.ui.process_user_input_table.horizontalHeader().setVisible(True)
        self.ui.append_checkbox.setChecked(False)
        self.ui.logo_label.setPixmap(QPixmap(f"{cwd}/gui/images/images/PythonLogoPNG.png"))
        self.ui.proc_error_label.setStyleSheet("color: #6272A4; font: 13pt 'Segoe UI';")
        self.ui.proc_error_label.setAlignment(Qt.AlignCenter)
        self.ui.path_line.setStyleSheet("background-color: #6272a4;")
        self.ui.open_btn.setStyleSheet("background-color: #6272a4;")
        self.ui.process_next_btn.setStyleSheet("background-color: #6272a4;")
        self.ui.new_row_btn.setStyleSheet("background-color: #6272a4;")
        self.ui.remove_a_row.setStyleSheet("background-color: #6272a4;")
        self.ui.output_text.setStyleSheet("background-color: #6272a4;")
        self.ui.process_user_input_table.setStyleSheet(
            "QScrollBar:vertical { background: #6272a4; } QScrollBar:horizontal { background: #6272a4; }")
        self.ui.combo_functions.setStyleSheet("background-color: #6272a4;")
        self.ui.combo_classes.setStyleSheet("background-color: #6272a4;")
Beispiel #30
0
    def update(self):
        for i, fact in enumerate(self.game.factories):
            img = QPixmap('pictures/factory1.png')
            self.money[i].setText(str(fact.money))
            if i == self.game.cur_factory:
                self.money[i].setFont(QFont('Times', 24, QFont.Bold))
                img = img.scaled(280, 280, QtCore.Qt.KeepAspectRatio)
            else:
                self.money[i].setFont(QFont('Times', 14))
                img = img.scaled(200, 200, QtCore.Qt.KeepAspectRatio)

            self.pictures[i].setPixmap(img)

        self.level.setText(f'Уровень: {self.game.cur_level}')
        self.river.setText(
            f'Процент загрязнения реки: {self.game.river.mud_level}%')