Snapshot/SnapshotFreehandGrabber.py

changeset 2106
cca04724bff8
parent 1965
96f5a76e1845
child 2131
e79d0610347a
equal deleted inserted replaced
2104:671c38b34bef 2106:cca04724bff8
5 5
6 """ 6 """
7 Module implementing a grabber widget for a freehand snapshot region. 7 Module implementing a grabber widget for a freehand snapshot region.
8 """ 8 """
9 9
10 from PyQt4.QtCore import pyqtSignal, Qt, QRect, QPoint, QTimer 10 from PyQt4.QtCore import pyqtSignal, Qt, QRect, QPoint, QTimer, qVersion
11 from PyQt4.QtGui import QWidget, QPixmap, QColor, QRegion, QApplication, QPainter, \ 11 from PyQt4.QtGui import QWidget, QPixmap, QColor, QRegion, QApplication, QPainter, \
12 QPalette, QToolTip, QPolygon, QPen, QBrush, QPaintEngine 12 QPalette, QToolTip, QPolygon, QPen, QBrush, QPaintEngine
13 if qVersion() >= "5.0.0":
14 from PyQt4.QtGui import QScreen
13 15
14 16
15 def drawPolygon(painter, polygon, outline, fill=QColor()): 17 def drawPolygon(painter, polygon, outline, fill=QColor()):
16 """ 18 """
17 Module function to draw a polygon with the given parameters. 19 Module function to draw a polygon with the given parameters.
78 Private slot to initialize the rest of the widget. 80 Private slot to initialize the rest of the widget.
79 """ 81 """
80 self.__desktop = QApplication.desktop() 82 self.__desktop = QApplication.desktop()
81 x = self.__desktop.x() 83 x = self.__desktop.x()
82 y = self.__desktop.y() 84 y = self.__desktop.y()
83 self.__pixmap = QPixmap.grabWindow(self.__desktop.winId(), x, y, 85 if qVersion() >= "5.0.0":
84 self.__desktop.width(), self.__desktop.height()) 86 self.__pixmap = QScreen.grabWindow(self.__desktop.winId(), x, y,
87 self.__desktop.width(), self.__desktop.height())
88 else:
89 self.__pixmap = QPixmap.grabWindow(self.__desktop.winId(), x, y,
90 self.__desktop.width(), self.__desktop.height())
85 self.resize(self.__pixmap.size()) 91 self.resize(self.__pixmap.size())
86 self.move(x, y) 92 self.move(x, y)
87 self.setCursor(Qt.CrossCursor) 93 self.setCursor(Qt.CrossCursor)
88 self.show() 94 self.show()
89 95

eric ide

mercurial