本文整理匯總了Python中PyQt5.QtCore.QFileInfo方法的典型用法代碼示例。如果您正苦於以下問題:Python QtCore.QFileInfo方法的具體用法?Python QtCore.QFileInfo怎麽用?Python QtCore.QFileInfo使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類PyQt5.QtCore
的用法示例。
在下文中一共展示了QtCore.QFileInfo方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: open_books_at_startup
# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QFileInfo [as 別名]
def open_books_at_startup(self):
# Last open books and command line books aren't being opened together
# so that command line books are processed last and therefore retain focus
# Open last... open books.
# Then set the value to None for the next run
if self.settings['last_open_books']:
files_to_open = {i: None for i in self.settings['last_open_books']}
self.open_files(files_to_open)
else:
self.settings['last_open_tab'] = None
# Open input files if specified
cl_parser = QtCore.QCommandLineParser()
cl_parser.process(QtWidgets.qApp)
my_args = cl_parser.positionalArguments()
if my_args:
file_list = [QtCore.QFileInfo(i).absoluteFilePath() for i in my_args]
self.process_post_hoc_files(file_list, True)
示例2: exportarPDF
# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QFileInfo [as 別名]
def exportarPDF(self):
if not self.documento.isEmpty():
nombreArchivo, _ = QFileDialog.getSaveFileName(self, "Exportar a PDF", "Listado de usuarios",
"Archivos PDF (*.pdf);;All Files (*)",
options=QFileDialog.Options())
if nombreArchivo:
# if QFileInfo(nombreArchivo).suffix():
# nombreArchivo += ".pdf"
impresion = QPrinter(QPrinter.HighResolution)
impresion.setOutputFormat(QPrinter.PdfFormat)
impresion.setOutputFileName(nombreArchivo)
self.documento.print_(impresion)
QMessageBox.information(self, "Exportar a PDF", "Datos exportados con éxito. ",
QMessageBox.Ok)
else:
QMessageBox.critical(self, "Exportar a PDF", "No hay datos para exportar. ",
QMessageBox.Ok)
# ================================================================
示例3: runto
# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QFileInfo [as 別名]
def runto(self):
self.path = QtCore.QFileInfo(self.filename).path()
g = globals()
os.chdir(str(self.path))
script = str(self.codebox.text())
try:
os.chdir(str(self.path))
os.path.join(os.path.expanduser('~'), os.path.expandvars(str(self.path)))
sys.path.insert(0, str(self.path))
exec (script, g)
except Exception as e:
print e.__doc__
print e.message
else:
pass
#exec (script, g)
示例4: icon
# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QFileInfo [as 別名]
def icon(self, type_info):
'''
:param fileInfo: 參考http://doc.qt.io/qt-5/qfileinfo.html
'''
if isinstance(type_info, QFileInfo):
# 如果type_info是QFileInfo類型則用getInfoIcon來返回圖標
return self.getInfoIcon(type_info)
# 如果type_info是QFileIconProvider自身的IconType枚舉類型則執行下麵的方法
# 這裏隻能自定義通用的幾種類型,參考http://doc.qt.io/qt-5/qfileiconprovider.html#IconType-enum
'''
QFileIconProvider::Computer 0
QFileIconProvider::Desktop 1
QFileIconProvider::Trashcan 2
QFileIconProvider::Network 3
QFileIconProvider::Drive 4
QFileIconProvider::Folder 5
QFileIconProvider::File 6
'''
if type_info == QFileIconProvider.Folder:
# 如果是文件夾
return self.DirIcon
return super(FileIconProvider, self).icon(type_info)
示例5: loadQSS
# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QFileInfo [as 別名]
def loadQSS(theme) -> None:
filename = ':/styles/{}.qss'.format(theme)
if QFileInfo(filename).exists():
qssfile = QFile(filename)
qssfile.open(QFile.ReadOnly | QFile.Text)
content = QTextStream(qssfile).readAll()
qApp.setStyleSheet(content)
示例6: getSettingsPath
# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QFileInfo [as 別名]
def getSettingsPath() -> str:
if sys.platform == 'win32':
settings_path = os.path.join(QDir.homePath(), 'AppData', 'Local', 'vidcutter')
elif sys.platform == 'darwin':
settings_path = os.path.join(QDir.homePath(), 'Library', 'Preferences', 'vidcutter')
else:
if QFileInfo(__file__).absolutePath().startswith('/app/'):
settings_path = QProcessEnvironment.systemEnvironment().value('XDG_CONFIG_HOME', '')
if not len(settings_path):
settings_path = os.path.join(QDir.homePath(), '.var', 'app', vidcutter.__desktopid__, 'config')
else:
settings_path = os.path.join(QDir.homePath(), '.config', 'vidcutter')
return os.path.join(settings_path, 'vidcutter.ini')
示例7: saveScreenshot
# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QFileInfo [as 別名]
def saveScreenshot(self):
logger.info("Saving %s to file...", self.name)
filename, _ = QtWidgets.QFileDialog.getSaveFileName(parent=self, caption="Save image",
filter="PNG (*.png);;All files (*.*)")
logger.debug("Filename: %s", filename)
if filename != "":
if not QtCore.QFileInfo(filename).suffix():
filename += ".png"
self.grab().save(filename)
示例8: open_file
# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QFileInfo [as 別名]
def open_file(path):
QDesktopServices.openUrl(QUrl.fromLocalFile(QFileInfo(path).absoluteFilePath()))
示例9: open
# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QFileInfo [as 別名]
def open(self):
self.path = QtCore.QFileInfo(self.filename).path()
# Get filename and show only .writer files
(self.filename, _) = \
QtWidgets.QFileDialog.getOpenFileName(self.vindu,
'Open File', self.path,
'Python Files (*.py *.pyc *.pyw)', '')
if self.filename:
with open(self.filename, 'r') as self.file:
self.codebox.setText(self.file.read())
os.chdir(str(self.path))
示例10: savefile
# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QFileInfo [as 別名]
def savefile(self):
self.path = QtCore.QFileInfo(self.filename).path()
(self.filename, _) = \
QtWidgets.QFileDialog.getSaveFileName(self.vindu, 'Save as'
, self.path, 'Python Files (*.py *.pyc *.pyw)')
if self.filename:
self.savetext(self.filename)
os.chdir(str(self.path))
示例11: runto
# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QFileInfo [as 別名]
def runto(self):
self.path = QtCore.QFileInfo(self.filename).path()
g = globals()
os.chdir(str(self.path))
script = str(self.codebox.text())
try:
os.chdir(str(self.path))
os.path.join(os.path.expanduser('~'), os.path.expandvars(str(self.path)))
sys.path.insert(0, str(self.path))
exec (script, g)
except Exception as e:
print e.__doc__
print e.message
else:
exec (script, g)
示例12: runtoprob
# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QFileInfo [as 別名]
def runtoprob(self):
try:
self.path = QtCore.QFileInfo(self.filename).path()
self.path = QtCore.QFileInfo(self.filename).path()
g = globals()
os.chdir(str(self.path))
script = str(self.codebox.text())
import cProfile
cProfile.run(script)
except Exception as e:
print e.__doc__
print e.message
else:
import cProfile
cProfile.run(script)
示例13: opentemp
# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QFileInfo [as 別名]
def opentemp(self):
print "hello"
self.path = QtCore.QFileInfo(self.filename).path()
# Get filename and show only .writer files
(self.filename, _) = \
QtWidgets.QFileDialog.getOpenFileName(self.wizardPage_3,
'Open File', self.path,
'Python Files (*.py *.pyc *.pyw)', '')
if self.filename:
with open(self.filename, 'r') as self.file:
self.TemptextEdit.setText(self.file.read())
os.chdir(str(self.path))
示例14: openscript
# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QFileInfo [as 別名]
def openscript(self):
print "hello"
self.path = QtCore.QFileInfo(self.filename).path()
# Get filename and show only .writer files
(self.filename, _) = \
QtWidgets.QFileDialog.getOpenFileName(self.wizardPage_3,
'Open File', self.path,
'Python Files (*.py *.pyc *.pyw)', '')
if self.filename:
with open(self.filename, 'r') as self.file:
self.script_textEdit.setText(self.file.read())
os.chdir(str(self.path))
示例15: savescript
# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QFileInfo [as 別名]
def savescript(self):
self.path = QtCore.QFileInfo(self.filename).path()
(self.filename, _) = \
QtWidgets.QFileDialog.getSaveFileName(self.wizardPage_3, 'Save as'
, self.path, 'Python Files (*.py *.pyc *.pyw)')
if self.filename:
self.savetextscript(self.filename)
os.chdir(str(self.path))