本文整理匯總了Python中keyboard.Keyboard.flush方法的典型用法代碼示例。如果您正苦於以下問題:Python Keyboard.flush方法的具體用法?Python Keyboard.flush怎麽用?Python Keyboard.flush使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類keyboard.Keyboard
的用法示例。
在下文中一共展示了Keyboard.flush方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: dispense_and_scan
# 需要導入模塊: from keyboard import Keyboard [as 別名]
# 或者: from keyboard.Keyboard import flush [as 別名]
def dispense_and_scan(self, author_selection):
j = 0
#f = open(self.dispenserDevices[0], "wb")
f = open("/dev/ttyUSB0", "wb")
f.write("020180000380".decode("hex"))
f.flush()
f.close()
#k = Keyboard(self.scannerKeyDev[0])
k = Keyboard("/dev/input/event0")
k.flush()
code = ""
i = 0
#return code
start_time = time.time()
while i < 8:
key = k.readKey()
#print key
if key is not None:
code += key
i += 1
end_time = time.time() - start_time
#self.write_log("end time = "+str(end_time))
if(end_time > 4):
self.write_log("reader time out!!")
break;
self.write_log("Dispensing from card dispenser " + str(0))
self.write_log("device = "+str(self.dispenserDevices[0]))
self.write_log("scanner device = "+str(self.scannerKeyDev[0]))
return code