Here are the examples of the python api PyQt4.QtGui.QApplication.flush taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
2 Examples
0
Example 1
Project: orange Source File: splashscreen.py
def repaint(self):
QWidget.repaint(self)
QApplication.flush()
0
Example 2
Project: Camelot Source File: __init__.py
def grab_widget(self, widget, suffix=None, subdir=None):
"""Save a widget as a png file :
:param widget: the widget to take a screenshot of
:param suffix: string to add to the default filename of the image
:param subdir: subdirectory of images_path in which to put the image file, defaults to
the name of the test class
- the name of the png file is the name of the test case, without 'test_'
- it is stored in the directory with the same name as the class, without 'test'
"""
import sys
import os
from PyQt4 import QtGui
from PyQt4.QtGui import QPixmap
if not subdir:
images_path = os.path.join(self.images_path, self.__class__.__name__.lower()[:-len('Test')])
else:
images_path = os.path.join(self.images_path, subdir)
if not os.path.exists(images_path):
os.makedirs(images_path)
# try to move up in the stack until we find a test method
for i in range(1, 10):
if sys._getframe(i).f_code.co_name.startswith('test'):
break
test_case_name = sys._getframe(i).f_code.co_name[5:]
image_name = '%s.png'%test_case_name
if suffix:
image_name = '%s_%s.png'%(test_case_name, suffix)
widget.adjustSize()
widget.repaint()
self.process()
QtGui.QApplication.flush()
inner_pixmap = QPixmap.grabWidget(widget)
#
# we'll create a label that contains a screenshot of our widget and
# take a screenshot of that label, for the sole purpose of adding a border
#
parent_widget = QtGui.QLabel()
parent_widget.setPixmap(inner_pixmap)
parent_widget.setFrameStyle(QtGui.QFrame.Panel | QtGui.QFrame.Plain)
parent_widget.setObjectName('grab_widget_parent')
parent_widget.setLineWidth(2)
parent_widget.setStyleSheet("""
#grab_widget_parent {
border: 2px solid gray;
}""")
parent_widget.adjustSize()
outer_pixmap = QPixmap.grabWidget(parent_widget)
outer_pixmap.save(os.path.join(images_path, image_name), 'PNG')