Go to the documentation of this file.00001 '''
00002 Created on Sep 10, 2013
00003 \todo Add license information here
00004 @author: dnad
00005 '''
00006 import os
00007
00008 from qt_gui.plugin import Plugin
00009 from python_qt_binding import loadUi, QtCore
00010
00011 class RqtPluginMeta(Plugin):
00012 def __init__(self,
00013 context,
00014 name,
00015 GuiT,
00016 RosT,
00017 resource = ""
00018 ):
00019 super(RqtPluginMeta, self).__init__(context)
00020
00021 self.setObjectName(name)
00022
00023 if resource == "": resource=_resource(name, file)
00024
00025 from argparse import ArgumentParser
00026 parser = ArgumentParser()
00027
00028 parser.add_argument("-q", "--quiet", action="store_true",
00029 dest="quiet",
00030 help="Put plugin in silent mode")
00031 args, unknowns = parser.parse_known_args(context.argv())
00032 if not args.quiet:
00033 print "arguments: ", args
00034 print "unknowns: ", unknowns
00035
00036
00037 self._gui = GuiT()
00038 self._ros = RosT()
00039
00040
00041 loadUi(resource, self._gui)
00042
00043 self._ros.setup(self._gui)
00044 self._gui.setup(name + "Rqt", self._ros)
00045
00046
00047
00048
00049
00050
00051 if context.serial_number() > 1:
00052 self._widget.setWindowTitle(self._widget.windowTitle() +
00053 (" (%d)" % context.serial_number()))
00054
00055 context.add_widget(self._gui)
00056
00057 def shutdown_plugin(self):
00058
00059 self._gui.unload();
00060 self._ros.unload()
00061 pass
00062
00063 def save_settings(self, plugin_settings, instance_settings):
00064
00065
00066 pass
00067
00068 def restore_settings(self, plugin_settings, instance_settings):
00069
00070
00071 pass
00072
00073
00074
00075
00076
00077
00078 def _resource(name):
00079 return os.path.join(os.path.dirname(
00080 os.path.realpath(__file__)),
00081 "resource", name+".ui")
00082
00083 def resource_rpath(name, file):
00084 return os.path.join(os.path.dirname(
00085 os.path.realpath(file)),
00086 "resource/" + name + ".ui")
00087
00088 def launch_standalone(name,
00089 GuiT,
00090 RosT,
00091 resource = ""):
00092 import rospy, os, sys
00093 import python_qt_binding as pyqt
00094 from python_qt_binding import QtGui
00095 app = QtGui.QApplication(sys.argv)
00096 rospy.init_node(name, sys.argv)
00097 gui = GuiT()
00098 ros = RosT()
00099
00100 if resource == "":
00101 resource = _resource(name)
00102
00103 pyqt.loadUi(resource, gui)
00104
00105 ros.setup(gui)
00106 gui.setup(name, ros)
00107
00108 gui.show()
00109
00110 sys.exit(app.exec_())