本文整理匯總了Python中PyQt4.QtGui.QFileDialog方法的典型用法代碼示例。如果您正苦於以下問題:Python QtGui.QFileDialog方法的具體用法?Python QtGui.QFileDialog怎麽用?Python QtGui.QFileDialog使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類PyQt4.QtGui
的用法示例。
在下文中一共展示了QtGui.QFileDialog方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: openProject
# 需要導入模塊: from PyQt4 import QtGui [as 別名]
# 或者: from PyQt4.QtGui import QFileDialog [as 別名]
def openProject(self):
"""
Open an existing project
"""
# Check if the current project has changed before continue operation
if self.__checkCurrentConfigChanges() != QtGui.QMessageBox.Cancel:
# Ask user for an existing file
selectedFile = str(QtGui.QFileDialog().getOpenFileName(self, "Open Project", Global.appPath + '/projects', "NuPIC project files (*.nuproj)"))
# If file exists, continue operation
if selectedFile != '':
# Open the selected project
Global.project.open(selectedFile)
# Initialize project state
self.setWindowTitle(Global.project.name + " - [" + Global.project.fileName + "] - NuPIC Studio")
self.markProjectChanges(False)
self.__cleanUp()
return True
return False
示例2: selectPwFile
# 需要導入模塊: from PyQt4 import QtGui [as 別名]
# 或者: from PyQt4.QtGui import QFileDialog [as 別名]
def selectPwFile(self):
"""
Show file dialog and return file user chose to store the
encrypted password database.
"""
path = QtCore.QDir.currentPath()
dialog = QtGui.QFileDialog(self, "Select password database file",
path, "(*.pwdb)")
dialog.setAcceptMode(QtGui.QFileDialog.AcceptSave)
res = dialog.exec_()
if not res:
return
fname = dialog.selectedFiles()[0]
self.pwFileEdit.setText(fname)
示例3: saveProject
# 需要導入模塊: from PyQt4 import QtGui [as 別名]
# 或者: from PyQt4.QtGui import QFileDialog [as 別名]
def saveProject(self):
"""
Save the current project
"""
# If current project is new, ask user for valid file
fileName = Global.project.fileName
if fileName == '':
# Ask user for valid file
selectedFile = str(QtGui.QFileDialog().getSaveFileName(self, "Save Project", Global.appPath + '/projects', "NuPIC project files (*.nuproj)"))
# If file exists, continue operation
if selectedFile != '':
fileName = selectedFile
# If file is Ok, continue operation
if fileName != '':
# Save to the selected location
Global.project.save(fileName)
# Initialize project state
self.setWindowTitle(Global.project.name + " - [" + Global.project.fileName + "] - NuPIC Studio")
self.markProjectChanges(False)
return True
return False
示例4: __buttonBrowseFile_Click
# 需要導入模塊: from PyQt4 import QtGui [as 別名]
# 或者: from PyQt4.QtGui import QFileDialog [as 別名]
def __buttonBrowseFile_Click(self, event):
# Ask user for an existing file
selectedFile = QtGui.QFileDialog().getOpenFileName(self, "Open File", Global.appPath + '/projects', "Input files (*.csv)")
# If file exists, set data source file
if selectedFile != '':
# Set file
self.textBoxFile.setText(selectedFile)
示例5: file_dialog
# 需要導入模塊: from PyQt4 import QtGui [as 別名]
# 或者: from PyQt4.QtGui import QFileDialog [as 別名]
def file_dialog(self, title):
dialog = qg.QFileDialog()
dialog.setWindowTitle(title)
dialog.setFileMode(qg.QFileDialog.AnyFile)
filenames = qc.QStringList()
if dialog.exec_():
filenames = dialog.selectedFiles()
return filenames[0]
raise Exception('Failed to open dialog')
示例6: saveBackup
# 需要導入模塊: from PyQt4 import QtGui [as 別名]
# 或者: from PyQt4.QtGui import QFileDialog [as 別名]
def saveBackup(self):
"""
Uses backup key encrypted by Trezor to decrypt all
passwords at once and export them. Export format is
CSV: group, key, password
"""
dialog = QtGui.QFileDialog(self,
"Select backup export file",
"", "CVS files (*.csv)")
dialog.setAcceptMode(QtGui.QFileDialog.AcceptSave)
res = dialog.exec_()
if not res:
return
fname = q2s(dialog.selectedFiles()[0])
backupKey = self.pwMap.backupKey
try:
privateKey = backupKey.unwrapPrivateKey()
except CallException:
return
with file(fname, "w") as f:
csv.register_dialect("escaped", doublequote=False, escapechar='\\')
writer = csv.writer(f, dialect="escaped")
sortedGroupNames = sorted(self.pwMap.groups.keys())
for groupName in sortedGroupNames:
group = self.pwMap.groups[groupName]
for entry in group.entries:
key, _, bkupPw = entry
password = backupKey.decryptPassword(bkupPw, privateKey)
csvEntry = (groupName, key, password)
writer.writerow(csvEntry)
示例7: event_show_select_file_dialog
# 需要導入模塊: from PyQt4 import QtGui [as 別名]
# 或者: from PyQt4.QtGui import QFileDialog [as 別名]
def event_show_select_file_dialog(self):
file_dialog = QtGui.QFileDialog()
file_dialog.setAcceptMode(QtGui.QFileDialog.AcceptOpen)
filters = [ "PEM Files (*.pem)", "Any files (*)" ]
# file_dialog.fileSelected.connect(self.event_file_selected)
file_dialog.filesSelected.connect(self.event_files_selected)
file_dialog.setFileMode(QtGui.QFileDialog.ExistingFiles)
file_dialog.exec()
示例8: save_as_pdf
# 需要導入模塊: from PyQt4 import QtGui [as 別名]
# 或者: from PyQt4.QtGui import QFileDialog [as 別名]
def save_as_pdf(self):
dialog = QtGui.QFileDialog(self)
dialog.setDefaultSuffix("pdf")
dialog.setWindowTitle("Save Figure as PDF...")
dialog.setAcceptMode(QtGui.QFileDialog.AcceptSave)
dialog.setFileMode(QtGui.QFileDialog.AnyFile)
dialog.fileSelected.connect(self.save_as_pdf_to_file)
dialog.exec()