本文整理汇总了Python中KdeQt.KQMessageBox类的典型用法代码示例。如果您正苦于以下问题:Python KQMessageBox类的具体用法?Python KQMessageBox怎么用?Python KQMessageBox使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了KQMessageBox类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: on_renameButton_clicked
def on_renameButton_clicked(self):
"""
Private slot to rename a custom toolbar.
"""
oldName = self.toolbarComboBox.currentText()
newName, ok = KQInputDialog.getText(\
self,
self.trUtf8("Rename Toolbar"),
self.trUtf8("New Toolbar Name:"),
QLineEdit.Normal,
oldName)
if ok and not newName.isEmpty():
if oldName == newName:
return
if self.toolbarComboBox.findText(newName) != -1:
# toolbar with this name already exists
KQMessageBox.critical(self,
self.trUtf8("Rename Toolbar"),
self.trUtf8("""A toolbar with the name <b>%1</b> already exists.""")\
.arg(newName),
QMessageBox.StandardButtons(\
QMessageBox.Abort))
return
index = self.toolbarComboBox.currentIndex()
self.toolbarComboBox.setItemText(index, newName)
tbItem = \
self.__toolbarItems[self.toolbarComboBox.itemData(index).toULongLong()[0]]
tbItem.title = newName
tbItem.isChanged = True
示例2: on_newButton_clicked
def on_newButton_clicked(self):
"""
Private slot to create a new toolbar.
"""
name, ok = KQInputDialog.getText(\
self,
self.trUtf8("New Toolbar"),
self.trUtf8("Toolbar Name:"),
QLineEdit.Normal)
if ok and not name.isEmpty():
if self.toolbarComboBox.findText(name) != -1:
# toolbar with this name already exists
KQMessageBox.critical(self,
self.trUtf8("New Toolbar"),
self.trUtf8("""A toolbar with the name <b>%1</b> already exists.""")\
.arg(name),
QMessageBox.StandardButtons(\
QMessageBox.Abort))
return
tbItem = E4ToolBarItem(None, [], False)
tbItem.title = name
tbItem.isChanged = True
self.__toolbarItems[id(tbItem)] = tbItem
self.__toolBarItemToWidgetActionID[id(tbItem)] = []
self.toolbarComboBox.addItem(name, QVariant(long(id(tbItem))))
self.toolbarComboBox.model().sort(0)
self.toolbarComboBox.setCurrentIndex(self.toolbarComboBox.findText(name))
示例3: __writeXMLMultiProject
def __writeXMLMultiProject(self, fn = None):
"""
Private method to write the multi project data to an XML file.
@param fn the filename of the multi project file (string)
"""
try:
if fn.lower().endswith("e4mz"):
try:
import gzip
except ImportError:
KQMessageBox.critical(None,
self.trUtf8("Save multiproject file"),
self.trUtf8("""Compressed multiproject files not supported."""
""" The compression library is missing."""))
return False
f = gzip.open(fn, "wb")
else:
f = open(fn, "wb")
MultiProjectWriter(self, f, os.path.splitext(os.path.basename(fn))[0])\
.writeXML()
f.close()
except IOError:
KQMessageBox.critical(None,
self.trUtf8("Save multiproject file"),
self.trUtf8("<p>The multiproject file <b>%1</b> could not be "
"written.</p>").arg(fn))
return False
return True
示例4: start
def start(self, pfn, fn=None):
"""
Public slot to start the calculation of the profile data.
@param pfn basename of the profiling file (string)
@param fn file to display the profiling data for (string)
"""
self.basename = os.path.splitext(pfn)[0]
fname = "%s.profile" % self.basename
if not os.path.exists(fname):
KQMessageBox.warning(None,
self.trUtf8("Profile Results"),
self.trUtf8("""<p>There is no profiling data"""
""" available for <b>%1</b>.</p>""")
.arg(pfn))
self.close()
return
try:
f = open(fname, 'rb')
self.stats = pickle.load(f)
f.close()
except (EnvironmentError, pickle.PickleError, EOFError):
KQMessageBox.critical(None,
self.trUtf8("Loading Profiling Data"),
self.trUtf8("""<p>The profiling data could not be"""
""" read from file <b>%1</b>.</p>""")
.arg(fname))
self.close()
return
self.file = fn
self.__populateLists()
self.__finish()
示例5: __checkPluginsDownloadDirectory
def __checkPluginsDownloadDirectory(self):
"""
Private slot to check for the existance of the plugins download directory.
"""
downloadDir = unicode(Preferences.getPluginManager("DownloadPath"))
if not downloadDir:
downloadDir = self.__defaultDownloadDir
if not os.path.exists(downloadDir):
try:
os.mkdir(downloadDir, 0755)
except (OSError, IOError), err:
# try again with (possibly) new default
downloadDir = self.__defaultDownloadDir
if not os.path.exists(downloadDir):
try:
os.mkdir(downloadDir, 0755)
except (OSError, IOError), err:
KQMessageBox.critical(self.__ui,
self.trUtf8("Plugin Manager Error"),
self.trUtf8("""<p>The plugin download directory <b>%1</b> """
"""could not be created. Please configure it """
"""via the configuration dialog.</p>"""
"""<p>Reason: %2</p>""")\
.arg(downloadDir).arg(str(err)))
downloadDir = ""
示例6: on_namedReferenceButton_clicked
def on_namedReferenceButton_clicked(self):
"""
Private slot to handle the named reference toolbutton.
"""
# determine cursor position as length into text
length = self.regexpTextEdit.textCursor().position()
# only present group names that occur before the current cursor position
regex = unicode(self.regexpTextEdit.toPlainText().left(length))
names = self.namedGroups(regex)
if not names:
KQMessageBox.information(None,
self.trUtf8("Named reference"),
self.trUtf8("""No named groups have been defined yet."""))
return
qs = QStringList()
for name in names:
qs.append(name)
groupName, ok = KQInputDialog.getItem(\
None,
self.trUtf8("Named reference"),
self.trUtf8("Select group name:"),
qs,
0, True)
if ok and not groupName.isEmpty():
self.__insertString("(?P=%s)" % groupName)
示例7: __findDuplicates
def __findDuplicates(self, cond, special, showMessage = False, index = QModelIndex()):
"""
Private method to check, if an entry already exists.
@param cond condition to check (string or QString)
@param special special condition to check (string or QString)
@param showMessage flag indicating a message should be shown,
if a duplicate entry is found (boolean)
@param index index that should not be considered duplicate (QModelIndex)
@return flag indicating a duplicate entry (boolean)
"""
cond = unicode(cond)
special = unicode(special)
idx = self.__model.getWatchPointIndex(cond, special)
duplicate = idx.isValid() and idx.internalPointer() != index.internalPointer()
if showMessage and duplicate:
if not special:
msg = self.trUtf8("""<p>A watch expression '<b>%1</b>'"""
""" already exists.</p>""")\
.arg(Utilities.html_encode(unicode(cond)))
else:
msg = self.trUtf8("""<p>A watch expression '<b>%1</b>'"""
""" for the variable <b>%2</b> already exists.</p>""")\
.arg(special)\
.arg(Utilities.html_encode(unicode(cond)))
KQMessageBox.warning(None,
self.trUtf8("Watch expression already exists"),
msg)
return duplicate
示例8: __init__
def __init__(self, parent = None):
"""
Constructor
@param parent reference to the parent widget (QWidget)
"""
QWidget.__init__(self, parent)
self.setupUi(self)
self.table.addAction(self.insertRowAction)
self.table.addAction(self.deleteRowAction)
if QSqlDatabase.drivers().isEmpty():
KQMessageBox.information(None,
self.trUtf8("No database drivers found"),
self.trUtf8("""This tool requires at least one Qt database driver. """
"""Please check the Qt documentation how to build the """
"""Qt SQL plugins."""))
self.connect(self.connections, SIGNAL("tableActivated(QString)"),
self.on_connections_tableActivated)
self.connect(self.connections, SIGNAL("schemaRequested(QString)"),
self.on_connections_schemaRequested)
self.connect(self.connections, SIGNAL("cleared()"),
self.on_connections_cleared)
self.emit(SIGNAL("statusMessage(QString)"), self.trUtf8("Ready"))
示例9: __importStyles
def __importStyles(self, lexers):
"""
Private method to import the styles of the given lexers.
@param lexers dictionary of lexer objects for which to import the styles
"""
fn = KQFileDialog.getOpenFileName(\
self,
self.trUtf8("Import Highlighting Styles"),
QString(),
self.trUtf8("eric4 highlighting styles file (*.e4h)"),
None)
if fn.isEmpty():
return
fn = unicode(fn)
try:
f = open(fn, "rb")
try:
line = f.readline()
dtdLine = f.readline()
finally:
f.close()
except IOError, err:
KQMessageBox.critical(self,
self.trUtf8("Import Highlighting Styles"),
self.trUtf8("""<p>The highlighting styles could not be read"""
""" from file <b>%1</b>.</p><p>Reason: %2</p>""")\
.arg(fn)\
.arg(str(err))
)
return
示例10: __generateTSFileDone
def __generateTSFileDone(self, exitCode, exitStatus):
"""
Private slot to handle the finished signal of the pylupdate process.
@param exitCode exit code of the process (integer)
@param exitStatus exit status of the process (QProcess.ExitStatus)
"""
if exitStatus == QProcess.NormalExit and exitCode == 0:
KQMessageBox.information(None,
self.trUtf8("Translation file generation"),
self.trUtf8("The generation of the translation files (*.ts)"
" was successful."))
else:
KQMessageBox.critical(None,
self.trUtf8("Translation file generation"),
self.trUtf8("The generation of the translation files (*.ts) has failed."))
proc = self.sender()
for index in range(len(self.__pylupdateProcesses)):
if proc == self.__pylupdateProcesses[index][0]:
try:
os.remove(self.__pylupdateProcesses[index][1])
except EnvironmentError:
pass
del self.__pylupdateProcesses[index]
break
if not self.__pylupdateProcesses:
# all done
self.pylupdateProcRunning = False
示例11: findPrev
def findPrev(self):
"""
Public slot to find the next previous of text.
"""
if not self.havefound or self.ui.findtextCombo.currentText().isEmpty():
self.show(self.viewmanager.textForFind())
return
self.__findBackwards = True
txt = self.ui.findtextCombo.currentText()
# This moves any previous occurrence of this statement to the head
# of the list and updates the combobox
self.findHistory.removeAll(txt)
self.findHistory.prepend(txt)
self.ui.findtextCombo.clear()
self.ui.findtextCombo.addItems(self.findHistory)
self.emit(SIGNAL('searchListChanged'))
ok = self.__findNextPrev(txt, True)
if ok:
if self.replace:
self.ui.replaceButton.setEnabled(True)
self.ui.replaceSearchButton.setEnabled(True)
else:
KQMessageBox.information(self, self.windowTitle(),
self.trUtf8("'%1' was not found.").arg(txt))
示例12: on_changeButton_clicked
def on_changeButton_clicked(self):
"""
Private slot to change an entry.
"""
row = self.groupsList.currentRow()
if row < 0:
return
groupName = self.nameEdit.text()
if groupName.isEmpty():
KQMessageBox.critical(self,
self.trUtf8("Add tool group entry"),
self.trUtf8("You have to give a name for the group to add."))
return
if len(self.groupsList.findItems(groupName, Qt.MatchFlags(Qt.MatchExactly))):
KQMessageBox.critical(self,
self.trUtf8("Add tool group entry"),
self.trUtf8("An entry for the group name %1 already exists.")\
.arg(groupName))
return
self.toolGroups[row][0] = unicode(groupName)
self.groupsList.currentItem().setText(groupName)
示例13: on_saveButton_clicked
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)))
示例14: _selectEntries
def _selectEntries(self, local = True, filter = None):
"""
Protected method to select entries based on their VCS status.
@param local flag indicating local (i.e. non VCS controlled) file/directory
entries should be selected (boolean)
@param filter list of classes to check against
"""
if self.project.vcs is None:
return
if local:
compareString = QApplication.translate('ProjectBaseBrowser', "local")
else:
compareString = QString(self.project.vcs.vcsName())
# expand all directories in order to iterate over all entries
self._expandAllDirs()
QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
QApplication.processEvents()
self.selectionModel().clear()
QApplication.processEvents()
# now iterate over all entries
startIndex = None
endIndex = None
selectedEntries = 0
index = self.model().index(0, 0)
while index.isValid():
itm = self.model().item(index)
if self.wantedItem(itm, filter) and \
QString.compare(compareString, itm.data(1)) == 0:
if startIndex is not None and \
startIndex.parent() != index.parent():
self._setItemRangeSelected(startIndex, endIndex, True)
startIndex = None
selectedEntries += 1
if startIndex is None:
startIndex = index
endIndex = index
else:
if startIndex is not None:
self._setItemRangeSelected(startIndex, endIndex, True)
startIndex = None
index = self.indexBelow(index)
if startIndex is not None:
self._setItemRangeSelected(startIndex, endIndex, True)
QApplication.restoreOverrideCursor()
QApplication.processEvents()
if selectedEntries == 0:
KQMessageBox.information(None,
QApplication.translate('ProjectBaseBrowser', "Select entries"),
QApplication.translate('ProjectBaseBrowser',
"""There were no matching entries found."""))
示例15: on_deleteButton_clicked
def on_deleteButton_clicked(self):
"""
Private slot to delete the selected search engines.
"""
if self.enginesTable.model().rowCount() == 1:
KQMessageBox.critical(self,
self.trUtf8("Delete selected engines"),
self.trUtf8("""You must have at least one search engine."""))
self.enginesTable.removeSelected()