--- a/eric6/Snapshot/SnapshotRegionGrabber.py Mon Sep 23 19:10:42 2019 +0200 +++ b/eric6/Snapshot/SnapshotRegionGrabber.py Mon Sep 23 19:22:12 2019 +0200 @@ -9,8 +9,9 @@ from PyQt5.QtCore import pyqtSignal, Qt, QRect, QPoint, QTimer, QLocale -from PyQt5.QtGui import QPixmap, QColor, QRegion, QPainter, QPalette, \ - QPaintEngine, QPen, QBrush +from PyQt5.QtGui import ( + QPixmap, QColor, QRegion, QPainter, QPalette, QPaintEngine, QPen, QBrush +) from PyQt5.QtWidgets import QWidget, QApplication, QToolTip @@ -189,15 +190,19 @@ textRect = painter.boundingRect(self.rect(), Qt.AlignLeft, txt) boundingRect = textRect.adjusted(-4, 0, 0, 0) - if textRect.width() < r.width() - 2 * self.__handleSize and \ - textRect.height() < r.height() - 2 * self.__handleSize and \ - r.width() > 100 and \ - r.height() > 100: + if ( + textRect.width() < r.width() - 2 * self.__handleSize and + textRect.height() < r.height() - 2 * self.__handleSize and + r.width() > 100 and + r.height() > 100 + ): # center, unsuitable for small selections boundingRect.moveCenter(r.center()) textRect.moveCenter(r.center()) - elif r.y() - 3 > textRect.height() and \ - r.x() + textRect.width() < self.rect().width(): + elif ( + r.y() - 3 > textRect.height() and + r.x() + textRect.width() < self.rect().width() + ): # on top, left aligned boundingRect.moveBottomLeft(QPoint(r.x(), r.y() - 3)) textRect.moveBottomLeft(QPoint(r.x() + 2, r.y() - 3)) @@ -205,8 +210,10 @@ # left, top aligned boundingRect.moveTopRight(QPoint(r.x() - 3, r.y())) textRect.moveTopRight(QPoint(r.x() - 5, r.y())) - elif r.bottom() + 3 + textRect.height() < self.rect().bottom() and \ - r.right() > textRect.width(): + elif ( + r.bottom() + 3 + textRect.height() < self.rect().bottom() and + r.right() > textRect.width() + ): # at bottom, right aligned boundingRect.moveTopRight(QPoint(r.right(), r.bottom() + 3)) textRect.moveTopRight(QPoint(r.right() - 2, r.bottom() + 3)) @@ -220,9 +227,11 @@ drawRect(painter, boundingRect, textColor, textBackgroundColor) painter.drawText(textRect, Qt.AlignHCenter, txt) - if (r.height() > self.__handleSize * 2 and - r.width() > self.__handleSize * 2) or \ - not self.__mouseDown: + if ( + (r.height() > self.__handleSize * 2 and + r.width() > self.__handleSize * 2) or + not self.__mouseDown + ): self.__updateHandles() painter.setPen(Qt.NoPen) painter.setBrush(handleColor) @@ -308,20 +317,20 @@ r = QRect(self.__selectionBeforeDrag) offset = evt.pos() - self.__dragStartPoint - if self.__mouseOverHandle in \ - [self.__TLHandle, self.__THandle, self.__TRHandle]: + if self.__mouseOverHandle in [ + self.__TLHandle, self.__THandle, self.__TRHandle]: r.setTop(r.top() + offset.y()) - if self.__mouseOverHandle in \ - [self.__TLHandle, self.__LHandle, self.__BLHandle]: + if self.__mouseOverHandle in [ + self.__TLHandle, self.__LHandle, self.__BLHandle]: r.setLeft(r.left() + offset.x()) - if self.__mouseOverHandle in \ - [self.__BLHandle, self.__BHandle, self.__BRHandle]: + if self.__mouseOverHandle in [ + self.__BLHandle, self.__BHandle, self.__BRHandle]: r.setBottom(r.bottom() + offset.y()) - if self.__mouseOverHandle in \ - [self.__TRHandle, self.__RHandle, self.__BRHandle]: + if self.__mouseOverHandle in [ + self.__TRHandle, self.__RHandle, self.__BRHandle]: r.setRight(r.right() + offset.x()) r.setTopLeft(self.__limitPointToRect(r.topLeft(), self.rect())) @@ -369,8 +378,10 @@ """ self.__mouseDown = False self.__newSelection = False - if self.__mouseOverHandle is None and \ - self.__selection.contains(evt.pos()): + if ( + self.__mouseOverHandle is None and + self.__selection.contains(evt.pos()) + ): self.setCursor(Qt.OpenHandCursor) self.update()