本文整理匯總了Python中PyQt5.Qt.QMessageBox類的典型用法代碼示例。如果您正苦於以下問題:Python QMessageBox類的具體用法?Python QMessageBox怎麽用?Python QMessageBox使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了QMessageBox類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: saveXML
def saveXML(self):
if len(self.tools.framemenu.getAllFrames()) > 1:
result = QFileDialog.getSaveFileName(self, 'Choose the destination for the animation file!', '.', 'Animation File (*.armo)')
if result[0] != "":
XML().toXML(self.tools.framemenu.getAllFrames(), result[0])
else:
QMessageBox.information(self, "Stickman Message", "You need at least 2 frames to save the animation!")
示例2: importGraph
def importGraph(self, text):
'''Init text after an import.
Argument(s):
text (str): Textual representation of the graph
'''
self.acceptUpdate = False
self.setPlainText(text)
pydotGraph = graph_from_dot_data(text)
# Check that attributes are in valid form
message = self.checkItemsAttributes(pydotGraph.get_nodes(),
pydotGraph.get_edges())
if not message:
self.rebuildTextModel(text, pydotGraph)
# Send every elements to the model to build him
for id, args in self.nodes.items():
self.controller.onCreateNode(id, args)
for id, args in self.edges.items():
self.controller.onCreateEdge(args[EdgeArgs.sourceId],
args[EdgeArgs.destId])
# Some attributes are in invalid form
else:
QMessageBox.warning(self, "Syntax error", message)
self.acceptUpdate = True
示例3: QuestionDialog
def QuestionDialog(title, text, info = None, dontAsk = False):
msgBox = QMessageBox()
buttonYes = msgBox.addButton(_("Yes"), QMessageBox.ActionRole)
buttonNo = msgBox.addButton(_("No"), QMessageBox.ActionRole)
answers = {buttonYes:"yes",
buttonNo :"no"}
if dontAsk:
buttonDontAsk = msgBox.addButton(_("Don't ask again"), QMessageBox.ActionRole)
answers[buttonDontAsk] = "dontask"
msgBox.setText(text)
if not info:
info = _("Do you want to continue?")
msgBox.setInformativeText(info)
dialog = Dialog(_(title), msgBox, closeButton = False, isDialog = True, icon="question")
dialog.resize(300,120)
dialog.exec_()
ctx.mainScreen.processEvents()
if msgBox.clickedButton() in answers.keys():
return answers[msgBox.clickedButton()]
return "no"
示例4: _validate_monkeys
def _validate_monkeys(self):
first_month = Monkey.unslash(self.ui.firstMonthEdit.text())
last_month = Monkey.unslash(self.ui.lastMonthEdit.text())
if not Monkey.is_valid_pair(first_month, last_month):
msg = 'Invalid time frame: invalid month or first month after last month!'
QMessageBox.critical(QMessageBox(), 'Input Error', msg)
self.ui.firstMonthEdit.setFocus()
return None
return TimeInterval(first_month=first_month, last_month=last_month)
示例5: fromXML
def fromXML(self):
file = QFileDialog.getOpenFileName(self, "Load Animation", ".", "Animation Files (*.armo)")
if file[0] != "":
try:
frames = XML().fromXML(file[0])
self.tools.framemenu.removeAllFrames()
for frame in frames:
self.tools.framemenu.addNewFrame(frame)
if len(frames) > 0:
getWorld().setWorldFrom(frames[0])
except:
QMessageBox.information(self, "Stickman Message", "The animation file is not valid!")
示例6: _save_clicked
def _save_clicked(self):
rec = self._valid_emp()
if rec:
try:
rec.save()
except AllocatException as e:
QMessageBox.critical(QMessageBox(), 'Input Error', e.msg)
self.ui.nameEdit.setFocus()
return
Dataset.employees = Employee.get_all()
self._load_list(Dataset.employees.keys(), rec.name)
self.ui.addBtn.setEnabled(True)
示例7: show_warning
def show_warning(text):
"""
Shows a simple warning with given text.
"""
msg_box = QMessageBox()
msg_box.setText(text)
msg_box.setStandardButtons(QMessageBox.Ok)
msg_box.setDefaultButton(QMessageBox.Ok)
msg_box.exec()
示例8: about
def about(self):
# Get the about text from a file inside the plugin zip file
# The get_resources function is a builtin function defined for all your
# plugin code. It loads files from the plugin zip file. It returns
# the bytes from the specified file.
#
# Note that if you are loading more than one file, for performance, you
# should pass a list of names to get_resources. In this case,
# get_resources will return a dictionary mapping names to bytes. Names that
# are not found in the zip file will not be in the returned dictionary.
text = get_resources('about.txt')
QMessageBox.about(self, 'About the Interface Plugin Demo',
text.decode('utf-8'))
示例9: msgbox
def msgbox(cls, typename, text, button0, button1=None, button2=None, title=None, form=None):
if form:
logger.warn("MessageBox: Se intentó usar form, y no está implementado.")
icon = QMessageBox.NoIcon
if not title:
title = "Pineboo"
if typename == "question":
icon = QMessageBox.Question
if not title:
title = "Question"
elif typename == "information":
icon = QMessageBox.Information
if not title:
title = "Information"
elif typename == "warning":
icon = QMessageBox.Warning
if not title:
title = "Warning"
elif typename == "critical":
icon = QMessageBox.Critical
if not title:
title = "Critical"
# title = unicode(title,"UTF-8")
# text = unicode(text,"UTF-8")
msg = QMessageBox(icon, title, text)
msg.addButton(button0)
if button1:
msg.addButton(button1)
if button2:
msg.addButton(button2)
return msg.exec_()
示例10: makeDatabase
def makeDatabase(self):
'''Runs recollindex outside calibre like in a terminal.
Look for recollindex for more information about the flags and options'''
self.cmd = [prefs['pathToRecoll'] + '/recollindex', '-c', prefs['pathToCofig'] + '/plugins/recollFullTextSearchPlugin']
#TODO: Fix for Linux
#self.cmd = 'LD_LIBRARY_PATH="" ' + prefs['pathToRecoll'] + '/recollindex -c ' + prefs['pathToCofig'] + '/plugins/recollFullTextSearchPlugin'
if self.replaceDatabase == True :
self.cmd += [' -z']
self.p = Popen(self.cmd, shell=False)
# TODO: Was close_fds nessesary? check it on linux
#self.p = Popen(self.cmd, shell=True, stdin=PIPE, stdout=PIPE, stderr=STDOUT, close_fds=True)
box = QMessageBox()
box.about(self, 'Please read! \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t','Depending on you library size this operation can take a lot of time.\nThe process runs outside calibre so you can use or close it, but do not use this plugin.\nFor now there is no information about when recoll finishs,\nso look up, whether a recoll of recollindex process is running on you system.')
示例11: buttonExportClicked
def buttonExportClicked(self):
(filePaths, filter) = QFileDialog.getOpenFileNames(
parent=self,
caption="轉換數據庫文件為文本格式",
directory=QApplication.applicationDirPath() + "/../data",
filter="Database file (*.db * mdb)",
)
if not filePaths:
return
#
if DatabaseMgr().convertToText(filePaths):
QMessageBox.information(self, "格式轉換", "轉換成功!")
else:
QMessageBox.warning(self, "格式轉換", "轉換失敗!")
示例12: InfoDialog
def InfoDialog(text, button=None, title=None, icon="info"):
if not title:
title = _("Information")
if not button:
button = _("OK")
msgBox = QMessageBox()
buttonOk = msgBox.addButton(button, QMessageBox.ActionRole)
msgBox.setText(text)
dialog = Dialog(_(title), msgBox, closeButton = False, isDialog = True, icon = icon)
dialog.resize(300,120)
dialog.exec_()
ctx.mainScreen.processEvents()
示例13: show_font_face_rule_for_font_file
def show_font_face_rule_for_font_file(file_data, added_name, parent=None):
try:
fm = FontMetadata(BytesIO(file_data)).to_dict()
except UnsupportedFont:
return
pp = _('Change this to the relative path to: %s') % added_name
rule = '''@font-face {{
src: url({pp});
font-family: "{ff}";
font-weight: {w};
font-style: {sy};
font-stretch: {st};
}}'''.format(pp=pp, ff=fm['font-family'], w=fm['font-weight'], sy=fm['font-style'], st=fm['font-stretch'])
QApplication.clipboard().setText(rule)
QMessageBox.information(parent, _('Font file added'), _(
'The font file <b>{}</b> has been added. The text for the CSS @font-face rule for this file has been copied'
' to the clipboard. You should paste it into whichever CSS file you want to add this font to.').format(added_name))
示例14: _monkey_clicked
def _monkey_clicked(self, row, col):
employee = self.tbl.item(row, 0).text()
monkey = self.monkeys[col - 2]
hdr = '%s\n%s' % (employee, Monkey.prettify(monkey))
lines = []
total = 0
for asn in self.efforts[employee].assignments:
interval = TimeInterval(
first_month=asn.first_month,
last_month=asn.last_month
)
asn_monkeys = Monkey.monkey_list(interval)
if monkey in asn_monkeys:
lines.append('%s: %d' % (asn.project_name, asn.effort))
total += asn.effort
msg = hdr + '\n\n' + '\n'.join(lines) + ('\n\nTotal: %d' % total)
QMessageBox.information(QMessageBox(), 'Effort Breakdown', msg)
示例15: _remove_clicked
def _remove_clicked(self):
nickname = self.ui.nicknameEdit.text()
msg = 'Are you sure you want to remove project ' + nickname + '?'
reply = QMessageBox.question(QMessageBox(), 'Double check', msg)
if reply == QMessageBox.Yes:
rec = Dataset.projects[nickname]
rec.remove()
del Dataset.projects[nickname]
self._load_list(Dataset.projects.keys())