Python PyQt5.QtCore.QDir() Examples

The following are 16 code examples for showing how to use PyQt5.QtCore.QDir(). These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example.

You may check out the related API usage on the sidebar.

You may also want to check out all available functions/classes of the module PyQt5.QtCore , or try the search function .

Example 1
Project: Pythonic   Author: hANSIc99   File: connectivitytools.py    License: GNU General Public License v3.0 6 votes vote down vote up
def initUI(self):

        self.setStyleSheet('background-color: silver')
        mod_path = os.path.dirname(Pythonic.__file__)
        """
        image_folder = QDir('images')

        if not image_folder.exists():
            logging.error('Image foulder not found')
            sys.exit(1)
        """
            
        self.layout_h = QHBoxLayout()

        self.e_mail = MasterTool(self, 'ConnMail', 1)
        self.e_mail.setPixmap(QPixmap(join(mod_path, 'images/ConnMail.png')).scaled(120, 60))

        self.rest = MasterTool(self, 'ConnREST', 1)
        self.rest.setPixmap(QPixmap(join(mod_path, 'images/ConnREST.png')).scaled(120, 60))

        self.layout_h.addWidget(self.e_mail)
        self.layout_h.addWidget(self.rest)
        self.layout_h.addStretch(1)

        self.setLayout(self.layout_h) 
Example 2
Project: uPyLoader   Author: BetaRavener   File: settings.py    License: MIT License 5 votes vote down vote up
def __init__(self):
        self.version = 100  # Assume oldest config
        self.root_dir = QDir().currentPath()
        self.send_sleep = 0.1
        self.read_sleep = 0.1
        self.use_transfer_scripts = True
        self.use_custom_transfer_scripts = False
        self.external_transfer_scripts_folder = None
        self.wifi_presets = []
        self.python_flash_executable = None
        self.last_firmware_directory = None
        self.debug_mode = False
        self._geometries = {}
        self.external_editor_path = None
        self.external_editor_args = None
        self.new_line_key = QKeySequence(Qt.SHIFT + Qt.Key_Return, Qt.SHIFT + Qt.Key_Enter)
        self.send_key = QKeySequence(Qt.Key_Return, Qt.Key_Enter)
        self.terminal_tab_spaces = 4
        self.mpy_cross_path = None
        self.preferred_port = None
        self.auto_transfer = False

        if not self.load():
            if not self.load_old():
                # No config found, init at newest version
                self.version = Settings.newest_version
                return

        self._update_config() 
Example 3
Project: uPyLoader   Author: BetaRavener   File: settings_dialog.py    License: MIT License 5 votes vote down vote up
def browse_external_editor(self):
        path = QFileDialog().getOpenFileName(
            caption="Select external editor",
            directory=QDir().homePath(),
            options=QFileDialog.ReadOnly)

        if path[0]:
            self.externalPathLineEdit.setText(path[0]) 
Example 4
Project: uPyLoader   Author: BetaRavener   File: settings_dialog.py    License: MIT License 5 votes vote down vote up
def browse_mpy_cross(self):
        path = QFileDialog().getOpenFileName(
            caption="Select mpy-cross compiler",
            directory=QDir().homePath(),
            options=QFileDialog.ReadOnly)

        if path[0]:
            self.mpyCrossPathLineEdit.setText(path[0]) 
Example 5
Project: uPyLoader   Author: BetaRavener   File: settings_dialog.py    License: MIT License 5 votes vote down vote up
def browse_external_transfer_files(self):
        path = QFileDialog().getExistingDirectory(
            caption="Select transfer files folder",
            directory=QDir().homePath(),
            options=QFileDialog.ShowDirsOnly | QFileDialog.DontResolveSymlinks)

        if path:
            self.transferFilesPathLineEdit.setText(path) 
Example 6
Project: Mastering-GUI-Programming-with-Python   Author: PacktPublishing   File: file_searcher.py    License: MIT License 5 votes vote down vote up
def do_search(self):
        #print(f'Beginning search for: {self.term}')
        root = qtc.QDir.rootPath()
        self._search(self.term, root)
        self.finished.emit() 
Example 7
Project: Mastering-GUI-Programming-with-Python   Author: PacktPublishing   File: file_searcher.py    License: MIT License 5 votes vote down vote up
def _search(self, term, path):
        self.directory_changed.emit(path)
        directory = qtc.QDir(path)
        directory.setFilter(
            directory.filter() |
            qtc.QDir.NoDotAndDotDot |
            qtc.QDir.NoSymLinks
        )
        for entry in directory.entryInfoList():
            if term in entry.filePath():
                print(entry.filePath())
                self.match_found.emit(entry.filePath())
            if entry.isDir():
                self._search(term, entry.filePath()) 
Example 8
Project: Mastering-GUI-Programming-with-Python   Author: PacktPublishing   File: hasher.py    License: MIT License 5 votes vote down vote up
def do_hashing(self, source, destination, threads):
        self.pool.setMaxThreadCount(threads)
        qdir = qtc.QDir(source)
        for filename in qdir.entryList(qtc.QDir.Files):
            filepath = qdir.absoluteFilePath(filename)
            runner = HashRunner(filepath, destination)
            self.pool.start(runner)

        # This call is why we put HashManager in its own thread.
        # If we don't care about being notified when the process is done,
        # we could leave this out and run HashManager in the main thread.
        self.pool.waitForDone()
        self.finished.emit() 
Example 9
Project: Mastering-GUI-Programming-with-Python   Author: PacktPublishing   File: file_searcher_subclassed.py    License: MIT License 5 votes vote down vote up
def run(self):
        #print(f'Beginning search for: {self.term}')
        root = qtc.QDir.rootPath()
        self._search(self.term, root)
        self.finished.emit() 
Example 10
Project: Mastering-GUI-Programming-with-Python   Author: PacktPublishing   File: file_searcher_subclassed.py    License: MIT License 5 votes vote down vote up
def _search(self, term, path):
        self.directory_changed.emit(path)
        directory = qtc.QDir(path)
        directory.setFilter(
            directory.filter() |
            qtc.QDir.NoDotAndDotDot |
            qtc.QDir.NoSymLinks
        )
        for entry in directory.entryInfoList():
            if term in entry.filePath():
                print(entry.filePath())
                self.match_found.emit(entry.filePath())
            if entry.isDir():
                self._search(term, entry.filePath()) 
Example 11
Project: Pythonic   Author: hANSIc99   File: basictools.py    License: GNU General Public License v3.0 5 votes vote down vote up
def initUI(self):

        self.setStyleSheet('background-color: silver')
        mod_path = os.path.dirname(Pythonic.__file__)
        image_folder = QDir('images')

        self.layout_h = QHBoxLayout()

        self.op_tool = MasterTool(self, 'ExecOp', 1)
        self.op_tool.setPixmap(QPixmap(join(mod_path, 'images/ExecOp.png')).scaled(120, 60))

        self.branch_tool = MasterTool(self, 'ExecBranch', 2)
        self.branch_tool.setPixmap(QPixmap(join(mod_path, 'images/ExecBranch.png')).scaled(120, 60))

        self.return_tool = MasterTool(self, 'ExecReturn', 0)
        self.return_tool.setPixmap(QPixmap(join(mod_path, 'images/ExecReturn.png')).scaled(120, 60))

        self.proc_tool = MasterTool(self, 'ExecProcess', 2)
        self.proc_tool.setPixmap(QPixmap(join(mod_path, 'images/ExecProcess.png')).scaled(120, 60))

        self.ta_tool = MasterTool(self, 'ExecTA', 1)
        self.ta_tool.setPixmap(QPixmap(join(mod_path, 'images/ExecTA.png')).scaled(120, 60))

        self.sched_tool = MasterTool(self, 'ExecSched', 1)
        self.sched_tool.setPixmap(QPixmap(join(mod_path, 'images/ExecSched.png')).scaled(120, 60))

        self.stack_tool = MasterTool(self, 'ExecStack', 1)
        self.stack_tool.setPixmap(QPixmap(join(mod_path, 'images/ExecStack.png')).scaled(120, 60))

        self.layout_h.addWidget(self.op_tool)
        self.layout_h.addWidget(self.branch_tool)
        self.layout_h.addWidget(self.return_tool)
        self.layout_h.addWidget(self.proc_tool)
        self.layout_h.addWidget(self.ta_tool)
        self.layout_h.addWidget(self.sched_tool)
        self.layout_h.addWidget(self.stack_tool)
        self.layout_h.addStretch(1)

        self.setLayout(self.layout_h) 
Example 12
Project: Pythonic   Author: hANSIc99   File: mltools.py    License: GNU General Public License v3.0 5 votes vote down vote up
def initUI(self):

        self.setStyleSheet('background-color: silver')
        mod_path = os.path.dirname(Pythonic.__file__)
        """
        image_folder = QDir('images')

        if not image_folder.exists():
            logging.error('Image foulder not found')
            sys.exit(1)
        """
            
        self.layout_h = QHBoxLayout()

        self.svm = MasterTool(self, 'MLSVM', 1)
        self.svm.setPixmap(QPixmap(os.path.join(mod_path, 'images/MLSVM.png')).scaled(120, 60))

        self.svm_predict = MasterTool(self, 'MLSVM_Predict', 1)
        self.svm_predict.setPixmap(QPixmap(os.path.join(mod_path, 'images/MLSVM_Predict.png')).scaled(120, 60))


        self.layout_h.addWidget(self.svm)
        self.layout_h.addWidget(self.svm_predict)
        self.layout_h.addStretch(1)

        self.setLayout(self.layout_h) 
Example 13
Project: tinydecred   Author: decred   File: screens.py    License: ISC License 5 votes vote down vote up
def loadClicked(self):
        """
        The user has selected the "load from file" option. Prompt for a file
        location and load the wallet.
        """
        fd = QtWidgets.QFileDialog(self, "select wallet file")
        fd.setViewMode(QtWidgets.QFileDialog.Detail)
        qdir = QtCore.QDir
        fd.setFilter(qdir.Dirs | qdir.Files | qdir.NoDotAndDotDot | qdir.Hidden)
        noFileMsg = "no file selected"
        if fd.exec_():
            fileNames = fd.selectedFiles()
            if len(fileNames) != 1:
                msg = "more than one file selected for importing"
                logError(msg)
                return
        else:
            log.info(noFileMsg)
            return
        walletPath = fileNames[0]
        log.debug(f"loading wallet from {walletPath}")
        if walletPath == "":
            logError(noFileMsg)
            return
        elif not os.path.isfile(walletPath):
            msg = f"no file found at {walletPath}"
            logError(msg)
            return
        elif not database.isSqlite3DB(walletPath):
            logError(f"{walletPath} is not a sqlite3 database")
            return

        destination = app.walletFilename()
        shutil.copy(walletPath, destination)
        app.initialize() 
Example 14
Project: CodeAtlasSublime   Author: league1991   File: mainwindow.py    License: Eclipse Public License 1.0 5 votes vote down vote up
def onOpen(self):
		dialog = QtWidgets.QFileDialog()
		curDir = QtCore.QDir()
		curPath = curDir.currentPath()
		dbPath = dialog.getOpenFileName(self, 'Open Database', curDir.currentPath())
		if dbPath:
			dbmgr = DBManager.DBManager.instance()
			dbmgr.openDB(dbPath[0])

			from UIManager import UIManager
			symScene = UIManager.instance().getSymbolScene() 
Example 15
Project: CodeAtlasSublime   Author: league1991   File: mainwindow.py    License: Eclipse Public License 1.0 5 votes vote down vote up
def onOpenPath(self, param):
		dialog = QtWidgets.QFileDialog()
		curDir = QtCore.QDir()
		curPath = curDir.currentPath()
		if param and False:
			curPath = param[0]
		dbPath = dialog.getOpenFileName(self, 'Open Database', curPath)
		if dbPath:
			dbmgr = DBManager.DBManager.instance()
			dbmgr.getDB().open(dbPath)
			from UIManager import UIManager
			symScene = UIManager.instance().getSymbolScene() 
Example 16
Project: equant   Author: epolestar   File: utils.py    License: GNU General Public License v2.0 4 votes vote down vote up
def dropEvent(self, event):
        event.ignore()
        return
        if event.source():
            QTreeView.dropEvent(self, event)
        else:
            ix = self.indexAt(event.pos())
            if not self.model().isDir(ix):
                ix = ix.parent()
            pathDir = self.model().filePath(ix)
            if not pathDir:
                pathDir = self.model().filePath(self.rootIndex())
            m = event.mimeData()
            if m.hasUrls():
                urlLocals = [url for url in m.urls() if url.isLocalFile()]
                accepted = False
                for urlLocal in urlLocals:
                    path = urlLocal.toLocalFile()
                    info = QFileInfo(path)
                    n_path = QDir(pathDir).filePath(info.fileName())
                    o_path = info.absoluteFilePath()
                    if n_path == o_path:
                        continue
                    if info.isDir():
                        if QDir(n_path).exists():
                            reply = QMessageBox.question(self, '提示', '所选的分组中存在同名文件夹,是否全部覆盖?',
                                                         QMessageBox.Yes | QMessageBox.No)
                            if reply == QMessageBox.Yes:
                                shutil.rmtree(n_path)
                                shutil.copytree(o_path, n_path)
                        else:
                            print(o_path)
                            for file in os.walk(o_path):
                                print(file)
                            shutil.copytree(o_path, n_path)
                            self.strategy_filters.append(os.path.split(n_path)[1])
                            self._model.setNameFilters(self.strategy_filters)
                    else:
                        qfile = QFile(o_path)
                        fname = qfile.fileName()
                        if not fname.endswith('.py'):
                            QMessageBox.warning(self, "提示", "暂不支持该类型文件", QMessageBox.Yes)
                        if QFile(n_path).exists():
                            reply = QMessageBox.question(self, '提示', '所选的分组中存在同名文件,是否覆盖?',
                                                         QMessageBox.Yes | QMessageBox.No)
                            if reply == QMessageBox.Yes:
                                shutil.copy(o_path, n_path)
                        # qfile.rename(n_path)
                    accepted = True
                if accepted:
                    event.acceptProposedAction()