emonitor_rqt.py
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 from emonitor_gui import EMonitorGui
00011 from emonitor_rqt import EMonitorRqt
00012 
00013 class EMonitorRqt(Plugin):
00014 
00015     def __init__(self, context):
00016         super(EMonitorRqt, self).__init__(context)
00017         # Give QObjects reasonable names
00018         self.setObjectName('EMonitorRqt')
00019 
00020         # Process standalone plugin command-line arguments
00021         from argparse import ArgumentParser
00022         parser = ArgumentParser()
00023         # Add argument(s) to the parser.
00024         parser.add_argument("-q", "--quiet", action="store_true",
00025                       dest="quiet",
00026                       help="Put plugin in silent mode")
00027         args, unknowns = parser.parse_known_args(context.argv())
00028         if not args.quiet:
00029             print 'arguments: ', args
00030             print 'unknowns: ', unknowns
00031 
00032         # Create QWidget
00033         self._gui = EMonitorGUI()
00034         self._ros = EMonitorROS()
00035         # Get path to UI file which is a sibling of this file
00036         # in this example the .ui and .py file are in the same folder
00037         ui_file = os.path.join(os.path.dirname(
00038                         os.path.realpath(__file__)), 'resource/EMonitor.ui')
00039         # Extend the widget with all attributes and children from UI file
00040         loadUi(ui_file, self._gui)
00041         # Give QObjects reasonable names
00042         self._ros.setup()
00043         self._gui.setup("EMonitorRqt", self._ros)
00044         
00045         # Show _widget.windowTitle on left-top of each plugin (when 
00046         # it's set in _widget). This is useful when you open multiple 
00047         # plugins at once. Also if you open multiple instances of your 
00048         # plugin at once, these lines add number to make it easy to 
00049         # tell from pane to pane.
00050         if context.serial_number() > 1:
00051             self._widget.setWindowTitle(self._widget.windowTitle() + 
00052                                         (' (%d)' % context.serial_number()))
00053         # Add widget to the user interface
00054         context.add_widget(self._gui._widget)      
00055 
00056     def shutdown_plugin(self):
00057         # TODO unregister all publishers here
00058         self._gui.unload();
00059         self._ros.unload()
00060         pass
00061 
00062     def save_settings(self, plugin_settings, instance_settings):
00063         # TODO save intrinsic configuration, usually using:
00064         # instance_settings.set_value(k, v)
00065         pass
00066 
00067     def restore_settings(self, plugin_settings, instance_settings):
00068         # TODO restore intrinsic configuration, usually using:
00069         # v = instance_settings.value(k)
00070         pass
00071 
00072     #def trigger_configuration(self):
00073         # Comment in to signal that the plugin has a way to configure
00074         # This will enable a setting button (gear icon) in each dock widget title bar
00075         # Usually used to open a modal configuration dialog


labust_gui
Author(s): Gyula Nagy
autogenerated on Fri Feb 7 2014 11:36:55