本文整理汇总了Python中KdeQt.KQFileDialog.getSaveFileName方法的典型用法代码示例。如果您正苦于以下问题:Python KQFileDialog.getSaveFileName方法的具体用法?Python KQFileDialog.getSaveFileName怎么用?Python KQFileDialog.getSaveFileName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KdeQt.KQFileDialog
的用法示例。
在下文中一共展示了KQFileDialog.getSaveFileName方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __getFileName
# 需要导入模块: from KdeQt import KQFileDialog [as 别名]
# 或者: from KdeQt.KQFileDialog import getSaveFileName [as 别名]
def __getFileName(self):
"""
Private method to get the filename to save to from the user.
@return flag indicating success (boolean)
"""
downloadDirectory = Preferences.getUI("DownloadPath")
if downloadDirectory.isEmpty():
downloadDirectory = \
QDesktopServices.storageLocation(QDesktopServices.DocumentsLocation)
if not downloadDirectory.isEmpty():
downloadDirectory += '/'
defaultFileName = self.__saveFileName(downloadDirectory)
fileName = defaultFileName
baseName = QFileInfo(fileName).completeBaseName()
self.__autoOpen = False
if not self.__toDownload:
res = KQMessageBox.question(None,
self.trUtf8("Downloading"),
self.trUtf8("""<p>You are about to download the file <b>%1</b>.</p>"""
"""<p>What do you want to do?</p>""").arg(fileName),
QMessageBox.StandardButtons(\
QMessageBox.Open | \
QMessageBox.Save | \
QMessageBox.Cancel))
if res == QMessageBox.Cancel:
self.__stop()
self.close()
return False
self.__autoOpen = res == QMessageBox.Open
fileName = QDesktopServices.storageLocation(QDesktopServices.TempLocation) + \
'/' + QFileInfo(fileName).completeBaseName()
if not self.__autoOpen and self.__requestFilename:
fileName = KQFileDialog.getSaveFileName(\
None,
self.trUtf8("Save File"),
defaultFileName,
QString(),
None)
if fileName.isEmpty():
self.__reply.close()
if not self.keepOpenCheckBox.isChecked():
self.close()
return False
else:
self.filenameLabel.setText(self.trUtf8("Download canceled: %1")\
.arg(QFileInfo(defaultFileName).fileName()))
self.__stop()
return True
self.__output.setFileName(fileName)
self.filenameLabel.setText(QFileInfo(self.__output.fileName()).fileName())
if self.__requestFilename:
self.__readyRead()
return True
示例2: on_saveButton_clicked
# 需要导入模块: from KdeQt import KQFileDialog [as 别名]
# 或者: from KdeQt.KQFileDialog import getSaveFileName [as 别名]
def on_saveButton_clicked(self):
"""
Private slot to handle the Save button press.
It saves the diff shown in the dialog to a file in the local
filesystem.
"""
if type(self.filename) is types.ListType:
if len(self.filename) > 1:
fname = self.vcs.splitPathList(self.filename)[0]
else:
dname, fname = self.vcs.splitPath(self.filename[0])
if fname != '.':
fname = "%s.diff" % self.filename[0]
else:
fname = dname
else:
fname = self.vcs.splitPath(self.filename)[0]
selectedFilter = QString("")
fname = KQFileDialog.getSaveFileName(\
self,
self.trUtf8("Save Diff"),
fname,
self.trUtf8("Patch Files (*.diff)"),
selectedFilter,
QFileDialog.Options(QFileDialog.DontConfirmOverwrite))
if fname.isEmpty():
return
ext = QFileInfo(fname).suffix()
if ext.isEmpty():
ex = selectedFilter.section('(*',1,1).section(')',0,0)
if not ex.isEmpty():
fname.append(ex)
if QFileInfo(fname).exists():
res = KQMessageBox.warning(self,
self.trUtf8("Save Diff"),
self.trUtf8("<p>The patch file <b>%1</b> already exists.</p>")
.arg(fname),
QMessageBox.StandardButtons(\
QMessageBox.Abort | \
QMessageBox.Save),
QMessageBox.Abort)
if res != QMessageBox.Save:
return
fname = unicode(Utilities.toNativeSeparators(fname))
try:
f = open(fname, "wb")
f.write(unicode(self.contents.toPlainText()))
f.close()
except IOError, why:
KQMessageBox.critical(self, self.trUtf8('Save Diff'),
self.trUtf8('<p>The patch file <b>%1</b> could not be saved.'
'<br>Reason: %2</p>')
.arg(unicode(fname)).arg(str(why)))
示例3: saveMultiProjectAs
# 需要导入模块: from KdeQt import KQFileDialog [as 别名]
# 或者: from KdeQt.KQFileDialog import getSaveFileName [as 别名]
def saveMultiProjectAs(self):
"""
Public slot to save the current multi project to a different file.
@return flag indicating success
"""
if Preferences.getProject("CompressedProjectFiles"):
selectedFilter = self.trUtf8("Compressed Multiproject Files (*.e4mz)")
else:
selectedFilter = self.trUtf8("Multiproject Files (*.e4m)")
if self.ppath:
defaultPath = self.ppath
else:
defaultPath = Preferences.getMultiProject("Workspace") or \
Utilities.getHomeDir()
fn = KQFileDialog.getSaveFileName(\
self.parent(),
self.trUtf8("Save multiproject as"),
defaultPath,
self.trUtf8("Multiproject Files (*.e4m);;"
"Compressed Multiproject Files (*.e4mz)"),
selectedFilter,
QFileDialog.Options(QFileDialog.DontConfirmOverwrite))
if not fn.isEmpty():
ext = QFileInfo(fn).suffix()
if ext.isEmpty():
ex = selectedFilter.section('(*', 1, 1).section(')', 0, 0)
if not ex.isEmpty():
fn.append(ex)
if QFileInfo(fn).exists():
res = KQMessageBox.warning(None,
self.trUtf8("Save File"),
self.trUtf8("""<p>The file <b>%1</b> already exists.</p>""")
.arg(fn),
QMessageBox.StandardButtons(\
QMessageBox.Abort | \
QMessageBox.Save),
QMessageBox.Abort)
if res != QMessageBox.Save:
return False
self.name = unicode(QFileInfo(fn).baseName())
ok = self.__writeMultiProject(unicode(fn))
self.emit(SIGNAL('multiProjectClosed'))
self.emit(SIGNAL('multiProjectOpened'))
return True
else:
return False
示例4: on_outputFileButton_clicked
# 需要导入模块: from KdeQt import KQFileDialog [as 别名]
# 或者: from KdeQt.KQFileDialog import getSaveFileName [as 别名]
def on_outputFileButton_clicked(self):
"""
Private slot to select the output file.
It displays a file selection dialog to
select the file the api is written to.
"""
filename = KQFileDialog.getSaveFileName(\
self,
self.trUtf8("Select output file"),
self.outputFileEdit.text(),
self.trUtf8("API files (*.api);;All files (*)"))
if not filename.isNull():
# make it relative, if it is in a subdirectory of the project path
fn = unicode(Utilities.toNativeSeparators(filename))
fn = self.project.getRelativePath(fn)
self.outputFileEdit.setText(fn)
示例5: exportBookmarks
# 需要导入模块: from KdeQt import KQFileDialog [as 别名]
# 或者: from KdeQt.KQFileDialog import getSaveFileName [as 别名]
def exportBookmarks(self):
"""
Public method to export the bookmarks.
"""
fileName = KQFileDialog.getSaveFileName(\
None,
self.trUtf8("Export Bookmarks"),
"eric4_bookmarks.xbel",
self.trUtf8("XBEL bookmarks").append(" (*.xbel *.xml)"))
if fileName.isEmpty():
return
writer = XbelWriter()
if not writer.write(fileName, self.__bookmarkRootNode):
KQMessageBox.critical(None,
self.trUtf8("Exporting Bookmarks"),
self.trUtf8("""Error exporting bookmarks to <b>%1</b>.""")\
.arg(fileName))
示例6: __export
# 需要导入模块: from KdeQt import KQFileDialog [as 别名]
# 或者: from KdeQt.KQFileDialog import getSaveFileName [as 别名]
def __export(self):
"""
Private slot to handle the Export context menu action.
"""
selectedFilter = QString("")
fn = KQFileDialog.getSaveFileName(\
self,
self.trUtf8("Export Templates"),
QString(),
self.trUtf8("Templates Files (*.e4c);; All Files (*)"),
selectedFilter,
QFileDialog.Options(QFileDialog.DontConfirmOverwrite))
if not fn.isEmpty():
ext = QFileInfo(fn).suffix()
if ext.isEmpty():
ex = selectedFilter.section('(*', 1, 1).section(')', 0, 0)
if not ex.isEmpty():
fn.append(ex)
self.writeTemplates(fn)
示例7: on_dirButton_clicked
# 需要导入模块: from KdeQt import KQFileDialog [as 别名]
# 或者: from KdeQt.KQFileDialog import getSaveFileName [as 别名]
def on_dirButton_clicked(self):
"""
Private slot to handle the button press for selecting the target via a
selection dialog.
"""
if os.path.isdir(self.source):
target = KQFileDialog.getExistingDirectory(\
None,
self.trUtf8("Select target"),
self.targetEdit.text(),
QFileDialog.Options(QFileDialog.ShowDirsOnly))
else:
target = KQFileDialog.getSaveFileName(\
None,
self.trUtf8("Select target"),
self.targetEdit.text(),
QString(),
None,
QFileDialog.Options(QFileDialog.DontConfirmOverwrite))
if not target.isEmpty():
self.targetEdit.setText(Utilities.toNativeSeparators(target))
示例8: on_saveButton_clicked
# 需要导入模块: from KdeQt import KQFileDialog [as 别名]
# 或者: from KdeQt.KQFileDialog import getSaveFileName [as 别名]
def on_saveButton_clicked(self):
"""
Private slot to save the regexp to a file.
"""
selectedFilter = QString("")
fname = KQFileDialog.getSaveFileName(\
self,
self.trUtf8("Save regular expression"),
QString(),
self.trUtf8("RegExp Files (*.rx);;All Files (*)"),
selectedFilter,
QFileDialog.Options(QFileDialog.DontConfirmOverwrite))
if not fname.isEmpty():
ext = QFileInfo(fname).suffix()
if ext.isEmpty():
ex = selectedFilter.section('(*', 1, 1).section(')', 0, 0)
if not ex.isEmpty():
fname.append(ex)
if QFileInfo(fname).exists():
res = KQMessageBox.warning(self,
self.trUtf8("Save regular expression"),
self.trUtf8("<p>The file <b>%1</b> already exists.</p>")
.arg(fname),
QMessageBox.StandardButtons(\
QMessageBox.Abort | \
QMessageBox.Save),
QMessageBox.Abort)
if res == QMessageBox.Abort or res == QMessageBox.Cancel:
return
try:
f=open(unicode(Utilities.toNativeSeparators(fname)), "wb")
f.write(unicode(self.regexpLineEdit.text()))
f.close()
except IOError, err:
KQMessageBox.information(self,
self.trUtf8("Save regular expression"),
self.trUtf8("""<p>The regular expression could not be saved.</p>"""
"""<p>Reason: %1</p>""").arg(str(err)))
示例9: __saveImage
# 需要导入模块: from KdeQt import KQFileDialog [as 别名]
# 或者: from KdeQt.KQFileDialog import getSaveFileName [as 别名]
def __saveImage(self):
"""
Private method to handle the save context menu entry.
"""
selectedFilter = QString('')
fname = KQFileDialog.getSaveFileName(\
self,
self.trUtf8("Save Diagram"),
QString(),
self.trUtf8("Portable Network Graphics (*.png);;"
"Scalable Vector Graphics (*.svg)"),
selectedFilter,
QFileDialog.Options(QFileDialog.DontConfirmOverwrite))
if not fname.isEmpty():
ext = QFileInfo(fname).suffix()
if ext.isEmpty():
ex = selectedFilter.section('(*',1,1).section(')',0,0)
if not ex.isEmpty():
fname.append(ex)
if QFileInfo(fname).exists():
res = KQMessageBox.warning(self,
self.trUtf8("Save Diagram"),
self.trUtf8("<p>The file <b>%1</b> already exists.</p>")
.arg(fname),
QMessageBox.StandardButtons(\
QMessageBox.Abort | \
QMessageBox.Save),
QMessageBox.Abort)
if res == QMessageBox.Abort or res == QMessageBox.Cancel:
return
success = self.saveImage(fname, QFileInfo(fname).suffix().toUpper())
if not success:
KQMessageBox.critical(None,
self.trUtf8("Save Diagram"),
self.trUtf8("""<p>The file <b>%1</b> could not be saved.</p>""")
.arg(fname))
示例10: __exportStyles
# 需要导入模块: from KdeQt import KQFileDialog [as 别名]
# 或者: from KdeQt.KQFileDialog import getSaveFileName [as 别名]
def __exportStyles(self, lexers):
"""
Private method to export the styles of the given lexers.
@param lexers list of lexer objects for which to export the styles
"""
selectedFilter = QString("")
fn = KQFileDialog.getSaveFileName(\
self,
self.trUtf8("Export Highlighting Styles"),
QString(),
self.trUtf8("eric4 highlighting styles file (*.e4h)"),
selectedFilter,
QFileDialog.Options(QFileDialog.DontConfirmOverwrite))
if fn.isEmpty():
return
ext = QFileInfo(fn).suffix()
if ext.isEmpty():
ex = selectedFilter.section('(*', 1, 1).section(')', 0, 0)
if not ex.isEmpty():
fn.append(ex)
fn = unicode(fn)
try:
f = open(fn, "wb")
HighlightingStylesWriter(f, lexers).writeXML()
f.close()
except IOError, err:
KQMessageBox.critical(self,
self.trUtf8("Export Highlighting Styles"),
self.trUtf8("""<p>The highlighting styles could not be exported"""
""" to file <b>%1</b>.</p><p>Reason: %2</p>""")\
.arg(fn)\
.arg(str(err))
)