Skip to content

Commit

Permalink
Fix for Maya 2019 error (#5)
Browse files Browse the repository at this point in the history
* Initial fix

* Py3 friendly long

* Fixed missing :, extra comment space
  • Loading branch information
Joe Yu authored Jun 2, 2020
1 parent 9da6d2f commit e54da65
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions python/screen_grab/screen_grab.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,14 +334,21 @@ def get_desktop_pixmap(rect):
:returns: Captured image
:rtype: :class:`~PySide.QtGui.QPixmap`
"""
desktop_id = QtGui.QApplication.desktop().winId()
x_y_w_h = rect.x(), rect.y(), rect.width(), rect.height()

if QT_MAJOR == 5:
screen = QtGui.QApplication.primaryScreen()
pixmap = screen.grabWindow(0, *x_y_w_h)
try:
pixmap = screen.grabWindow(desktop_id, *x_y_w_h)
except TypeError as error:
if "quintptr" in str(error):
ptr_type = getattr(__builtins__, "long", int) # Py3 safe long
pixmap = screen.grabWindow(ptr_type(desktop_id), *x_y_w_h)
else:
raise
elif QT_MAJOR == 4:
desktop = QtGui.QApplication.desktop()
pixmap = QtGui.QPixmap.grabWindow(desktop.winId(), *x_y_w_h)
pixmap = QtGui.QPixmap.grabWindow(desktop_id, *x_y_w_h)
else:
message = "Screen capture not implmented for Qt %d"
raise NotImplementedError(message % QT_MAJOR)
Expand Down

0 comments on commit e54da65

Please sign in to comment.