本文整理汇总了Python中pyvirtualdisplay.smartdisplay.SmartDisplay.waitgrab方法的典型用法代码示例。如果您正苦于以下问题:Python SmartDisplay.waitgrab方法的具体用法?Python SmartDisplay.waitgrab怎么用?Python SmartDisplay.waitgrab使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyvirtualdisplay.smartdisplay.SmartDisplay
的用法示例。
在下文中一共展示了SmartDisplay.waitgrab方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_slowshot
# 需要导入模块: from pyvirtualdisplay.smartdisplay import SmartDisplay [as 别名]
# 或者: from pyvirtualdisplay.smartdisplay.SmartDisplay import waitgrab [as 别名]
def test_slowshot(self):
disp = SmartDisplay(visible=0).start()
py = path(__file__).parent / ('slowgui.py')
proc = EasyProcess('python ' + py).start()
img = disp.waitgrab()
proc.stop()
disp.stop()
eq_(img is not None, True)
示例2: test_slowshot_timeout
# 需要导入模块: from pyvirtualdisplay.smartdisplay import SmartDisplay [as 别名]
# 或者: from pyvirtualdisplay.smartdisplay.SmartDisplay import waitgrab [as 别名]
def test_slowshot_timeout(self):
disp = SmartDisplay(visible=0)
py = path(__file__).parent / ('slowgui.py')
proc = EasyProcess('python ' + py)
f = disp.wrap(proc.wrap(lambda: disp.waitgrab(timeout=1)))
self.assertRaises(DisplayTimeoutError, f)
示例3: SmartDisplay
# 需要导入模块: from pyvirtualdisplay.smartdisplay import SmartDisplay [as 别名]
# 或者: from pyvirtualdisplay.smartdisplay.SmartDisplay import waitgrab [as 别名]
from easyprocess import EasyProcess
from pyvirtualdisplay.smartdisplay import SmartDisplay
disp = SmartDisplay(visible=0, bgcolor='black').start()
xmessage = EasyProcess('xmessage hello').start()
img = disp.waitgrab()
xmessage.stop()
disp.stop()
img.show()
示例4: AppSession
# 需要导入模块: from pyvirtualdisplay.smartdisplay import SmartDisplay [as 别名]
# 或者: from pyvirtualdisplay.smartdisplay.SmartDisplay import waitgrab [as 别名]
class AppSession(ApplicationSession):
log = Logger()
events = ( uinput.KEY_E, uinput.KEY_H, uinput.KEY_L, uinput.KEY_V, uinput.KEY_END,uinput.KEY_HOME, uinput.KEY_UP, uinput.KEY_DOWN )
lastzValue = 0.0
@inlineCallbacks
def onJoin(self, details):
# SUBSCRIBE to a topic and receive events
#
self.zstoreFlag = 1
self.lastzValue = 0.0
self.zCounter = 0
self.ystoreFlag = 1
self.lastyValue = 0.0
def y_direction(IMUTable):
if self.ystoreFlag == 1:
self.lastyValue = abs( IMUTable['y'])
self.ystoreFlag = 0
return
curryValue = abs(IMUTable['y'])
ydiff = self.lastyValue - curryValue
gammaValue = IMUTable['gamma']
if abs(gammaValue) > 66:
print "Z Stable"
if ( curryValue > 1.5) and (abs(ydiff) > 0.4):
print "Right"
self.keyb.emit_click(uinput.KEY_V)
if ( curryValue < 1.5) and (abs(ydiff) > 0.4):
print "Left"
self.keyb.emit_click(uinput.KEY_END)
self.lastyValue = curryValue
print "The diff is ",ydiff, abs(ydiff)
def z_direction(IMUTable):
if self.zstoreFlag == 1:
self.lastzValue = IMUTable['z']
self.zstoreFlag = 0
return
currzValue = IMUTable['z']
zdiff = self.lastzValue - currzValue
gammaValue = IMUTable['gamma']
if abs(gammaValue) > 66:
print "Z Stable"
if ( currzValue > 1.5) and (abs(zdiff) > 0.4):
print "Forward"
self.keyb.emit_click(uinput.KEY_UP)
if ( currzValue < 1.5) and (abs(zdiff) > 0.4):
print "Backward"
self.keyb.emit_click(uinput.KEY_DOWN)
self.lastzValue = currzValue
print "The diff is ",zdiff, abs(zdiff)
def on_event(i):
print("Got event: {}".format(i))
IMUTab = json.loads(i);
print IMUTab['z']
z_direction(IMUTab)
y_direction(IMUTab)
#if self.storeFlag == 1:
# self.lastzValue = IMUTab['z']
# self.storeFlag = 0
# return
#currzValue = IMUTab['z']
#zdiff = self.lastzValue - currzValue
yield self.subscribe(on_event, 'com.myapp.topic1')
self.log.info("subscribed to topic 'onhello'")
# REGISTER a procedure for remote calling
#
def add2(x, y):
self.log.info("add2() called with {x} and {y}", x=x, y=y)
return x + y
yield self.register(add2, 'com.example.add2')
self.log.info("procedure add2() registered")
self.keyb = uinput.Device(self.events)
self.disp = SmartDisplay(visible=1, size=(800,600)).start()
# self.disp = SmartDisplay(visible=1, size=(640, 480) ).start()
# self.command = EasyProcess('celestia -s -f').start()
# self.command = EasyProcess('lightdm --test-mode').start()
self.p = Popen(['celestia'], stdout=PIPE, stdin=PIPE, stderr=PIPE)
# self.p = Popen(['xterm'], stdout=PIPE, stdin=PIPE, stderr=PIPE)
# PUBLISH and CALL every second .. forever
#
counter = 0
sleep(10)
while True:
# stdout_data = p.communicate(input="\x1B[C")[0]
# print stdout_data
self.buffer = cStringIO.StringIO()
#self.img = self.disp.wait()
self.img = self.disp.waitgrab(timeout=0.1, autocrop=False)
#.........这里部分代码省略.........