dialog.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 
00003 import roslib
00004 roslib.load_manifest('cob_hardware_test')
00005 import sys
00006 import rospy
00007 import wx
00008 from cob_hardware_test.srv import *
00009 
00010 def handle_dialog(req):
00011     if req.type == 1:
00012             print "Asking: %s" % (req.message)
00013             ex = wx.App()
00014             dial = wx.MessageDialog(None, req.message, 'Question',
00015                             wx.YES_NO | wx.ICON_QUESTION)
00016             ret = dial.ShowModal()
00017             if ret == wx.ID_YES:
00018                     answer = True
00019             else:
00020                     answer = False
00021 
00022         #TODO exit properly
00023         #self.Destroy()
00024         #ex.Destroy()   
00025         #dial.Destroy()
00026             return DialogResponse(answer)
00027 
00028     if req.type == 0:
00029             print "Confirm: %s" % (req.message)
00030             ex = wx.App()
00031             dial = wx.MessageDialog(None, req.message, 'Confirm',
00032                             wx.OK | wx.ICON_WARNING)
00033             ret = dial.ShowModal()
00034             if ret == wx.ID_OK:
00035                     answer = True
00036             else:
00037                     answer = False
00038 
00039         #TODO exit properly
00040         #self.Destroy()
00041         #ex.Destroy()   
00042         #dial.Destroy()
00043             return DialogResponse(answer)
00044 
00045 
00046 
00047 def dialog_server():
00048         rospy.init_node('dialog_server')
00049         s = rospy.Service('dialog', Dialog, handle_dialog)
00050         print "Ready to ask(1) or confirm(0)!"
00051         rospy.spin()
00052 
00053 
00054 
00055 if __name__ == "__main__":
00056       dialog_server()
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends


cob_hardware_test
Author(s): Florian Weisshardt
autogenerated on Fri Mar 1 2013 18:00:26