Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __init__(self, images, *arg, **kw):
super(NewLensDialog, self).__init__(*arg, **kw)
self.setWindowTitle(translate('TechnicalTab', 'Photini: define lens'))
self.setLayout(QtWidgets.QVBoxLayout())
# main dialog area
scroll_area = QtWidgets.QScrollArea()
scroll_area.setWidgetResizable(True)
self.layout().addWidget(scroll_area)
panel = QtWidgets.QWidget()
panel.setLayout(QtWidgets.QFormLayout())
panel.layout().setFieldGrowthPolicy(
QtWidgets.QFormLayout.AllNonFixedFieldsGrow)
# ok & cancel buttons
button_box = QtWidgets.QDialogButtonBox(
QtWidgets.QDialogButtonBox.Ok | QtWidgets.QDialogButtonBox.Cancel)
button_box.accepted.connect(self.accept)
button_box.rejected.connect(self.reject)
self.layout().addWidget(button_box)
# model
self.lens_model = QtWidgets.QLineEdit()
self.lens_model.setMinimumWidth(
width_for_text(self.lens_model, 'x' * 35))
panel.layout().addRow(
translate('TechnicalTab', 'Model name'), self.lens_model)
# maker
@QtCore.pyqtSlot()
@catch_all
def editing_finished(self):
self.new_value.emit(self, self.get_value())
class QTabBar(QtWidgets.QTabBar):
context_menu = QtCore.pyqtSignal(QtGui.QContextMenuEvent)
@catch_all
def contextMenuEvent(self, event):
self.context_menu.emit(event)
class TabWidget(QtWidgets.QWidget):
@staticmethod
def tab_name():
return translate('AddressTab', '&Address')
def __init__(self, image_list, parent=None):
super(TabWidget, self).__init__(parent)
self.app = QtWidgets.QApplication.instance()
self.geocoder = self.app.open_cage
self.image_list = image_list
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)
def __init__(self, *arg, **kw):
super(EditSettings, self).__init__(*arg, **kw)
self.config_store = QtWidgets.QApplication.instance().config_store
self.setWindowTitle(self.tr('Photini: settings'))
self.setLayout(QtWidgets.QVBoxLayout())
# main dialog area
scroll_area = QtWidgets.QScrollArea()
self.layout().addWidget(scroll_area)
panel = QtWidgets.QWidget()
panel.setLayout(QtWidgets.QFormLayout())
panel.layout().setRowWrapPolicy(max(QtWidgets.QFormLayout.WrapLongRows,
panel.layout().rowWrapPolicy()))
# apply & cancel buttons
self.button_box = QtWidgets.QDialogButtonBox(
QtWidgets.QDialogButtonBox.Apply | QtWidgets.QDialogButtonBox.Cancel)
self.button_box.clicked.connect(self.button_clicked)
self.layout().addWidget(self.button_box)
# copyright holder name
self.copyright_name = SingleLineEdit(spell_check=True)
self.copyright_name.set_value(
self.config_store.get('user', 'copyright_name', ''))
panel.layout().addRow(self.tr('Copyright holder name'), self.copyright_name)
# copyright text
self.copyright_text = SingleLineEdit(spell_check=True)
self.copyright_text.set_value(
# line edit box
self.edit = LineEdit()
layout.addWidget(self.edit)
# auto complete button
self.auto = QtWidgets.QPushButton(translate('DescriptiveTab', 'Auto'))
layout.addWidget(self.auto)
# adopt child widget methods and signals
self.set_value = self.edit.set_value
self.get_value = self.edit.get_value
self.set_multiple = self.edit.set_multiple
self.is_multiple = self.edit.is_multiple
self.editingFinished = self.edit.editingFinished
self.autoComplete = self.auto.clicked
class RatingWidget(QtWidgets.QWidget):
def __init__(self, *arg, **kw):
super(RatingWidget, self).__init__(*arg, **kw)
self.multiple_values = multiple_values()
self.setLayout(QtWidgets.QHBoxLayout())
self.layout().setContentsMargins(0, 0, 0, 0)
# slider
self.slider = Slider(Qt.Horizontal)
self.slider.setFixedWidth(200)
self.slider.setRange(-2, 5)
self.slider.setPageStep(1)
self.slider.valueChanged.connect(self.set_display)
self.layout().addWidget(self.slider)
# display
self.display = QtWidgets.QLineEdit()
self.display.setFrame(False)
self.display.setReadOnly(True)
from collections import defaultdict
import logging
import os
import requests
from photini.metadata import Location
from photini.photinimap import LatLongDisplay
from photini.pyqt import catch_all, Qt, QtCore, QtGui, QtWidgets, SingleLineEdit
logger = logging.getLogger(__name__)
translate = QtCore.QCoreApplication.translate
class LocationInfo(QtWidgets.QWidget):
new_value = QtCore.pyqtSignal(object, dict)
def __init__(self, *args, **kw):
super(LocationInfo, self).__init__(*args, **kw)
layout = QtWidgets.QGridLayout()
self.setLayout(layout)
layout.setContentsMargins(0, 0, 0, 0)
self.members = {}
for key in ('sublocation', 'city', 'province_state',
'country_name', 'country_code', 'world_region'):
self.members[key] = SingleLineEdit()
self.members[key].editingFinished.connect(self.editing_finished)
self.members['country_code'].setMaximumWidth(40)
for j, text in enumerate((
translate('AddressTab', 'Street'),
translate('AddressTab', 'City'),
@QtCore.pyqtSlot(int)
@catch_all
def add_favourite(self, idx):
if idx <= 0:
return
self.favourites.setCurrentIndex(0)
new_value = self.favourites.itemText(idx)
current_value = self.get_value()
if current_value:
new_value = current_value + '; ' + new_value
self.set_value(new_value)
self.editingFinished.emit()
class TabWidget(QtWidgets.QWidget):
@staticmethod
def tab_name():
return translate('DescriptiveTab', '&Descriptive metadata')
def __init__(self, image_list, *arg, **kw):
super(TabWidget, self).__init__(*arg, **kw)
self.config_store = QtWidgets.QApplication.instance().config_store
self.image_list = image_list
self.form = QtWidgets.QFormLayout()
self.setLayout(self.form)
# construct widgets
self.widgets = {}
# title
self.widgets['title'] = SingleLineEdit(spell_check=True)
self.widgets['title'].editingFinished.connect(self.new_title)
self.form.addRow(translate(
def load_url(self, auth_url):
self.browser.load(QtCore.QUrl(auth_url))
@QtCore.pyqtSlot(QtCore.QUrl)
@catch_all
def auth_url_changed(self, url):
if url.path() != '/connect/login_success.html':
return
self.browser.setHtml('<p></p>')
self.result = url.toString()
if 'access_token' in url.fragment():
return self.accept()
self.reject()
class FacebookUploadConfig(QtWidgets.QWidget):
new_album = QtCore.pyqtSignal()
select_album = QtCore.pyqtSignal(int)
def __init__(self, *arg, **kw):
super(FacebookUploadConfig, self).__init__(*arg, **kw)
self.setLayout(QtWidgets.QHBoxLayout())
self.layout().setContentsMargins(0, 0, 0, 0)
self.widgets = {}
## upload config
config_group = QtWidgets.QGroupBox(self.tr('Options'))
config_group.setLayout(QtWidgets.QFormLayout())
self.layout().addWidget(config_group)
# suppress feed story
self.widgets['no_story'] = QtWidgets.QCheckBox()
config_group.layout().addRow(
self.tr('Suppress news feed story'), self.widgets['no_story'])
def __init__(self, parent=None):
super(ScrollArea, self).__init__(parent)
self.multi_row = None
self.set_multi_row(True)
self.setWidgetResizable(True)
self.setAcceptDrops(True)
widget = QtWidgets.QWidget()
self.thumbs = ThumbsLayout(scroll_area=self)
widget.setLayout(self.thumbs)
self.setWidget(widget)
# adopt some layout methods
self.add_widget = self.thumbs.addWidget
self.remove_widget = self.thumbs.removeWidget
translate('FlickrTab', 'Synchronise'))
self.sync_button.clicked.connect(self.sync_metadata)
self.layout().addWidget(self.sync_button, 1, 1)
# create new set
new_set_button = QtWidgets.QPushButton(
translate('FlickrTab', 'New album'))
new_set_button.clicked.connect(self.new_set)
self.layout().addWidget(new_set_button, 2, 1)
# list of sets widget
sets_group = QtWidgets.QGroupBox(
translate('FlickrTab', 'Add to albums'))
sets_group.setLayout(QtWidgets.QVBoxLayout())
scrollarea = QtWidgets.QScrollArea()
scrollarea.setFrameStyle(QtWidgets.QFrame.NoFrame)
scrollarea.setStyleSheet("QScrollArea { background-color: transparent }")
self.sets_widget = QtWidgets.QWidget()
self.sets_widget.setLayout(QtWidgets.QVBoxLayout())
self.sets_widget.layout().setSpacing(0)
self.sets_widget.layout().setSizeConstraint(
QtWidgets.QLayout.SetMinAndMaxSize)
scrollarea.setWidget(self.sets_widget)
self.sets_widget.setAutoFillBackground(False)
sets_group.layout().addWidget(scrollarea)
self.layout().addWidget(sets_group, 0, 2, 3, 1)
self.layout().setColumnStretch(2, 1)