Ejemplo n.º 1
0
    def OnChooseInitGuess(self, evt=None):
        """
        set reference files
        """
        wildcard = '*.chromagnon*'

        if os.name == 'posix':
            dlg = G.FileSelectorDialog(self,
                                       direc=self.lastpath,
                                       wildcard=wildcard,
                                       multiple=False)
        else:
            dlg = wx.FileDialog(self,
                                'Choose chromagnon files',
                                defaultDir=self.lastpath,
                                wildcard=wildcard)

        if dlg.ShowModal() == wx.ID_OK:
            fn = dlg.GetPath()
            if chromformat.is_chromagnon(fn, True):
                self._setInitGuess(fn)
            else:
                G.openMsg(parent=self,
                          msg='The file is not a valid chromagnon file',
                          title="Warning")
Ejemplo n.º 2
0
    def OnChooseTargetFiles(self, evt):
        """
        set reference files
        """
        confdic = C.readConfig()
        wildcard = confdic.get('lastwildcard', FILTER)

        ll = self.listTgt

        if os.name == 'posix':
            dlg = G.FileSelectorDialog(self, self.lastpath, wildcard=wildcard)
        else:
            dlg = wx.FileDialog(self, 'Choose %s files' % listtype, defaultDir=self.lastpath, style=wx.FD_MULTIPLE)
            
        if dlg.ShowModal() == wx.ID_OK:
            fns = dlg.GetPaths()

            if not fns:
                return
            if os.name == 'posix':
                wildcard = dlg.fnPat
            if isinstance(fns, basestring):
                fns = [fns]

            ll.addFiles(fns)
            
            self.lastpath = os.path.dirname(fns[0])
            C.saveConfig(lastwildcard=wildcard, lastpath=self.lastpath)

            self.checkGo()
Ejemplo n.º 3
0
    def OnChooseReferenceFile(self, evt):
        """
        set reference files
        """
        confdic = C.readConfig()
        wildcard = confdic.get('lastwildcard', FILTER)

        ll = self.listRef
        if os.name == 'posix':
            dlg = G.FileSelectorDialog(self, direc=self.lastpath, wildcard=wildcard, multiple=False)
        else:
            dlg = wx.FileDialog(self, 'Choose %sfiles'  % listtype, defaultDir=self.lastpath, wildcard=wildcard)
            
        if dlg.ShowModal() == wx.ID_OK:
            fn = dlg.GetPath()

            if not fn:
                return
            if os.name == 'posix':
                wildcard = dlg.fnPat

            ll.clearAll()
            ll.addFiles([fn])
            
            self.lastpath = os.path.dirname(fn)
            C.saveConfig(lastwildcard=wildcard, lastpath=self.lastpath)

            self.checkGo()
Ejemplo n.º 4
0
    def OnChooseImgFiles(self, evt, listtype='ref'):
        """
        set reference files
        """
        confdic = C.readConfig()
        if listtype == 'ref':
            ll = self.listRef
            wildcard = confdic.get('lastwildcardref', FILTER)
        else:
            ll = self.listTgt
            wildcard = confdic.get('lastwildcardtgt', FILTER)

        if os.name == 'posix':
            dlg = G.FileSelectorDialog(self, self.lastpath, wildcard=wildcard)
        else:
            dlg = wx.FileDialog(self,
                                'Choose %s files' % listtype,
                                defaultDir=self.lastpath,
                                style=wx.FD_MULTIPLE)

        if dlg.ShowModal() == wx.ID_OK:
            fns = dlg.GetPaths()

            if not fns:
                return
            if os.name == 'posix':
                wildcard = dlg.fnPat
            if isinstance(fns, six.string_types):  #str):
                fns = [fns]

            ll.addFiles(fns)
            if listtype != 'ref':
                if any([nw > 5 for nw in ll.nws
                        ]) and self.outextch.GetStringSelection() == (
                            os.path.extsep + aligner.WRITABLE_FORMATS[1]):
                    self.outextch.SetStringSelection(
                        os.path.extsep + aligner.WRITABLE_FORMATS[0])
                    G.openMsg(
                        parent=self,
                        msg=
                        'Since number of wavelength in some image file is more than 5,\nthe output file format was changed to tiff',
                        title="Output file format change")

            self.lastpath = os.path.dirname(fns[0])
            if listtype == 'ref':
                C.saveConfig(lastwildcardref=wildcard, lastpath=self.lastpath)
            else:
                C.saveConfig(lastwildcardtgt=wildcard, lastpath=self.lastpath)

            self.checkGo()
Ejemplo n.º 5
0
    def onChooseFile(self, evnt):
        """
        get image file
        call self.view()
        """
        confdic = C.readConfig()
        lastpath = confdic.get('lastpath', '')
        #parent = self.GetTopLevelParent()
        if os.name == 'posix':
            dlg = G.FileSelectorDialog(self, lastpath)
        else:
            dlg = wx.FileDialog(self, 'Choose a file', defaultDir=lastpath)

        if dlg.ShowModal() == wx.ID_OK:
            fn = dlg.GetPath()
        else:
            return

        self.view(fn)

        C.saveConfig(lastpath=os.path.dirname(fn))
Ejemplo n.º 6
0
    def onChooseOriginalFile(self, ev):
        """
        get image file
        """
        confdic = C.readConfig()
        lastpath = confdic.get('lastpath', '')
        wildcard = confdic.get('localfnpat', '*')
        #parent = self.GetTopLevelParent()
        if os.name == 'posix':
            dlg = G.FileSelectorDialog(self, lastpath, wildcard)
        else:
            dlg = wx.FileDialog(self, 'Choose a file', defaultDir=lastpath)

        if dlg.ShowModal() == wx.ID_OK:
            fn = dlg.GetPath()
        else:
            return

        self.originalFileTxt.SetValue(fn)

        C.saveConfig(lastpath=os.path.dirname(fn), localfnpat=dlg.fnPat)