def capture_as_image(self, rect=None):"""Return a PIL image of the control.
See PIL documentation to know what you can do with the resulting
image."""control_rectangle=self.rectangle()if not (control_rectangle.width() andcontrol_rectangle.height()):returnNone#PIL is optional so check first
if notImageGrab:print("PIL does not seem to be installed."
"PIL is required for capture_as_image")
self.actions.log("PIL does not seem to be installed."
"PIL is required for capture_as_image")returnNoneifrect:
control_rectangle=rect#get the control rectangle in a way that PIL likes it
width =control_rectangle.width()
height=control_rectangle.height()
left=control_rectangle.left
right=control_rectangle.right
top=control_rectangle.top
bottom=control_rectangle.bot