コード例 #1
0
 def OnButton1Button(self, event):
     self.ShowMoreToCome(0)
     try:
         self.Control.Log("self.SS.XferImageNatively()")
         self.Control.statusBar1.SetStatusText("7 - Transferring Data", 2)
         (handle, more_to_come) = self.SS.XferImageNatively()
         self.Control.Log(">> (0x%lx, %d)"%(handle, more_to_come))
         if more_to_come:
             self.Control.statusBar1.SetStatusText("6 - Data Available", 2)
         else:
             self.Control.statusBar1.SetStatusText("5 - Acquisition Requested", 2)
         frm=frmViewBmp.create(self)
         frm.SetImageFile(handle, self.Control)
         self.Control.Log("twain.GlobalHandleFree(0x%lx)"%handle)        
         twain.GlobalHandleFree(handle)
         frm.Show(1)
         frm.Raise()
         if more_to_come:
             self.ShowMoreToCome(1)
         else:
             # Provide from variable, so parent can re-raise it
             self.frm = frm
             self.Close(1)
     except:
         self.Control.DisplayException("self.SS.XferImageNatively")
コード例 #2
0
ファイル: dlgTransfer.py プロジェクト: wupj1993/pytwain
 def OnButton1Button(self, event):
     self.ShowMoreToCome(0)
     try:
         self.Control.Log("self.SS.XferImageNatively()")
         self.Control.statusBar1.SetStatusText("7 - Transferring Data", 2)
         (handle, more_to_come) = self.SS.XferImageNatively()
         self.Control.Log(">> (0x%lx, %d)" % (handle, more_to_come))
         if more_to_come:
             self.Control.statusBar1.SetStatusText("6 - Data Available", 2)
         else:
             self.Control.statusBar1.SetStatusText(
                 "5 - Acquisition Requested", 2)
         frm = frmViewBmp.create(self)
         frm.SetImageFile(handle, self.Control)
         self.Control.Log("twain.GlobalHandleFree(0x%lx)" % handle)
         twain.GlobalHandleFree(handle)
         frm.Show(1)
         frm.Raise()
         if more_to_come:
             self.ShowMoreToCome(1)
         else:
             # Provide from variable, so parent can re-raise it
             self.frm = frm
             self.Close(1)
     except:
         self.Control.DisplayException("self.SS.XferImageNatively")
コード例 #3
0
ファイル: dlgTransfer.py プロジェクト: wupj1993/pytwain
    def OnButton2Button(self, event):
        self.ShowMoreToCome(0)
        GetXferFileNameWorks = False
        XferFileName = ''
        try:
            self.Control.Log("self.SS.GetXferFileName()")
            (name, imgType) = self.SS.GetXferFileName()
            XferFileName = name
            GetXferFileNameWorks = True
        except:
            self.Control.Log(
                "** This scanner does not support GetXferFileName - using default TWAIN.TMP"
            )
            self.Control.DisplayException("self.SS.GetXferFileName()")
            (name, imgType) = ("twain.tmp", twain.TWFF_BMP)
            XferFileName = 'twain.tmp'

        if GetXferFileNameWorks:
            dlg = dlgFileXFer.create(self)
            dlg.SetInfo(name, imgType)
            try:
                rv = dlg.ShowModal()
                if rv:
                    self.Control.Log("self.SS.SetXferFileName('%s', %d)" %
                                     (dlg.Name, dlg.imgType))
                    if dlg.Name:
                        self.SS.SetXferFileName(dlg.Name, dlg.imgType)
                        XferFileName = dlg.Name
            except:
                self.Control.DisplayException("self.SS.SetXferFileName")
            dlg.Destroy()

        try:
            self.Control.Log("self.SS.XferImageByFile()")
            self.Control.statusBar1.SetStatusText("7 - Transferring Data", 2)
            more_to_come = self.SS.XferImageByFile()
            self.Control.Log(">> %d" % more_to_come)

            # Display the image, assume Bitmap
            frm = frmViewBmp.create(self)
            frm.SetImageFromFile(XferFileName, self)
            frm.Show(1)
            frm.Raise()
            self.FileViewer = frm

            # Let the user know the operation was successful
            if more_to_come:
                self.Control.statusBar1.SetStatusText("6 - Data Available", 2)
            else:
                self.Control.statusBar1.SetStatusText("4 - Source Open", 2)
                self.Control.statusBar1.SetStatusText("Aquisition Complete", 0)

            if more_to_come:
                self.ShowMoreToCome(1)
            else:
                self.Close(1)

        except:
            self.Control.DisplayException("self.SS.XferImageByFile")
コード例 #4
0
ファイル: dlgTransfer.py プロジェクト: ahmed-gamal10/pytwain
    def OnButton2Button(self, event):
        self.ShowMoreToCome(0)
        GetXferFileNameWorks=False
        XferFileName=''
        try:
            self.Control.Log("self.SS.GetXferFileName()")
            (name, imgType) = self.SS.GetXferFileName()
            XferFileName=name
            GetXferFileNameWorks=True
        except:
            self.Control.Log("** This scanner does not support GetXferFileName - using default TWAIN.TMP")
            self.Control.DisplayException("self.SS.GetXferFileName()")
            (name, imgType) = ("twain.tmp", twain.TWFF_BMP)
            XferFileName='twain.tmp'

        if GetXferFileNameWorks:
            dlg = dlgFileXFer.create(self)
            dlg.SetInfo(name, imgType)
            try:
                rv = dlg.ShowModal()
                if rv:
                    self.Control.Log("self.SS.SetXferFileName('%s', %d)" % (dlg.Name, dlg.imgType))
                    if dlg.Name:
                        self.SS.SetXferFileName(dlg.Name, dlg.imgType)
                        XferFileName=dlg.Name
            except:
                self.Control.DisplayException("self.SS.SetXferFileName")
            dlg.Destroy()

        try:
            self.Control.Log("self.SS.XferImageByFile()")
            self.Control.statusBar1.SetStatusText("7 - Transferring Data", 2)
            more_to_come = self.SS.XferImageByFile()
            self.Control.Log(">> %d"%more_to_come)

            # Display the image, assume Bitmap
            frm=frmViewBmp.create(self)
            frm.SetImageFromFile(XferFileName, self)
            frm.Show(1)
            frm.Raise()
            self.FileViewer = frm
            
            # Let the user know the operation was successful
            if more_to_come:
                self.Control.statusBar1.SetStatusText("6 - Data Available", 2)
            else:
                self.Control.statusBar1.SetStatusText("4 - Source Open", 2)
                self.Control.statusBar1.SetStatusText("Aquisition Complete", 0)

            if more_to_come:
                self.ShowMoreToCome(1)
            else:
                self.Close(1)
            
        except:
            self.Control.DisplayException("self.SS.XferImageByFile")