本文整理汇总了Python中PyQt5.QtCore.QFileInfo.absolutePath方法的典型用法代码示例。如果您正苦于以下问题:Python QFileInfo.absolutePath方法的具体用法?Python QFileInfo.absolutePath怎么用?Python QFileInfo.absolutePath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtCore.QFileInfo
的用法示例。
在下文中一共展示了QFileInfo.absolutePath方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from PyQt5.QtCore import QFileInfo [as 别名]
# 或者: from PyQt5.QtCore.QFileInfo import absolutePath [as 别名]
def __init__(self, ui_file, bus, devices=[], parent=None):
QtWidgets.QMainWindow.__init__(self, parent=parent)
self.bus = bus
# TODO: CAMPid 980567566238416124867857834291346779
ico_file = os.path.join(QFileInfo.absolutePath(QFileInfo(__file__)), "icon.ico")
ico = QtGui.QIcon(ico_file)
self.setWindowIcon(ico)
ui = ui_file
# TODO: CAMPid 9549757292917394095482739548437597676742
if not QFileInfo(ui).isAbsolute():
ui_file = os.path.join(QFileInfo.absolutePath(QFileInfo(__file__)), ui)
else:
ui_file = ui
ui_file = QFile(ui_file)
ui_file.open(QFile.ReadOnly | QFile.Text)
ts = QTextStream(ui_file)
sio = io.StringIO(ts.readAll())
self.ui = uic.loadUi(sio, self)
self.ui.action_About.triggered.connect(self.about)
device_tree = epyqlib.devicetree.Tree()
device_tree_model = epyqlib.devicetree.Model(root=device_tree)
device_tree_model.device_removed.connect(self._remove_device)
self.ui.device_tree.setModel(device_tree_model)
self.ui.device_tree.device_selected.connect(self.set_current_device)
示例2: openFolder
# 需要导入模块: from PyQt5.QtCore import QFileInfo [as 别名]
# 或者: from PyQt5.QtCore.QFileInfo import absolutePath [as 别名]
def openFolder(self):
"""
Public slot to open the folder containing the downloaded file.
"""
info = QFileInfo(self.__fileName)
url = QUrl.fromLocalFile(info.absolutePath())
QDesktopServices.openUrl(url)
示例3: _addIcon
# 需要导入模块: from PyQt5.QtCore import QFileInfo [as 别名]
# 或者: from PyQt5.QtCore.QFileInfo import absolutePath [as 别名]
def _addIcon(self):
filter_ = self.tr("Images (*.jpg *.jpeg *.bmp *.png *.tiff *.gif);;"
"All files (*.*)")
fileName, _selectedFilter = QFileDialog.getOpenFileName(self,
self.tr("Open File"), self.latestDir,
filter_)
if fileName:
file_info = QFileInfo(fileName)
self.latestDir = file_info.absolutePath()
image = QImage()
if image.load(fileName):
maxWidth = 22
maxHeight = 15
if image.width() > maxWidth or image.height() > maxHeight:
scaledImage = image.scaled(maxWidth, maxHeight,
Qt.KeepAspectRatio, Qt.SmoothTransformation)
else:
scaledImage = image
ba = QByteArray()
buffer = QBuffer(ba)
buffer.open(QIODevice.WriteOnly)
scaledImage.save(buffer, 'png')
model = self.model()
index = model.index(self.selectedIndex().row(), model.fieldIndex('icon'))
model.setData(index, ba)
示例4: _addIcon
# 需要导入模块: from PyQt5.QtCore import QFileInfo [as 别名]
# 或者: from PyQt5.QtCore.QFileInfo import absolutePath [as 别名]
def _addIcon(self):
filter_ = self.tr("Images (*.jpg *.jpeg *.bmp *.png *.tiff *.gif *.ico);;"
"All files (*.*)")
fileName, _selectedFilter = QFileDialog.getOpenFileName(self,
self.tr("Open File"), self.latestDir,
filter_)
if fileName:
file_info = QFileInfo(fileName)
self.latestDir = file_info.absolutePath()
self.loadFromFile(fileName)
示例5: destinationButtonClicked
# 需要导入模块: from PyQt5.QtCore import QFileInfo [as 别名]
# 或者: from PyQt5.QtCore.QFileInfo import absolutePath [as 别名]
def destinationButtonClicked(self):
destination = self.destination.text()
if not destination and self.collection:
destination = self.latestDir + '/' + self.collection.getCollectionName() + '_mobile.db'
file, _selectedFilter = QFileDialog.getSaveFileName(
self, self.tr("Select destination"), destination, "*.db")
if file:
file_info = QFileInfo(file)
self.latestDir = file_info.absolutePath()
self.destination.setText(file)
self.acceptButton.setEnabled(True)
示例6: create_wallet
# 需要导入模块: from PyQt5.QtCore import QFileInfo [as 别名]
# 或者: from PyQt5.QtCore.QFileInfo import absolutePath [as 别名]
def create_wallet(database):
target_dir = QFileInfo(database).absoluteDir()
if not target_dir.exists():
QDir().mkdir(target_dir.absolutePath())
db = sqlite3.connect(database)
cursor = db.cursor()
try:
for cq in WalletDatabase.__WALLET_INIT_WALLET_QUERY:
cursor.execute(cq)
except sqlite3.Error as e:
raise WalletDatabaseException(tr('WalletDatabase', 'Failed to create wallet: %s') % e)
db.commit()
db.close()
示例7: excepthook
# 需要导入模块: from PyQt5.QtCore import QFileInfo [as 别名]
# 或者: from PyQt5.QtCore.QFileInfo import absolutePath [as 别名]
def excepthook(excType, excValue, tracebackobj):
"""
Global function to catch unhandled exceptions.
@param excType exception type
@param excValue exception value
@param tracebackobj traceback object
"""
separator = "-" * 70
email = "[email protected]"
try:
hash = "Revision Hash: {}\n\n".format(epyq.revision.hash)
except:
hash = ""
notice = (
"""An unhandled exception occurred. Please report the problem via email to:\n"""
"""\t\t{email}\n\n{hash}"""
"""A log has been written to "{log}".\n\nError information:\n""".format(email=email, hash=hash, log=log.name)
)
# TODO: add something for version
versionInfo = ""
timeString = time.strftime("%Y-%m-%d, %H:%M:%S")
tbinfofile = io.StringIO()
traceback.print_tb(tracebackobj, None, tbinfofile)
tbinfofile.seek(0)
tbinfo = tbinfofile.read()
errmsg = "%s: \n%s" % (str(excType), str(excValue))
sections = [separator, timeString, separator, errmsg, separator, tbinfo]
msg = "\n".join(sections)
errorbox = QMessageBox()
errorbox.setWindowTitle("EPyQ")
errorbox.setIcon(QMessageBox.Critical)
# TODO: CAMPid 980567566238416124867857834291346779
ico_file = os.path.join(QFileInfo.absolutePath(QFileInfo(__file__)), "icon.ico")
ico = QtGui.QIcon(ico_file)
errorbox.setWindowIcon(ico)
complete = str(notice) + str(msg) + str(versionInfo)
sys.stderr.write(complete)
errorbox.setText(complete)
errorbox.exec_()
示例8: addFilesClicked
# 需要导入模块: from PyQt5.QtCore import QFileInfo [as 别名]
# 或者: from PyQt5.QtCore.QFileInfo import absolutePath [as 别名]
def addFilesClicked(self):
newFiles = QFileDialog.getOpenFileNames(self, "Please select the files to add to stack", "",
"Images (*.png *.jpg *.bmp)")
for file in newFiles[0]:
entries = self.fileTreeWidget.findItems(file, Qt.MatchCaseSensitive)
for entry in entries:
self.fileTreeWidget.takeItem(self.fileTreeWidget.row(entry))
item = QTreeWidgetItem()
fileInfo = QFileInfo(file)
fileInfo.fileName()
exif = getExifInfo(file)
item.setText(0, fileInfo.fileName())
item.setText(1, exif.exposureTime)
item.setText(2, exif.aperture)
item.setText(3, exif.ISO)
item.setText(4, fileInfo.absolutePath())
self.fileTreeWidget.insertTopLevelItem(self.fileTreeWidget.topLevelItemCount(), item)
示例9: about
# 需要导入模块: from PyQt5.QtCore import QFileInfo [as 别名]
# 或者: from PyQt5.QtCore.QFileInfo import absolutePath [as 别名]
def about(self):
box = QMessageBox()
box.setWindowTitle("About EPyQ")
# TODO: CAMPid 980567566238416124867857834291346779
ico_file = os.path.join(QFileInfo.absolutePath(QFileInfo(__file__)), "icon.ico")
ico = QtGui.QIcon(ico_file)
box.setWindowIcon(ico)
message = [__copyright__, __license__]
try:
import epyq.revision
except ImportError:
pass
else:
message.append(epyq.revision.hash)
box.setText("\n".join(message))
box.exec_()
示例10: _write_qmake
# 需要导入模块: from PyQt5.QtCore import QFileInfo [as 别名]
# 或者: from PyQt5.QtCore.QFileInfo import absolutePath [as 别名]
#.........这里部分代码省略.........
lib_name += '_s'
l_libs.append('-l' + lib_name)
# Add the LIBS value for any PyQt modules to the global scope.
if len(l_libs) > 0:
self._add_value_for_scopes(used_libs,
'-L{0}/{1} {2}'.format(site_packages, pyqt_version,
' '.join(l_libs)))
# Add the sip module.
self._add_value_for_scopes(used_inittab, 'sip')
self._add_value_for_scopes(used_libs,
'-L{0} -lsip'.format(site_packages))
# Handle any other extension modules.
for other_em in project.other_extension_modules:
scoped_values = self._parse_scoped_values(other_em.libs, False)
for scope, values in scoped_values.items():
self._add_value_for_scopes(used_inittab, other_em.name,
[scope])
self._add_value_set_for_scope(used_libs, values, scope)
# Configure the target Python interpreter.
if project.python_target_include_dir != '':
self._add_value_for_scopes(used_includepath,
project.path_from_user(project.python_target_include_dir))
if project.python_target_library != '':
fi = QFileInfo(project.path_from_user(
project.python_target_library))
lib_dir = fi.absolutePath()
lib = fi.completeBaseName()
# This is smart enough to translate the Python library as a UNIX .a
# file to what Windows needs.
if lib.startswith('lib'):
lib = lib[3:]
if '.' in lib:
self._add_value_for_scopes(used_libs,
'-L{0} -l{1}'.format(lib_dir, lib.replace('.', '')),
['win32'])
self._add_value_for_scopes(used_libs,
'-L{0} -l{1}'.format(lib_dir, lib), ['!win32'])
else:
self._add_value_for_scopes(used_libs,
'-L{0} -l{1}'.format(lib_dir, lib))
# Handle any standard library extension modules.
if len(required_ext) != 0:
source_dir = project.path_from_user(project.python_source_dir)
source_scopes = set()
for name, module in required_ext.items():
# Get the list of all applicable scopes.
module_scopes = self._stdlib_scopes(module.scope)
if len(module_scopes) == 0:
# The module is specific to a platform for which we are
# using the python.org Python libraries so ignore it
# completely.
continue
示例11: __getFileName
# 需要导入模块: from PyQt5.QtCore import QFileInfo [as 别名]
# 或者: from PyQt5.QtCore.QFileInfo import absolutePath [as 别名]
def __getFileName(self):
"""
Private method to get the file name to save to from the user.
"""
if self.__gettingFileName:
return
import Helpviewer.HelpWindow
downloadDirectory = Helpviewer.HelpWindow.HelpWindow\
.downloadManager().downloadDirectory()
if self.__fileName:
fileName = self.__fileName
originalFileName = self.__originalFileName
self.__toDownload = True
ask = False
else:
defaultFileName, originalFileName = \
self.__saveFileName(downloadDirectory)
fileName = defaultFileName
self.__originalFileName = originalFileName
ask = True
self.__autoOpen = False
if not self.__toDownload:
from .DownloadAskActionDialog import DownloadAskActionDialog
url = self.__reply.url()
dlg = DownloadAskActionDialog(
QFileInfo(originalFileName).fileName(),
self.__reply.header(QNetworkRequest.ContentTypeHeader),
"{0}://{1}".format(url.scheme(), url.authority()),
self)
if dlg.exec_() == QDialog.Rejected or dlg.getAction() == "cancel":
self.progressBar.setVisible(False)
self.__reply.close()
self.on_stopButton_clicked()
self.filenameLabel.setText(
self.tr("Download canceled: {0}").format(
QFileInfo(defaultFileName).fileName()))
self.__canceledFileSelect = True
return
if dlg.getAction() == "scan":
self.__mainWindow.requestVirusTotalScan(url)
self.progressBar.setVisible(False)
self.__reply.close()
self.on_stopButton_clicked()
self.filenameLabel.setText(
self.tr("VirusTotal scan scheduled: {0}").format(
QFileInfo(defaultFileName).fileName()))
self.__canceledFileSelect = True
return
self.__autoOpen = dlg.getAction() == "open"
if PYQT_VERSION_STR >= "5.0.0":
from PyQt5.QtCore import QStandardPaths
tempLocation = QStandardPaths.standardLocations(
QStandardPaths.TempLocation)[0]
else:
from PyQt5.QtGui import QDesktopServices
tempLocation = QDesktopServices.storageLocation(
QDesktopServices.TempLocation)
fileName = tempLocation + '/' + \
QFileInfo(fileName).completeBaseName()
if ask and not self.__autoOpen and self.__requestFilename:
self.__gettingFileName = True
fileName = E5FileDialog.getSaveFileName(
None,
self.tr("Save File"),
defaultFileName,
"")
self.__gettingFileName = False
if not fileName:
self.progressBar.setVisible(False)
self.__reply.close()
self.on_stopButton_clicked()
self.filenameLabel.setText(
self.tr("Download canceled: {0}")
.format(QFileInfo(defaultFileName).fileName()))
self.__canceledFileSelect = True
return
fileInfo = QFileInfo(fileName)
Helpviewer.HelpWindow.HelpWindow.downloadManager()\
.setDownloadDirectory(fileInfo.absoluteDir().absolutePath())
self.filenameLabel.setText(fileInfo.fileName())
self.__output.setFileName(fileName + ".part")
self.__fileName = fileName
# check file path for saving
saveDirPath = QFileInfo(self.__fileName).dir()
if not saveDirPath.exists():
if not saveDirPath.mkpath(saveDirPath.absolutePath()):
self.progressBar.setVisible(False)
self.on_stopButton_clicked()
self.infoLabel.setText(self.tr(
"Download directory ({0}) couldn't be created.")
.format(saveDirPath.absolutePath()))
#.........这里部分代码省略.........