How to use the photini.pyqt.QtCore 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 / mapboxmap.py View on Github external
##  .

from __future__ import unicode_literals

import locale
import logging

import requests

from photini.configstore import key_store
from photini.photinimap import GeocoderBase, PhotiniMap
from photini.pyqt import (
    Busy, catch_all, CompactButton, QtCore, QtGui, QtWidgets)

logger = logging.getLogger(__name__)
translate = QtCore.QCoreApplication.translate


class MapboxGeocoder(GeocoderBase):
    api_key = key_store.get('mapboxmap', 'api_key')

    def do_geocode(self, query, params={}):
        params['access_token'] = self.api_key
        params['autocomplete '] = 'false'
        lang, encoding = locale.getdefaultlocale()
        if lang:
            params['language'] = lang
        query += '.json'
        url = 'https://api.mapbox.com/geocoding/v5/mapbox.places/' + query
        with Busy():
            self.rate_limit()
            try:
github jim-easterbrook / Photini / src / photini / imagelist.py View on Github external
    @QtCore.pyqtSlot(bool)
    @catch_all
    def show_status(self, changed):
        status = ''
        # set 'geotagged' status
        if self.metadata.latlong:
            status += six.unichr(0x2690)
        # set 'unsaved' status
        if changed:
            status += six.unichr(0x26A1)
        self.status.setText(status)
        self._elide_name()
        if changed:
            self.image_list.new_metadata.emit(True)
github jim-easterbrook / Photini / src / photini / spelling.py View on Github external
    @QtCore.pyqtSlot(bool)
    @catch_all
    def enable(self, enabled):
        self.enabled = enabled and bool(Gspell or enchant)
        self.config_store.set('spelling', 'enabled', str(self.enabled))
        self.new_dict.emit()
github jim-easterbrook / Photini / src / photini / technical.py View on Github external
from collections import defaultdict
from datetime import datetime, timedelta
import logging
import math
import re

import six

from photini.metadata import LensSpec
from photini.pyqt import (
    catch_all, ComboBox, multiple, multiple_values, Qt, QtCore, QtGui,
    QtWidgets, scale_font, set_symbol_font, Slider, SquareButton,
    width_for_text)

logger = logging.getLogger(__name__)
translate = QtCore.QCoreApplication.translate


class DropdownEdit(ComboBox):
    new_value = QtCore.pyqtSignal(object)

    def __init__(self, *arg, **kw):
        super(DropdownEdit, self).__init__(*arg, **kw)
        self.addItem(translate('TechnicalTab', ''), None)
        self.addItem('', None)
        self.setItemData(1, 0, Qt.UserRole - 1)
        self.addItem(multiple_values(), None)
        self.setItemData(2, 0, Qt.UserRole - 1)
        self.currentIndexChanged.connect(self.current_index_changed)

    @QtCore.pyqtSlot(int)
    @catch_all
github jim-easterbrook / Photini / src / photini / photinimap.py View on Github external
    @QtCore.pyqtSlot()
    @catch_all
    def search(self, search_string=None, bounded=True):
        if not search_string:
            search_string = self.edit_box.lineEdit().text()
            self.edit_box.clearEditText()
        if not search_string:
            return
        self.search_string = search_string
        self.clear_search()
        if bounded:
            bounds = self.map_status['bounds']
        else:
            bounds = None
        for result in self.geocoder.search(search_string, bounds=bounds):
            north, east, south, west, name = result
            self.edit_box.addItem(name, (north, east, south, west))
github jim-easterbrook / Photini / src / photini / uploader.py View on Github external
import time

import six
from six.moves.BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
from six.moves.urllib import parse

import appdirs
import keyring

from photini.metadata import Metadata
from photini.pyqt import (
    Busy, catch_all, DisableWidget, Qt, QtCore, QtGui, QtWidgets,
    StartStopButton)

logger = logging.getLogger(__name__)
translate = QtCore.QCoreApplication.translate

class UploaderSession(QtCore.QObject):
    connection_changed = QtCore.pyqtSignal(bool)

    @QtCore.pyqtSlot()
    @catch_all
    def log_out(self):
        keyring.delete_password('photini', self.name)
        self.disconnect()

    def get_password(self):
        return keyring.get_password('photini', self.name)

    def set_password(self, password):
        keyring.set_password('photini', self.name, password)
github jim-easterbrook / Photini / src / photini / metadata.py View on Github external
def write(self, handler, tag):
        if handler.is_xmp_tag(tag):
            data = self.data
            if self.fmt != 'JPEG':
                pixmap = QtGui.QPixmap()
                pixmap.loadFromData(data)
                buf = QtCore.QBuffer()
                buf.open(QtCore.QIODevice.WriteOnly)
                pixmap.save(buf, 'JPEG')
                data = buf.data().data()
                w = pixmap.width()
                h = pixmap.height()
            else:
                w, h = self.size()
            data = codecs.encode(data, 'base64_codec')
            if not six.PY2:
                data = data.decode('ascii')
            handler.set_string(tag, (data, 'JPEG', str(w), str(h)))
        elif handler.is_exif_tag(tag):
            handler.set_exif_thumbnail_from_buffer(self.data)
github jim-easterbrook / Photini / src / photini / importer.py View on Github external
logger.warning(
                    'Please close image %s before moving it', info['name'])
            else:
                copy_list.append(info)
        if not copy_list:
            return
        if move:
            self.move_button.set_checked(True)
            self.copy_button.setEnabled(False)
        else:
            self.copy_button.set_checked(True)
            self.move_button.setEnabled(False)
        self.last_file_copied = None, datetime.min
        # start file copier in a separate thread
        self.file_copier = FileCopier(self.source, copy_list, move)
        self.file_copier_thread = QtCore.QThread(self)
        self.file_copier.moveToThread(self.file_copier_thread)
        self.file_copier.output.connect(self.file_copied)
        self.file_copier_thread.started.connect(self.file_copier.start)
        self.file_copier_thread.start()
github jim-easterbrook / Photini / src / photini / loggerwindow.py View on Github external
    @QtCore.pyqtSlot(str)
    def write(self, msg):
        self.text.append(msg)
github jim-easterbrook / Photini / src / photini / imagelist.py View on Github external
from six import BytesIO
from six.moves.urllib.parse import unquote

try:
    import PIL.Image as PIL
except ImportError:
    PIL = None

from photini.ffmpeg import FFmpeg
from photini.metadata import Metadata, MultiString
from photini.pyqt import (
    Busy, catch_all, image_types, Qt, QtCore, QtGui, QtWidgets, qt_version_info,
    scale_font, set_symbol_font, video_types)

logger = logging.getLogger(__name__)
translate = QtCore.QCoreApplication.translate
DRAG_MIMETYPE = 'application/x-photini-image'


class TableWidget(QtWidgets.QTableWidget):
    @catch_all
    def sizeHint(self):
        h_hdr = self.horizontalHeader()
        v_hdr = self.verticalHeader()
        return QtCore.QSize(h_hdr.length() + v_hdr.sizeHint().width() + 4,
                            v_hdr.length() + h_hdr.sizeHint().height() + 4)


class Image(QtWidgets.QFrame):
    def __init__(self, path, image_list, thumb_size=80, *arg, **kw):
        super(Image, self).__init__(*arg, **kw)
        self.path = path