本文整理汇总了Python中Scanner.setDuplex方法的典型用法代码示例。如果您正苦于以下问题:Python Scanner.setDuplex方法的具体用法?Python Scanner.setDuplex怎么用?Python Scanner.setDuplex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Scanner
的用法示例。
在下文中一共展示了Scanner.setDuplex方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ScanDialog
# 需要导入模块: import Scanner [as 别名]
# 或者: from Scanner import setDuplex [as 别名]
class ScanDialog(QDialog):
def __init__(self, parent=None):
QDialog.__init__(self, parent)
dirs = [
os.path.abspath( os.path.dirname(__file__) ),
'/usr/lib/site-packages/NanScan',
os.path.join( 'share', 'NanScan' ),
]
for dir in dirs:
if os.path.exists( os.path.join(dir, 'ScanDialog.ui') ):
break
QResource.registerResource( os.path.join(dir,'common.rcc') )
loadUi( os.path.join(dir,'ScanDialog.ui'), self )
self.connect( self.pushAccept, SIGNAL('clicked()'), self.accept )
self.connect( self.pushScan, SIGNAL('clicked()'), self.scan )
self.connect( self.pushDuplexScan, SIGNAL('clicked()'), self.duplexScan )
self.uiList.setIconSize( QSize( 128, 128 ) )
self.saving = QSemaphore()
self.setScanning( False )
# By default images are stored as files in
# the temporary directory. The application
# may choose to override the 'thread' propery
# with an appropiate AbstractImageSaver() subclass
self._imageSaverFactory = FileImageSaverFactory()
def setImageSaverFactory(self, imageSaverFactory):
self._imageSaverFactory = imageSaverFactory
def imageSaverFactory(self):
return self._imageSaverFactory
def closeEvent(self, event):
if self.hasFinished:
event.accept()
else:
event.ignore()
def setScanning(self, value):
self.scanning = value
self.updateAccept()
def addSaving(self):
self.saving.release()
self.updateAccept()
def removeSaving(self):
self.saving.acquire()
self.updateAccept()
def updateAccept(self):
if self.scanning or self.saving.available():
self.hasFinished = False
self.pushAccept.setEnabled( False )
self.pushScan.setEnabled( False )
self.pushDuplexScan.setEnabled( False )
self.setCursor( Qt.BusyCursor )
else:
self.hasFinished = True
self.pushAccept.setEnabled( True )
self.pushScan.setEnabled( True )
self.pushDuplexScan.setEnabled( True )
self.unsetCursor()
def scan(self):
self.setScanning( True )
self.scan = Scanner(self)
self.scan.setDuplex( False )
self.connect( self.scan, SIGNAL('scanned(QImage)'), self.scanned )
self.connect( self.scan, SIGNAL('error(int)'), self.error )
self.connect( self.scan, SIGNAL('finished()'), self.finished )
self.scan.startScan()
def duplexScan(self):
self.setScanning( True )
self.scan = Scanner(self)
self.scan.setDuplex( True )
self.connect( self.scan, SIGNAL('scanned(QImage)'), self.scanned )
self.connect( self.scan, SIGNAL('error(int)'), self.error )
self.connect( self.scan, SIGNAL('finished()'), self.finished )
self.scan.startScan()
def error(self, code):
if code == ScannerError.NoDeviceFound:
message = 'No device found'
elif code == ScannerError.CouldNotOpenDevice:
message = 'Could not open device'
elif code == ScannerError.AcquisitionError:
message = 'Error acquiring image'
else:
message = 'Unknown error'
self.setScanning( False )
QMessageBox.critical( self, 'Scanning Error', message )
def scanned(self, image):
item = ImageItem( self.uiList )
item.setImage( image )
#.........这里部分代码省略.........