def _showWarning(self, title, body): if threading.current_thread().name != "MainThread": rospy.logwarn("{}: {}".format(title, body)) else: msg = QMessageBox() msg.setIcon(QMessageBox.Warning) msg.setWindowTitle(title) msg.setText(body) msg.setStandardButtons(QMessageBox.Ok) msg.exec_()
def dasherr(msg, obj, title='Error'): """ Logs a message with ``rospy.logerr`` and displays a ``QMessageBox`` to the user :param msg: Message to display. :type msg: str :param obj: Parent object for the ``QMessageBox`` :type obj: QObject :param title: An optional title for the `QMessageBox`` :type title: str """ rospy.logerr(msg) box = QMessageBox() box.setText(msg) box.setWindowTitle(title) box.show() obj._message_box = box