[PyKDE] QMessageBox
Boudewijn Rempt
boud at rempt.xs4all.nl
Mon Oct 18 18:25:27 BST 1999
On 18 Oct 1999, Pete Ware wrote:
> The docs say it is full implemented but in examples/application.py I get:
>
> Traceback (innermost last):
> File "./application.py", line 175, in saveDoc
> QMessageBox.message('Note', 'Left as an exercise for the user.')
> AttributeError: message
>
> And in my own where I use "QMessageBox.warning" I get the following
> errors (all variations on parameters passed to warning()). Any idea's
> what is going wrong?
>
Well, first of all, QMessageBox hasn't got a member 'message' - that's
KMsgBox, so I guess this is a type in QApplication. QMessageBox has
warning, information and critical - besides being able to constructed
beforehand and then exec_looped.
If I try
QMessageBox.critical(self, 'Note', 'Left as an exercise for the user.')
QMessageBox.warning(self, 'Note', 'Left as an exercise for the user.')
QMessageBox.information(self, 'Note', 'Left as an exercise for the user.')
everything works fine. So, let's look at your errors:
>
> Traceback (innermost last):
> File "App.py", line 301, in ?
> warning ('what a title', 'testing the warning')
> File "App.py", line 22, in warning
> qt.QMessageBox.warning (title, mess)
> TypeError: Invalid argument types to QMessageBox.warning()
>
You need to give a parent in QMessageBox, I think.
> Traceback (innermost last):
> File "App.py", line 301, in ?
> warning ('what a title', 'testing the warning')
> File "App.py", line 22, in warning
> qt.QMessageBox.warning (ThisApp.parent, title, mess, qt.QMessageBox.Ok|qt.QMessageBox.Default)
>
You give ThisApp - I don't know where it's coming from, but when you
show the msgbox from the main windows (QMainWindow), it's enough to
pass self.
> Traceback (innermost last):
> File "App.py", line 301, in ?
> warning ('what a title', 'testing the warning')
> File "App.py", line 22, in warning
> qt.QMessageBox.warning ('hi', 'mess', qt.QMessageBox.Ok|qt.QMessageBox.Default)
> TypeError: Invalid argument types to QMessageBox.warning()
>
Again, no parent.
Well, lots of luck with the rest of your app!
Boudewijn Rempt | http://www.xs4all.nl/~bsarempt
More information about the PyQt
mailing list