How to write a simple Python Qt dialog on ROS Service?
I want to write a ROS Service that receives a Question and then shows a Qt Pop-up Dialog with the Question and a yes or no Button. The service should return the Answer as a Boolean. I have it with wx but since it is depreciated in ROS, I want to use Qt now. This is how it looked like with wx:
rospy.init_node('dialog_server') s = rospy.Service('dialog', Dialog, self.handle_dialog) rospy.spin() def handle_dialog(self, req): ex = wx.App() dial = wx.MessageDialog(None, req.message, 'Question', wx.YES_NO | wx.ICON_QUESTION) ret = dial.ShowModal() if ret == wx.ID_YES: answer = True else: answer = False return DialogResponse(answer)
I tried simply replacing wx with the equivalent qt (like wx.MessageDialog -> QtGui.QMessageBox.question) but it's not working because ros is another Thread. Error: "It is not safe to use pixmaps outside the GUI thread". I am not familiar with Qt, rqt python_qt_binding and plug-ins at all.
What do I need to achieve this? Do I have to use Slots and Signals between GUI and ROS, or even write it as a plug-in? How should it look like?