Ejemplo n.º 1
0
    def updateWorkDir(self):
        for i in reversed(range(self.gridLayout.count())):
            self.gridLayout.itemAt(i).widget().setParent(None)
        self.selectedImage = ""
        self.selectedImageDir = ""

        #self.selectDirButton.setText(unicode(QtCore.QDir(self.workDir).dirName()))
        folderIterator = QtCore.QDirIterator(
            self.workDir, QtCore.QDir.Dirs | QtCore.QDir.NoDotAndDotDot)
        self.checkAllBox = QtGui.QCheckBox('Check/Uncheck All', self)
        self.checkAllBox.setChecked(True)
        self.checkAllBox.stateChanged.connect(lambda: (self.checkAll(
        ) if self.checkAllBox.isChecked() else self.unCheckAll()))
        self.gridLayout.addWidget(self.checkAllBox)
        self.folderWidgets = []
        i = 0
        while folderIterator.hasNext():

            tempDir = QtCore.QDir(folderIterator.next())

            self.folderWidgets.append(imageFolderWidget(tempDir))
            self.gridLayout.addWidget(self.folderWidgets[-1])
            self.folderWidgets[-1].signal_hideall.connect(
                self.hideAllImageLabels)
            self.folderWidgets[-1].signal_show_image.connect(
                lambda key=i: self.updateImage(key))
            self.folderWidgets[-1].signal_show_images.connect(
                lambda key=i: self.updateImages(key))
            i += 1
        try:
            self.updateImages(0)
        except IndexError:
            self.signal_update_images.emit()
Ejemplo n.º 2
0
    def loadNotes(self):

        tree = self.tree
        tree.clear()

        notes_walker = QtCore.QDirIterator(
            self.notes_base, QtCore.QDirIterator.FollowSymlinks
            | QtCore.QDirIterator.Subdirectories)
        dir_dict = {}
        while (notes_walker.hasNext()):
            nwi = notes_walker.next()
            ffn = notes_walker.fileName()
            fi = notes_walker.fileInfo()
            fpath = fi.path()
            if ffn in ['.', '..']:
                continue

            print fpath, ffn
            if fpath in dir_dict.keys():
                parent = dir_dict[fpath]
                print fpath, "", parent.text(0)
            else:
                parent = tree

            item = QtGui.QTreeWidgetItem(parent)
            item.setFlags(item.flags() | QtCore.Qt.ItemIsEditable
                          | QtCore.Qt.ItemIsDragEnabled)
            item.setText(0, ffn)
            item.file_info = fi

            if fi.isDir():
                dir_dict[fi.filePath()] = item
Ejemplo n.º 3
0
    def loadColorMapRepository(self, _s_dir):

        o_dirWalk = QtCore.QDirIterator(_s_dir,
                                        QtCore.QDirIterator.Subdirectories)

        while o_dirWalk.hasNext():
            o_dirWalk.next()

            if o_dirWalk.fileInfo().completeSuffix() == 'cmap':
                self.loadColorMapFile(o_dirWalk.filePath())
Ejemplo n.º 4
0
    def __init_ui(self, path=None):
        """
        Initialization of the gui, fills elements with data
        :return:
        """
        self.debug("Initialization of UI")

        # path for the profiles
        path = config.PROFILES[PROFILE_DIR]
        self.debug("Profile path ({})".format(path))

        # make an icon
        image_path = self._provideImagePath()
        if image_path is not None:
            pixmap = QtGui.QPixmap(image_path.absoluteFilePath())
            self.setWindowIcon(QtGui.QIcon(pixmap))

        self._ui = Ui_ProfileDialog()
        self._ui.setupUi(self)

        dir = QtCore.QDir(path)

        # get iterator on files
        dirit = QtCore.QDirIterator(dir, QtCore.QDirIterator.NoIteratorFlags)

        # get string list to process profiles
        sl = QtCore.QStringList()

        # parse directory structure, find passing files profile*.py
        # get information from these files
        while dirit.hasNext():
            next = dirit.next()
            finfo = QtCore.QFileInfo(next)
            if finfo.isFile() and re.match(".*profile[^\\\/]*.py$",
                                           str(finfo.filePath()).lower()):
                mod = self._loadModule(finfo)
                if self.test(mod):
                    self.info("Found a profile ({})".format(
                        finfo.absoluteFilePath()))
                    try:
                        sl.append(mod.START[PROFILE_NAME])
                    except KeyError:
                        sl.append(finfo.baseName())
                    self._profiles.append(finfo)

        if type(sl) is QtCore.QStringList:
            if len(sl):
                self._ui.lbPath.setText(dir.absolutePath())
                self._ui.lbPath.setToolTip("Path: {}".format(
                    dir.absolutePath()))
                self._ui.lwFiles.insertItems(0, sl)
                self._ui.lwFiles.setCurrentRow(0)
Ejemplo n.º 5
0
    def __init__(self, inDir):
        super(imageFolderWidget, self).__init__()
        self.isHidden = True

        self.dir = inDir
        self.selectedPic = ""
        self.Layout = QtGui.QGridLayout(self)
        self.Layout.setSpacing(0)
        self.Layout.setContentsMargins(0, 0, 0, 0)
        self.Layout.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignTop)
        self.checked = QtGui.QCheckBox(self)
        self.checked.setTristate(False)
        self.checked.setChecked(True)
        self.r_button = QtGui.QPushButton(self.dir.dirName())
        self.r_button.setIcon(self.style().standardIcon(
            QtGui.QStyle.SP_DirIcon))
        self.r_button.setSizePolicy(QtGui.QSizePolicy.Expanding,
                                    QtGui.QSizePolicy.Minimum)
        self.r_button.setStyleSheet("text-align: left;padding: 3px")
        self.Layout.addWidget(self.checked, 0, 0)
        self.Layout.addWidget(self.r_button, 0, 1)

        self.connect(self.r_button, QtCore.SIGNAL("clicked()"),
                     self.showAllImageLabels)
        filters = ["*.TIF", "*.tif", "*.jpg", "*.JPG"]
        self.dir.setNameFilters(filters)
        pictureIterator = QtCore.QDirIterator(self.dir)
        i = 1
        self.dirs = []
        self.labels = []
        while pictureIterator.hasNext():
            i += 1
            tempDir = QtCore.QDir(pictureIterator.next())

            self.dirs.append(tempDir)

            self.labels.append(ExtendedQLabel(unicode(
                self.dirs[-1].dirName())))
            self.connect(self.labels[-1],
                         QtCore.SIGNAL("clicked()"),
                         lambda key=i - 2: self.highliteItem(key))
            self.Layout.addWidget(self.labels[-1], i, 1)
            self.labels[-1].setAutoFillBackground(True)
            self.labels[-1].setStyleSheet(
                "background-color: none; qproperty-alignment: AlignCenter;")
            self.labels[-1].setFixedHeight(20)
            self.labels[-1].hide()
Ejemplo n.º 6
0
 def run(self):
     it = QtCore.QDirIterator(self.directory,
                              QtCore.QDirIterator.Subdirectories)
     while it.hasNext() and not self.abort:
         if it.next().endsWith('.fb2') and it.fileInfo().isFile():
             self.found.emit(it.filePath())
Ejemplo n.º 7
0
    def openWorkDir(self, workdir=None):
        if not (workdir):
            workdir = QtGui.QFileDialog.getExistingDirectory(
                directory=self.workDir)
            if workdir != "":
                self.parent.workDir = unicode(workdir)
        if workdir != "":
            self.workDir = unicode(workdir)
            for i in reversed(range(self.folderLayout.count())):
                self.folderLayout.itemAt(i).widget().setParent(None)
            self.selectedImage = ""
            self.selectedImageDir = ""
            self.checkedPaths = []
            self.nameList = []

            folderIterator = QtCore.QDirIterator(
                self.workDir, QtCore.QDir.Dirs | QtCore.QDir.NoDotAndDotDot)

            while folderIterator.hasNext():
                imageQDir = QtCore.QDir(folderIterator.next())
                imageList = imageQDir.entryList(
                    ["*.TIF", "*.tif", "*.jpg", "*.JPG", "*.BMP", "*.bmp"])
                for name in imageList:
                    if not (name in self.nameList):
                        self.nameList.append(unicode(name))

            [
                self.parent.nuclNameComboBox.removeItem(0)
                for i in xrange(self.parent.nuclNameComboBox.count())
            ]
            self.parent.nuclNameComboBox.addItems(self.nameList)
            if self.parent.settings.nuclei_name in self.nameList:
                #print self.parent.nuclNameComboBox.itemText(1)
                self.parent.nuclNameComboBox.setCurrentIndex(
                    self.parent.nuclNameComboBox.findText(
                        self.parent.settings.nuclei_name))
            else:
                self.parent.nuclNameComboBox.setCurrentIndex(0)
                self.parent.settings.nuclei_name = self.nameList[0]

            [
                self.parent.fociNameComboBox.removeItem(1)
                for i in xrange(1, self.parent.fociNameComboBox.count())
            ]
            self.parent.fociNameComboBox.addItems(self.nameList)

            if self.parent.settings.foci_name in self.nameList:
                self.parent.fociNameComboBox.setCurrentIndex(
                    self.parent.fociNameComboBox.findText(
                        self.parent.settings.foci_name))
            else:
                self.parent.fociNameComboBox.setCurrentIndex(0)
                self.parent.settings.foci_name = '--None--'

            self.checkAllBox = QtGui.QCheckBox('Check/Uncheck All', self)
            self.checkAllBox.setChecked(True)
            self.checkAllBox.stateChanged.connect(lambda: (self.checkAll(
            ) if self.checkAllBox.isChecked() else self.unCheckAll()))
            self.folderLayout.addWidget(self.checkAllBox)

            self.folderWidgets = []
            self.imageDirs = []

            self.cell_set = pic_an.cell_set(name=self.workDir, cells=[])
            i = 0

            folderIterator = QtCore.QDirIterator(
                self.workDir, QtCore.QDir.Dirs | QtCore.QDir.NoDotAndDotDot)
            while folderIterator.hasNext():

                imageQDir = QtCore.QDir(folderIterator.next())
                nucleiPath = imageQDir.absolutePath() + QtCore.QDir.separator(
                ) + self.parent.settings.nuclei_name
                fociPath = imageQDir.absolutePath() + QtCore.QDir.separator(
                ) + self.parent.settings.foci_name
                if ((self.parent.settings.foci_name == '--None--') &
                    (QtCore.QFile(nucleiPath).exists())):
                    self.imageDirs.append(
                        pic_an.image_dir(
                            unicode(imageQDir.absolutePath()),
                            unicode(self.parent.settings.nuclei_name)))

                    self.folderWidgets.append(imageFolderWidget(imageQDir))
                    self.folderLayout.addWidget(self.folderWidgets[-1])
                    self.folderWidgets[-1].signal_hideall.connect(
                        self.hideAllImageLabels)
                    ############
                    self.folderWidgets[-1].signal_show_image.connect(
                        lambda key=i: self.updateImage(key))
                    self.folderWidgets[-1].signal_show_all_images.connect(
                        lambda key=i: self.updateImages(key))
                    ############
                    i += 1

                elif ((QtCore.QFile(fociPath).exists()) &
                      (QtCore.QFile(nucleiPath).exists())):

                    self.imageDirs.append(
                        pic_an.image_dir(
                            unicode(imageQDir.absolutePath()),
                            unicode(self.parent.settings.nuclei_name),
                            unicode(self.parent.settings.foci_name)))

                    self.folderWidgets.append(imageFolderWidget(imageQDir))
                    self.folderLayout.addWidget(self.folderWidgets[-1])
                    self.folderWidgets[-1].signal_hideall.connect(
                        self.hideAllImageLabels)
                    ############
                    self.folderWidgets[-1].signal_show_image.connect(
                        lambda key=i: self.updateImage(key))
                    self.folderWidgets[-1].signal_show_all_images.connect(
                        lambda key=i: self.updateImages(key))
                    ############
                    i += 1

            print str(len(self.imageDirs)) + ' dirs found in working directory'
            try:
                self.updateImages(0)
            except IndexError:
                self.signal_update_images.emit()