當前位置: 首頁>>代碼示例>>Python>>正文


Python QtCore.QDir方法代碼示例

本文整理匯總了Python中PyQt5.QtCore.QDir方法的典型用法代碼示例。如果您正苦於以下問題:Python QtCore.QDir方法的具體用法?Python QtCore.QDir怎麽用?Python QtCore.QDir使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在PyQt5.QtCore的用法示例。


在下文中一共展示了QtCore.QDir方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: initUI

# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QDir [as 別名]
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) 
開發者ID:hANSIc99,項目名稱:Pythonic,代碼行數:27,代碼來源:connectivitytools.py

示例2: __init__

# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QDir [as 別名]
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() 
開發者ID:BetaRavener,項目名稱:uPyLoader,代碼行數:31,代碼來源:settings.py

示例3: browse_external_editor

# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QDir [as 別名]
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]) 
開發者ID:BetaRavener,項目名稱:uPyLoader,代碼行數:10,代碼來源:settings_dialog.py

示例4: browse_mpy_cross

# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QDir [as 別名]
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]) 
開發者ID:BetaRavener,項目名稱:uPyLoader,代碼行數:10,代碼來源:settings_dialog.py

示例5: browse_external_transfer_files

# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QDir [as 別名]
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) 
開發者ID:BetaRavener,項目名稱:uPyLoader,代碼行數:10,代碼來源:settings_dialog.py

示例6: do_search

# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QDir [as 別名]
def do_search(self):
        #print(f'Beginning search for: {self.term}')
        root = qtc.QDir.rootPath()
        self._search(self.term, root)
        self.finished.emit() 
開發者ID:PacktPublishing,項目名稱:Mastering-GUI-Programming-with-Python,代碼行數:7,代碼來源:file_searcher.py

示例7: _search

# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QDir [as 別名]
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()) 
開發者ID:PacktPublishing,項目名稱:Mastering-GUI-Programming-with-Python,代碼行數:16,代碼來源:file_searcher.py

示例8: do_hashing

# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QDir [as 別名]
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() 
開發者ID:PacktPublishing,項目名稱:Mastering-GUI-Programming-with-Python,代碼行數:15,代碼來源:hasher.py

示例9: run

# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QDir [as 別名]
def run(self):
        #print(f'Beginning search for: {self.term}')
        root = qtc.QDir.rootPath()
        self._search(self.term, root)
        self.finished.emit() 
開發者ID:PacktPublishing,項目名稱:Mastering-GUI-Programming-with-Python,代碼行數:7,代碼來源:file_searcher_subclassed.py

示例10: initUI

# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QDir [as 別名]
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) 
開發者ID:hANSIc99,項目名稱:Pythonic,代碼行數:41,代碼來源:basictools.py

示例11: initUI

# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QDir [as 別名]
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) 
開發者ID:hANSIc99,項目名稱:Pythonic,代碼行數:28,代碼來源:mltools.py

示例12: loadClicked

# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QDir [as 別名]
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() 
開發者ID:decred,項目名稱:tinydecred,代碼行數:37,代碼來源:screens.py

示例13: onOpen

# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QDir [as 別名]
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() 
開發者ID:league1991,項目名稱:CodeAtlasSublime,代碼行數:13,代碼來源:mainwindow.py

示例14: onOpenPath

# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QDir [as 別名]
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() 
開發者ID:league1991,項目名稱:CodeAtlasSublime,代碼行數:14,代碼來源:mainwindow.py

示例15: dropEvent

# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QDir [as 別名]
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() 
開發者ID:epolestar,項目名稱:equant,代碼行數:53,代碼來源:utils.py


注:本文中的PyQt5.QtCore.QDir方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。