def __init__(self): void_file = os.path.join(Resources.get_resource_dir(),'no_preview.png') self.image_void = Image.open(void_file)
def __init__(self, parent, title,clear_data=True): wx.Dialog.__init__(self, parent, -1, _('Scanning a new document'), wx.DefaultPosition, (372, 700), style=wx.CLOSE_BOX | wx.SYSTEM_MENU | wx.CAPTION | wx.RESIZE_BORDER | wx.MAXIMIZE_BOX | wx.MINIMIZE_BOX) self.panel = wx.Panel(self, -1) self.totalWin = wx.BoxSizer(wx.VERTICAL) self.upPart = wx.GridBagSizer(3,2) self.stSource = wx.StaticText(self.panel,-1,_("Source :")) #self.btSource = wx.Button(self.panel, -1, _('Select Scanner')) self.buttonPart = wx.BoxSizer(wx.HORIZONTAL) self.btScan = wx.BitmapButton(self.panel,-1, wx.Bitmap(Resources.get_icon_filename('PERFORM_SCAN'))) self.btScan.SetToolTipString(_('Scan')) self.buttonPart.Add(self.btScan ,0) self.btAddScan = wx.BitmapButton(self.panel, 666, wx.Bitmap(Resources.get_icon_filename('ADD_PERFORM_SCAN'))) self.btAddScan.SetToolTipString(_('Add scan')) self.buttonPart.Add(self.btAddScan ,0) self.btSave = wx.BitmapButton(self.panel, -1, wx.Bitmap(Resources.get_icon_filename('RECORD_SCANNED'))) self.btSave.SetToolTipString(_('Record')) self.buttonPart.Add(self.btSave ,0) self.btSource = wx.BitmapButton(self.panel, -1, wx.Bitmap(Resources.get_icon_filename('CHOOSE_SCANNER'))) self.btSource.SetToolTipString(_('Select Scanner')) self.buttonPart.Add(self.btSource ,0) self.btOptions = wx.BitmapButton(self.panel,-1,wx.Bitmap(Resources.get_icon_filename('SCANNER_PREFERENCES'))) self.btOptions.SetToolTipString(_('Options')) self.buttonPart.Add(self.btOptions ,0) #self.btScan = wx.Button(self.panel, -1, _('Scan')) #self.cbMultiplePage = wx.CheckBox(self.panel, -1, _('Manual MultiPage')) #self.btSave = wx.Button(self.panel, -1, _('Record')) #self.btOptions = wx.Button(self.panel,-1,_('Options')) self.docWin = docWindow.docWindow(self.panel,-1) self.recordPart = RecordWidget.RecordWidget(self.panel,file_style=wx.FLP_SAVE | wx.FLP_OVERWRITE_PROMPT | wx.FLP_USE_TEXTCTRL) self.recordPart.cbOCR.SetValue(str_to_bool(theConfig.get_param('OCR', 'autoStart','1'))) self.upPart.Add(wx.StaticText(self.panel,-1,_("Source :")),(0,0),flag=wx.ALL | wx.ALIGN_CENTRE_VERTICAL) self.upPart.Add(self.stSource,(0,1),flag=wx.ALL| wx.ALIGN_CENTRE_VERTICAL) #self.upPart.Add(self.btSource,0,wx.EXPAND | wx.CENTER) #self.upPart.Add(self.btScan,0,wx.EXPAND | wx.CENTER) #self.upPart.Add(self.btSave,0,wx.EXPAND | wx.CENTER) #self.upPart.Add(self.btOptions,0,wx.EXPAND | wx.CENTER) #self.upPart.Add(self.cbMultiplePage,0,wx.EXPAND | wx.CENTER) self.upPart.Add(self.buttonPart,(1,0),span=(1,2),flag=wx.ALIGN_TOP|wx.EXPAND) self.totalWin.Add(self.upPart,0,wx.ALIGN_TOP|wx.EXPAND) self.totalWin.Add(self.recordPart,0,wx.EXPAND) self.totalWin.Add(self.docWin,1,wx.ALIGN_BOTTOM|wx.EXPAND|wx.ALIGN_CENTER_HORIZONTAL) # BINDING EVENTS self.Bind(wx.EVT_BUTTON, self.actionChooseSource, self.btSource) self.Bind(wx.EVT_BUTTON, self.actionPerformScan, self.btScan) self.Bind(wx.EVT_BUTTON, self.actionPerformScan, self.btAddScan) self.Bind(wx.EVT_BUTTON, self.actionSaveRecord, self.btSave) self.Bind(wx.EVT_BUTTON, self.actionOpenOptions, self.btOptions) self.Bind(wx.EVT_CLOSE,self.onClose) # OTHER INITIALISATIIONS if os.name == 'posix' : self.scanner = saneAccess.SaneAccess(self.GetHandle(),self.onNewScannerData) else: self.scanner = twainAccess.TwainAccess(self.GetHandle(),self.onNewScannerData) self.panel.SetSizerAndFit(self.totalWin) self.SetSize(self.GetSize()) self.stSource.Label = self.scanner.chooseSource(database.theConfig.get_current_scanner()) self.SetSizeWH(550,800) self.currentOptions=dict() op_ini = database.theConfig.get_all_params_in('scanner_options') op_scan = self.scanner.get_options() for op in op_scan : if op.name in op_ini.keys() : self.currentOptions[op.name] = str(op_ini[op.name]) else: self.currentOptions[op.name] = op.value for name,val in op_ini.items() : if not name in self.currentOptions.keys() : self.currentOptions[name]=val #self.recordPart.lbFileName.SetPath(self.defaultNameDir()) #data.theData.clear_all() if str_to_bool(database.theConfig.get_param('scanner', 'autoScan','False',True)) : # event.Id = 0 if clear_data else 666 self.actionPerformScan(None)
def __init__(self, parent,doc_id): self.center = [0.5 , 0.5] self.window=[1.0,1.0] wx.Window.__init__(self, parent, doc_id) self.panel = wx.Panel(self, -1) self.img = None self.totalWin = wx.BoxSizer(wx.VERTICAL) self.buttonPart = wx.BoxSizer(wx.HORIZONTAL) self.btLeft = wx.BitmapButton(self.panel,-1,wx.Bitmap(Resources.get_icon_filename('PREVIOUS_PAGE'))) self.btLeft.SetToolTipString(_('Previous page')) self.btRight = wx.BitmapButton(self.panel,-1,wx.Bitmap(Resources.get_icon_filename('NEXT_PAGE'))) self.btRight.SetToolTipString(_('Next page')) self.btZoomPlus = wx.BitmapButton(self.panel,-1,wx.Bitmap(Resources.get_icon_filename('ZOOM_PLUS'))) self.btZoomPlus.SetToolTipString(_('Zoom')) self.btZoomMinus = wx.BitmapButton(self.panel,-1,wx.Bitmap(Resources.get_icon_filename('ZOOM_MINUS'))) self.btZoomMinus.SetToolTipString(_('Unzoom')) self.btRotate90 = wx.BitmapButton(self.panel,-1,wx.Bitmap(Resources.get_icon_filename('ROTATE_90'))) self.btRotate90.SetToolTipString(_('Rotate clockwise')) self.btRotate270 = wx.BitmapButton(self.panel,-1,wx.Bitmap(Resources.get_icon_filename('ROTATE_270'))) self.btRotate270.SetToolTipString(_('Rotate anti-clockwise')) self.btFlipX = wx.BitmapButton(self.panel,-1,wx.Bitmap(Resources.get_icon_filename('FLIP_X'))) self.btFlipX.SetToolTipString(_('Flip horizontally')) self.btFlipY = wx.BitmapButton(self.panel,-1,wx.Bitmap(Resources.get_icon_filename('FLIP_Y'))) self.btFlipY.SetToolTipString(_('Flip vertically')) self.btAllDocs = wx.lib.buttons.GenBitmapToggleButton(self.panel,-1,wx.Bitmap(Resources.get_icon_filename('ALL_DOCS'))) self.btAllDocs.SetToolTipString(_('Apply to all pages')) #self.btAllDocs.Show(False) self.lbImage = wx.StaticText(self.panel,-1,_('No page')) #self.canvas = self.MyCanvas(self.panel,-1) self.canvas = wx.StaticBitmap(self.panel, -1) #self.canvas.SetDoubleBuffered(False) self.totalWin.Add(self.buttonPart,0,wx.ALIGN_TOP|wx.EXPAND) self.totalWin.Add(self.canvas,1,wx.GROW|wx.EXPAND|wx.ALIGN_CENTER) self.buttonPart.Add(self.btLeft ,0) self.buttonPart.Add(self.btRight,0) self.buttonPart.Add(self.btZoomPlus ,0) self.buttonPart.Add(self.btZoomMinus,0) self.buttonPart.Add(self.btRotate270 ,0) self.buttonPart.Add(self.btRotate90,0) self.buttonPart.Add(self.btFlipX,0) self.buttonPart.Add(self.btFlipY,0) self.buttonPart.Add(self.btAllDocs,0) self.buttonPart.Add(self.lbImage,1,wx.ALIGN_CENTER_VERTICAL|wx.ALL) self.Bind(wx.EVT_BUTTON, self.actionPreviousImage, self.btLeft) self.Bind(wx.EVT_BUTTON, self.actionNextImage, self.btRight) self.Bind(wx.EVT_BUTTON, self.actionZoomPlus, self.btZoomPlus) self.Bind(wx.EVT_BUTTON, self.actionZoomMinus, self.btZoomMinus) self.Bind(wx.EVT_BUTTON, self.actionRotate90, self.btRotate90) self.Bind(wx.EVT_BUTTON, self.actionRotate270, self.btRotate270) self.Bind(wx.EVT_BUTTON, self.actionFlipX, self.btFlipX) self.Bind(wx.EVT_BUTTON, self.actionFlipY, self.btFlipY) self.Bind(wx.EVT_SIZE,self.onResize) self.Bind(wx.EVT_MOUSEWHEEL,self.onMouseWheelEvent) self.canvas.Bind(wx.EVT_MOTION,self.onMouseMotion) self.canvas.Bind(wx.EVT_LEFT_UP,self.onMouseLeftUp) self.canvas.SetSize(wx.Size(200,300)) self.panel.SetSizerAndFit(self.totalWin) self.showCurrentImage()