python 3.x - How do I create a critical error message using PySide? -


i seem hitting brick wall. no matter do, creating critical error message box doesn't seem working. here's i've tried far:

flags = qtgui.qmessagebox.standardbutton.abort flags |= qtgui.qmessagebox.standardbutton.ignore  result = qtgui.qmessagebox.critical(     self,     'critical error',     'error message',     flags     ) 

as taken this tutorial (old know, it's been helpful far). doing however, brings following error:

'pyside.qtgui.qmessagebox.critical' called wrong argument types:

pyside.qtgui.qmessagebox.critical(createmessage, str, standardbuttons)

supported signatures:

pyside.qtgui.qmessagebox.critical(pyside.qtgui.qwidget, unicode, unicode, pyside.qtgui.qmessagebox.standardbuttons = qmessagebox.ok, pyside.qtgui.qmessagebox.standardbutton = nobutton)

pyside.qtgui.qmessagebox.critical(pyside.qtgui.qwidget, unicode, unicode, pyside.qtgui.qmessagebox.standardbutton, pyside.qtgui.qmessagebox.standardbutton)

i've tried following:

result = qtgui.qmessagebox.critical(     self,     'critical error',     'error message',     qtgui.qmessagebox.standardbutton.abort     )  # or this....  result = qtgui.qmessagebox.critical(     self,     'critical error',      'error message',     qtgui.qmessagebox.abort     ) 

none of these seem work properly. how create critical error message box?

here's example qt.gitorious.

from pyside import qtgui, qtcore import sys  class dialog(qtgui.qdialog):     message = qtcore.qt_tr_noop("<p>message boxes have caption, text, , "                                 "three buttons, each standard or custom texts.</p>"                                 "<p>click button or press esc.</p>")      def __init__(self, parent=none):         qtgui.qdialog.__init__(self, parent)         self.criticallabel = qtgui.qlabel()         self.criticallabel.setframestyle(qtgui.qframe.sunken | qtgui.qframe.panel)         self.criticalbutton = qtgui.qpushbutton(self.tr("qmessagebox.critica&l()"))          layout = qtgui.qgridlayout()         layout.addwidget(self.criticalbutton, 10, 0)         layout.addwidget(self.criticallabel, 10, 1)         self.setlayout(layout)          self.connect(self.criticalbutton, qtcore.signal("clicked()"), self.criticalmessage)       def criticalmessage(self):             reply = qtgui.qmessagebox.critical(self, self.tr("qmessagebox.showcritical()"),                                                dialog.message, qtgui.qmessagebox.abort|                                                qtgui.qmessagebox.standardbutton.retry|                                                qtgui.qmessagebox.standardbutton.ignore)         if reply == qtgui.qmessagebox.abort:             self.criticallabel.settext(self.tr("abort"))         elif reply == qtgui.qmessagebox.retry:             self.criticallabel.settext(self.tr("retry"))         else:             self.criticallabel.settext(self.tr("ignore"))  if __name__ == '__main__':       app = qtgui.qapplication(sys.argv)     dialog = dialog()     sys.exit(dialog.exec_())         

to answer question you can check documentation:

static pyside.qtgui.qmessagebox.critical(parent, title, text[, buttons=qmessagebox.ok[, defaultbutton=nobutton]]) 

in example, parent = self, title = self.tr("qmessagebox.showcritical()"), text = dialog.message, buttons = qtgui.qmessagebox.abort | qtgui.qmessagebox.standardbutton.retry | qtgui.qmessagebox.standardbutton.ignore

the tr qt function set translations, string. can't tell did wrong, looking @ error message, seems have parsed things wrong. possibly because of way assigned values flags.

the example shows how deal result of critical dialog, seems useful.


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -