本文整理汇总了Python中PyQt5.QtCore.QFileInfo.dir方法的典型用法代码示例。如果您正苦于以下问题:Python QFileInfo.dir方法的具体用法?Python QFileInfo.dir怎么用?Python QFileInfo.dir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtCore.QFileInfo
的用法示例。
在下文中一共展示了QFileInfo.dir方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: restoreDir
# 需要导入模块: from PyQt5.QtCore import QFileInfo [as 别名]
# 或者: from PyQt5.QtCore.QFileInfo import dir [as 别名]
def restoreDir(self):
"用户点击了“默认运行目录”按钮。"
path = self.txtPath.text().strip()
fi = QFileInfo(path)
if path == "" or not fi.exists():
return
self.txtDir.setText(fi.dir().absolutePath())
示例2: browsePath
# 需要导入模块: from PyQt5.QtCore import QFileInfo [as 别名]
# 或者: from PyQt5.QtCore.QFileInfo import dir [as 别名]
def browsePath(self):
"""用户点击了浏览路径的按钮。如果成功设置了路径,就返回True,如果用户取消了操作或者出错,就返回False
返回的用途参见showEvent()"""
filename, selectedFilter = QFileDialog.getOpenFileName(self, self.windowTitle())
if not filename:
return False
fi = QFileInfo(filename)
if fi.isSymLink():
filename = fi.symLinkTarget()
if not os.path.exists(filename):
QMessageBox.information(self, self.windowTitle(), self.tr("快捷方式所指向的程序不正确。"))
return False
fi = QFileInfo(filename)
self.txtName.setText(fi.baseName())
self.txtPath.setText(fi.absoluteFilePath())
self.setFileIcon(fi.absoluteFilePath())
self.txtDir.setText(fi.dir().absolutePath())
return True
示例3: Project
# 需要导入模块: from PyQt5.QtCore import QFileInfo [as 别名]
# 或者: from PyQt5.QtCore.QFileInfo import dir [as 别名]
class Project(QObject):
""" The encapsulation of a project. """
# The minimum supported project version. At the moment a project will be
# automatically updated to the current version when saved.
min_version = 4
# The current project version.
version = 6
# Emitted when the modification state of the project changes.
modified_changed = pyqtSignal(bool)
@property
def modified(self):
""" The modified property getter. """
return self._modified
@modified.setter
def modified(self, value):
""" The modified property setter. """
if self._modified != value:
self._modified = value
self.modified_changed.emit(value)
# Emitted when the name of the project changes.
name_changed = pyqtSignal(str)
@property
def name(self):
""" The name property getter. """
# Use absoluteFilePath() because the file might not exist.
return self._name.absoluteFilePath() if self._name is not None else ''
@name.setter
def name(self, value):
""" The name property setter. """
if self._name is None or self._name.absoluteFilePath() != value:
self._name = QFileInfo(value)
self.name_changed.emit(value)
def __init__(self, name=''):
""" Initialise the project. """
super().__init__()
# Initialise the project meta-data.
self._modified = False
self._name = QFileInfo(name) if name != '' else None
# Initialise the project data.
self.application_name = ''
self.application_is_pyqt5 = True
self.application_is_console = False
self.application_use_py_dll = False
self.application_is_bundle = True
self.application_package = QrcPackage()
self.application_script = ''
self.application_entry_point = ''
self.build_dir = 'build'
self.external_libraries = []
self.other_extension_modules = []
self.other_packages = []
self.pyqt_modules = []
self.python_host_interpreter = ''
self.python_use_platform = ['win32']
self.python_source_dir = '$SYSROOT/src/Python-$PDY_PY_MAJOR.$PDY_PY_MINOR.$PDY_PY_MICRO'
self.python_ssl = False
self.python_target_include_dir = '$SYSROOT/include/python$PDY_PY_MAJOR.$PDY_PY_MINOR'
self.python_target_library = '$SYSROOT/lib/libpython$PDY_PY_MAJOR.$PDY_PY_MINOR.a'
self.python_target_stdlib_dir = '$SYSROOT/lib/python$PDY_PY_MAJOR.$PDY_PY_MINOR'
self.python_target_version = get_latest_supported_python_version()
self.qmake = ''
self.qmake_configuration = ''
self.standard_library = []
self.sys_path = ''
def path_to_user(self, path):
""" Convert a file name to one that is relative to the project name if
possible and uses native separators.
"""
if self._name is not None:
rel = self._name.dir().relativeFilePath(path)
if not rel.startswith('..'):
path = rel
return QDir.toNativeSeparators(path)
def path_from_user(self, user_path):
""" Convert the name of a file or directory specified by the user to
the standard Qt format (ie. an absolute path using UNIX separators). A
user path may be relative to the name of the project and may contain
environment variables.
"""
#.........这里部分代码省略.........