本文整理汇总了Python中pyvirtualdisplay.smartdisplay.SmartDisplay.pyscreenshot_childprocess方法的典型用法代码示例。如果您正苦于以下问题:Python SmartDisplay.pyscreenshot_childprocess方法的具体用法?Python SmartDisplay.pyscreenshot_childprocess怎么用?Python SmartDisplay.pyscreenshot_childprocess使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyvirtualdisplay.smartdisplay.SmartDisplay
的用法示例。
在下文中一共展示了SmartDisplay.pyscreenshot_childprocess方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: prog_shot
# 需要导入模块: from pyvirtualdisplay.smartdisplay import SmartDisplay [as 别名]
# 或者: from pyvirtualdisplay.smartdisplay.SmartDisplay import pyscreenshot_childprocess [as 别名]
def prog_shot(cmd, f, wait, timeout, screen_size, visible, bgcolor, cwd=None):
'''start process in headless X and create screenshot after 'wait' sec.
Repeats screenshot until it is not empty if 'repeat_if_empty'=True.
wait: wait at least N seconds after first window is displayed,
it can be used to skip splash screen
:param enable_crop: True -> crop screenshot
:param wait: int
'''
disp = SmartDisplay(visible=visible, size=screen_size, bgcolor=bgcolor)
disp.pyscreenshot_backend = None
disp.pyscreenshot_childprocess = True
proc = EasyProcess(cmd, cwd=cwd)
def func():
try:
img = disp.waitgrab(timeout=timeout)
except DisplayTimeoutError as e:
raise DisplayTimeoutError(str(e) + ' ' + str(proc))
if wait:
proc.sleep(wait)
img = disp.grab()
return img
img = disp.wrap(proc.wrap(func))()
if img:
img.save(f)
return (proc.stdout, proc.stderr)