コード例 #1
0
    def set_file_chooser_path(self, path):
        file_names = []
        for file_name in os.listdir(path):
            ext = os.path.splitext(file_name)[1].lower()
            if (len(ext) > 0 and ext[1:]
                    in cellprofiler.preferences.EXT_PIPELINE_CHOICES):
                file_names.append(file_name)
        self.file_chooser.DeleteAllItems()
        module_count = [None]

        def on_pipeline_event(caller, event):
            if isinstance(event, cellprofiler.pipeline.LoadExceptionEvent):
                module_count[0] = None
            elif isinstance(event, cellprofiler.pipeline.PipelineLoadedEvent):
                module_count[0] = len(caller.modules())

        pipeline = cellprofiler.gui.pipeline.Pipeline()
        pipeline.add_listener(on_pipeline_event)
        for file_name in file_names:
            file_path = os.path.join(path, file_name)
            mtime = os.path.getmtime(file_path)
            mtime = datetime.datetime.fromtimestamp(mtime)
            mtime = mtime.ctime()
            pipeline.load(file_path)
            if module_count[0] is not None:
                index = self.file_chooser.InsertStringItem(
                    sys.maxsize, file_name)
                self.file_chooser.SetStringItem(index, FC_DATE_COLUMN, mtime)
                self.file_chooser.SetStringItem(index, FC_MODULE_COUNT_COLUMN,
                                                str(module_count[0]))
        self.file_chooser.SetColumnWidth(FC_FILENAME_COLUMN, wx.LIST_AUTOSIZE)
        self.file_chooser.SetColumnWidth(FC_DATE_COLUMN, wx.LIST_AUTOSIZE)
コード例 #2
0
    def set_file_chooser_path(self, path):
        file_names = []
        for file_name in os.listdir(path):
            ext = os.path.splitext(file_name)[1].lower()
            if len(ext) > 0 and ext[1:] in cellprofiler.preferences.EXT_PIPELINE_CHOICES:
                file_names.append(file_name)
        self.file_chooser.DeleteAllItems()
        module_count = [None]

        def on_pipeline_event(caller, event):
            if isinstance(event, cellprofiler.pipeline.LoadExceptionEvent):
                module_count[0] = None
            elif isinstance(event, cellprofiler.pipeline.PipelineLoadedEvent):
                module_count[0] = len(caller.modules())

        pipeline = cellprofiler.gui.pipeline.Pipeline()
        pipeline.add_listener(on_pipeline_event)
        for file_name in file_names:
            file_path = os.path.join(path, file_name)
            mtime = os.path.getmtime(file_path)
            mtime = datetime.datetime.fromtimestamp(mtime)
            mtime = mtime.ctime()
            pipeline.load(file_path)
            if module_count[0] is not None:
                index = self.file_chooser.InsertStringItem(
                        sys.maxsize, file_name)
                self.file_chooser.SetStringItem(index, FC_DATE_COLUMN, mtime)
                self.file_chooser.SetStringItem(index, FC_MODULE_COUNT_COLUMN,
                                                str(module_count[0]))
        self.file_chooser.SetColumnWidth(FC_FILENAME_COLUMN, wx.LIST_AUTOSIZE)
        self.file_chooser.SetColumnWidth(FC_DATE_COLUMN, wx.LIST_AUTOSIZE)