def cb(code):
            if timer:
                timer.stop()
            dialog.accept()
            if isinstance(code, Exception):
                QtGui.QMessageBox.warning(window, m.error,
                                          code.message)
            else:
                self.code = code