当前位置: 首页>>代码示例>>Python>>正文


Python Scanner.setDuplex方法代码示例

本文整理汇总了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 ) 
#.........这里部分代码省略.........
开发者ID:IMAGE-ET,项目名称:dicomimport,代码行数:103,代码来源:ScanDialog.py


注:本文中的Scanner.setDuplex方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。