eric6/Snapshot/SnapshotRegionGrabber.py

changeset 7966
3afa7b9e51b0
parent 7957
7bdfa13bc3f5
child 8143
2c730d5fd177
equal deleted inserted replaced
7965:48fbf9149d16 7966:3afa7b9e51b0
11 from PyQt5.QtGui import ( 11 from PyQt5.QtGui import (
12 QPixmap, QColor, QRegion, QPainter, QPalette, QPaintEngine, QPen, QBrush, 12 QPixmap, QColor, QRegion, QPainter, QPalette, QPaintEngine, QPen, QBrush,
13 QGuiApplication, QCursor 13 QGuiApplication, QCursor
14 ) 14 )
15 from PyQt5.QtWidgets import QWidget, QToolTip 15 from PyQt5.QtWidgets import QWidget, QToolTip
16
17 import Globals
16 18
17 19
18 def drawRect(painter, rect, outline, fill=None): 20 def drawRect(painter, rect, outline, fill=None):
19 """ 21 """
20 Module function to draw a rectangle with the given parameters. 22 Module function to draw a rectangle with the given parameters.
111 113
112 def __initialize(self): 114 def __initialize(self):
113 """ 115 """
114 Private slot to initialize the rest of the widget. 116 Private slot to initialize the rest of the widget.
115 """ 117 """
116 screen = QGuiApplication.screens()[0] 118 if Globals.isMacPlatform():
117 self.__virtualGeometrie = screen.availableVirtualGeometry() 119 # macOS variant
118 screen = QGuiApplication.screenAt(QCursor.pos()) 120 screen = QGuiApplication.screenAt(QCursor.pos())
119 sgeom = screen.geometry() 121 geom = screen.geometry()
120 self.__pixmap = screen.grabWindow( 122 self.__pixmap = screen.grabWindow(
121 0, sgeom.x(), sgeom.y(), sgeom.width(), sgeom.height()) 123 0, geom.x(), geom.y(), geom.width(), geom.height())
124 else:
125 # Linux variant
126 # Windows variant
127 screen = QGuiApplication.screens()[0]
128 geom = screen.availableVirtualGeometry()
129 self.__pixmap = screen.grabWindow(
130 0, geom.x(), geom.y(), geom.width(), geom.height())
122 self.resize(self.__pixmap.size()) 131 self.resize(self.__pixmap.size())
123 self.move(sgeom.x(), sgeom.y()) 132 self.move(geom.x(), geom.y())
124 self.setCursor(Qt.CrossCursor) 133 self.setCursor(Qt.CrossCursor)
125 self.show() 134 self.show()
126 135
127 self.grabMouse() 136 self.grabMouse()
128 self.grabKeyboard() 137 self.grabKeyboard()

eric ide

mercurial