How to use the photini.pyqt.QtGui function in Photini

To help you get started, we’ve selected a few Photini examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jim-easterbrook / Photini / src / photini / photinimap.py View on Github external
def __init__(self, image_list, parent=None):
        super(PhotiniMap, self).__init__(parent)
        self.app = QtWidgets.QApplication.instance()
        self.image_list = image_list
        name = self.__module__.split('.')[-1]
        self.script_dir = pkg_resources.resource_filename(
            'photini', 'data/' + name + '/')
        self.drag_icon = QtGui.QPixmap(
            os.path.join(self.script_dir, '../map_pin_grey.png'))
        self.drag_hotspot = 11, 35
        self.search_string = None
        self.map_loaded = False
        self.marker_info = {}
        self.map_status = {}
        self.dropped_images = []
        self.geocoder = self.get_geocoder()
        self.setLayout(QtWidgets.QHBoxLayout())
        ## left side
        left_side = QtWidgets.QGridLayout()
        # latitude & longitude
        self.coords = LatLongDisplay(self.image_list)
        left_side.addWidget(self.coords.label, 0, 0)
        self.coords.changed.connect(self.new_coords)
        left_side.addWidget(self.coords, 0, 1)
github jim-easterbrook / Photini / src / photini / facebook.py View on Github external
def __init__(self, *arg, **kw):
        self.upload_config = FacebookUploadConfig()
        super(FacebookUploader, self).__init__(self.upload_config, *arg, **kw)
        self.upload_config.new_album.connect(self.new_album)
        self.upload_config.select_album.connect(self.select_album)
        self.service_name = self.tr('Facebook')
        self.image_types = {
            'accepted': ('image/jpeg', 'image/png'),
            'rejected': ('image/x-portable-anymap', 'image/x-canon-cr2'),
            }
        self.login_popup = None
        # add Facebook icon to connect button
        icon_file = pkg_resources.resource_filename(
            'photini', 'data/facebook_logo.png')
        self.user_connect.setIcon(QtGui.QIcon(QtGui.QPixmap(icon_file)))
github jim-easterbrook / Photini / src / photini / uploader.py View on Github external
def show_user(self, name, picture):
        if name:
            self.user_name.setText(translate(
                'UploaderTabsAll',
                'Logged in as {0} on {1}').format(name, self.service_name))
        else:
            self.user_name.setText(translate(
                'UploaderTabsAll',
                'Not logged in to {}').format(self.service_name))
        pixmap = QtGui.QPixmap()
        if picture:
            pixmap.loadFromData(picture)
        self.user_photo.setPixmap(pixmap)
github jim-easterbrook / Photini / src / photini / metadata.py View on Github external
def size(self):
        if self.w and self.h:
            return self.w, self.h
        pixmap = QtGui.QPixmap()
        pixmap.loadFromData(self.data)
        return pixmap.width(), pixmap.height()
github jim-easterbrook / Photini / src / photini / editor.py View on Github external
def __init__(self, options, initial_files):
        super(MainWindow, self).__init__()
        self.setWindowTitle(translate(
            'MenuBar', "Photini photo metadata editor"))
        pixmap = QtGui.QPixmap()
        pixmap.loadFromData(pkg_resources.resource_string(
            'photini', 'data/icons/48/photini.png'))
        icon = QtGui.QIcon(pixmap)
        self.setWindowIcon(icon)
        self.selection = list()
        # logger window
        self.loggerwindow = LoggerWindow(options.verbose)
        self.loggerwindow.setWindowIcon(icon)
        # set network proxy
        proxies = getproxies()
        if 'http' in proxies:
            parsed = urlparse(proxies['http'])
            QNetworkProxy.setApplicationProxy(QNetworkProxy(
                QNetworkProxy.HttpProxy, parsed.hostname, parsed.port))
        # create shared global objects
        self.app = QtWidgets.QApplication.instance()
        self.app.config_store = ConfigStore('editor', parent=self)
        self.app.spell_check = SpellCheck(parent=self)
        self.app.open_cage = OpenCage(parent=self)
github jim-easterbrook / Photini / src / photini / importer.py View on Github external
def validate(self, inp, pos):
        if os.path.abspath(inp) == inp:
            return QtGui.QValidator.Acceptable, inp, pos
        return QtGui.QValidator.Intermediate, inp, pos
github jim-easterbrook / Photini / src / photini / imagelist.py View on Github external
def get_qt_image(self):
        qt_im = QtGui.QImage(self.path)
        if not qt_im or qt_im.isNull():
            logger.error('Cannot read %s image data from %s',
                         self.file_type, self.path)
            return None
        # reorient if required
        if self.file_type in ('image/x-canon-cr2', 'image/x-nikon-nef'):
            qt_im = self.transform(
                qt_im, self.metadata.orientation, inverse=True)
        w = qt_im.width()
        h = qt_im.height()
        if max(w, h) > 6000:
            # use Qt's scaling (not high quality) to pre-shrink very
            # large images, to avoid PIL "DecompressionBombWarning"
            return qt_im.scaled(
                6000, 6000, Qt.KeepAspectRatio, Qt.SmoothTransformation)
            w = qt_im.width()
github jim-easterbrook / Photini / src / photini / importer.py View on Github external
buttons.addWidget(self.move_button)
        self.copy_button = StartStopButton(
            translate('ImporterTab', 'Copy\nphotos'),
            translate('ImporterTab', 'Stop\ncopy'))
        self.copy_button.click_start.connect(self.copy_selected)
        self.copy_button.click_stop.connect(self.stop_copy)
        buttons.addWidget(self.copy_button)
        self.layout().addLayout(buttons, 0, 1, 2, 1)
        self.selection_changed()
        # final initialisation
        self.image_list.sort_order_changed.connect(self.sort_file_list)
        if qt_version_info >= (5, 0):
            path = QtCore.QStandardPaths.writableLocation(
                QtCore.QStandardPaths.PicturesLocation)
        else:
            path = QtGui.QDesktopServices.storageLocation(
                QtGui.QDesktopServices.PicturesLocation)
        self.path_format.setText(
            os.path.join(path, '%Y', '%Y_%m_%d', '{name}'))
        self.refresh()
        self.list_files()
github jim-easterbrook / Photini / src / photini / importer.py View on Github external
subst['number'] = numbers[-1]
        else:
            subst['number'] = ''
        subst['root'], subst['ext'] = os.path.splitext(name)
        subst['camera'] = file_data['camera'] or 'unknown_camera'
        subst['camera'] = subst['camera'].replace(' ', '_')
        # process {...} parts first
        try:
            result = self.format_string.format(**subst)
        except (KeyError, ValueError):
            result = self.format_string
        # then do timestamp
        return file_data['timestamp'].strftime(result)


class PathFormatValidator(QtGui.QValidator):
    def validate(self, inp, pos):
        if os.path.abspath(inp) == inp:
            return QtGui.QValidator.Acceptable, inp, pos
        return QtGui.QValidator.Intermediate, inp, pos

    def fixup(self, inp):
        return os.path.abspath(inp)


class TabWidget(QtWidgets.QWidget):
    @staticmethod
    def tab_name():
        return translate('ImporterTab', '&Import photos')

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