Snapshot/SnapshotRegionGrabber.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 rectangular snapshot region. 7 Module implementing a grabber widget for a rectangular 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, QPaintEngine, QPen, QBrush 12 QPalette, QToolTip, QPaintEngine, QPen, QBrush
13 13 if qVersion() >= "5.0.0":
14 from PyQt4.QtGui import QScreen
14 15
15 def drawRect(painter, rect, outline, fill=QColor()): 16 def drawRect(painter, rect, outline, fill=QColor()):
16 """ 17 """
17 Module function to draw a rectangle with the given parameters. 18 Module function to draw a rectangle with the given parameters.
18 19
106 Private slot to initialize the rest of the widget. 107 Private slot to initialize the rest of the widget.
107 """ 108 """
108 self.__desktop = QApplication.desktop() 109 self.__desktop = QApplication.desktop()
109 x = self.__desktop.x() 110 x = self.__desktop.x()
110 y = self.__desktop.y() 111 y = self.__desktop.y()
111 self.__pixmap = QPixmap.grabWindow(self.__desktop.winId(), x, y, 112 if qVersion() >= "5.0.0":
112 self.__desktop.width(), self.__desktop.height()) 113 self.__pixmap = QScreen.grabWindow(self.__desktop.winId(), x, y,
114 self.__desktop.width(), self.__desktop.height())
115 else:
116 self.__pixmap = QPixmap.grabWindow(self.__desktop.winId(), x, y,
117 self.__desktop.width(), self.__desktop.height())
113 self.resize(self.__pixmap.size()) 118 self.resize(self.__pixmap.size())
114 self.move(x, y) 119 self.move(x, y)
115 self.setCursor(Qt.CrossCursor) 120 self.setCursor(Qt.CrossCursor)
116 self.show() 121 self.show()
117 122

eric ide

mercurial