How to use grab_to_buffer method in Pyscreenshot

Best Python code snippet using pyscreenshot_python

pyside_grabwindow.py

Source:pyside_grabwindow.py Github

copy

Full Screen

...20 from PySide import QtCore21 self.app = None22 self.QtGui = QtGui23 self.QtCore = QtCore24 def grab_to_buffer(self, buff, file_type='png'):25 QApplication = self.PySide.QtGui.QApplication26 QBuffer = self.PySide.QtCore.QBuffer27 QIODevice = self.PySide.QtCore.QIODevice28 QPixmap = self.PySide.QtGui.QPixmap29 if not self.app:30 self.app = QApplication([])31 qbuffer = QBuffer()32 qbuffer.open(QIODevice.ReadWrite)33 QPixmap.grabWindow(34 QApplication.desktop().winId()).save(qbuffer, file_type)35 buff.write(qbuffer.data())36 qbuffer.close()37# del app38 def grab(self, bbox=None):39 strio = BytesIO()40 self.grab_to_buffer(strio)41 strio.seek(0)42 im = Image.open(strio)43 if bbox:44 im = im.crop(bbox)45 return im46 def grab_to_file(self, filename, bbox=None):47 if bbox:48 log.info('bbox is not implemented!')49 file_type = 'png'50 if filename.endswith('.jpeg'):51 file_type = 'jpeg'52 buff = open(filename, 'wb')53 self.grab_to_buffer(buff, file_type)54 buff.close()55 def backend_version(self):...

Full Screen

Full Screen

qtgrabwindow.py

Source:qtgrabwindow.py Github

copy

Full Screen

...20 self.app = None21 self.QtGui = QtGui22 self.Qt = Qt23 24 def grab_to_buffer(self, buff, file_type='png'):25 QApplication = self.PyQt4.QtGui.QApplication26 QBuffer = self.PyQt4.Qt.QBuffer27 QIODevice = self.PyQt4.Qt.QIODevice28 QPixmap = self.PyQt4.QtGui.QPixmap29 if not self.app:30 self.app = QApplication([])31 qbuffer = QBuffer()32 qbuffer.open(QIODevice.ReadWrite)33 QPixmap.grabWindow(34 QApplication.desktop().winId()).save(qbuffer, file_type)35 buff.write(qbuffer.data())36 qbuffer.close()37# del app38 def grab(self, bbox=None):39 strio = BytesIO()40 self.grab_to_buffer(strio)41 strio.seek(0)42 im = Image.open(strio)43 if bbox:44 im = im.crop(bbox)45 return im46 def grab_to_file(self, filename):47 file_type = 'png'48 if filename.endswith('.jpeg'):49 file_type = 'jpeg'50 buff = open(filename, 'wb')51 self.grab_to_buffer(buff, file_type)52 buff.close()53 def backend_version(self):54 # TODO:...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Pyscreenshot automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful