コード例 #1
0
ファイル: caddy_plug.py プロジェクト: pi19404/labust-ros-pkg
    def __init__(self, context):
        super(CaddyGuiPlug, self).__init__(context)
        # Give QObjects reasonable names
        self.setObjectName('CaddyGuiPlug')

        # Process standalone plugin command-line arguments
        from argparse import ArgumentParser
        parser = ArgumentParser()
        # Add argument(s) to the parser.
        parser.add_argument("-q", "--quiet", action="store_true",
                      dest="quiet",
                      help="Put plugin in silent mode")
        args, unknowns = parser.parse_known_args(context.argv())
        if not args.quiet:
            print 'arguments: ', args
            print 'unknowns: ', unknowns

        # Create QWidget
        self._gui = CaddyGui()
        self._ros = CaddyGuiROS(self._gui)
        # Get path to UI file which is a sibling of this file
        # in this example the .ui and .py file are in the same folder
        ui_file = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'resource/CaddyGui.ui')
        # Extend the widget with all attributes and children from UI file
        loadUi(ui_file, self._gui._widget)
        # Give QObjects reasonable names
        self._gui._widget.setObjectName('CaddyGui')
        self._gui.setup()
        self._ros.setup()
        
        # Show _widget.windowTitle on left-top of each plugin (when 
        # it's set in _widget). This is useful when you open multiple 
        # plugins at once. Also if you open multiple instances of your 
        # plugin at once, these lines add number to make it easy to 
        # tell from pane to pane.
        if context.serial_number() > 1:
            self._widget.setWindowTitle(self._widget.windowTitle() + (' (%d)' % context.serial_number()))
        # Add widget to the user interface
        context.add_widget(self._gui._widget)      
コード例 #2
0
ファイル: caddy_plug.py プロジェクト: pi19404/labust-ros-pkg
class CaddyGuiPlug(Plugin):

    def __init__(self, context):
        super(CaddyGuiPlug, self).__init__(context)
        # Give QObjects reasonable names
        self.setObjectName('CaddyGuiPlug')

        # Process standalone plugin command-line arguments
        from argparse import ArgumentParser
        parser = ArgumentParser()
        # Add argument(s) to the parser.
        parser.add_argument("-q", "--quiet", action="store_true",
                      dest="quiet",
                      help="Put plugin in silent mode")
        args, unknowns = parser.parse_known_args(context.argv())
        if not args.quiet:
            print 'arguments: ', args
            print 'unknowns: ', unknowns

        # Create QWidget
        self._gui = CaddyGui()
        self._ros = CaddyGuiROS(self._gui)
        # Get path to UI file which is a sibling of this file
        # in this example the .ui and .py file are in the same folder
        ui_file = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'resource/CaddyGui.ui')
        # Extend the widget with all attributes and children from UI file
        loadUi(ui_file, self._gui._widget)
        # Give QObjects reasonable names
        self._gui._widget.setObjectName('CaddyGui')
        self._gui.setup()
        self._ros.setup()
        
        # Show _widget.windowTitle on left-top of each plugin (when 
        # it's set in _widget). This is useful when you open multiple 
        # plugins at once. Also if you open multiple instances of your 
        # plugin at once, these lines add number to make it easy to 
        # tell from pane to pane.
        if context.serial_number() > 1:
            self._widget.setWindowTitle(self._widget.windowTitle() + (' (%d)' % context.serial_number()))
        # Add widget to the user interface
        context.add_widget(self._gui._widget)      

    def shutdown_plugin(self):
        # TODO unregister all publishers here
        self._gui.unload();
        self._ros.unload()
        pass

    def save_settings(self, plugin_settings, instance_settings):
        # TODO save intrinsic configuration, usually using:
        # instance_settings.set_value(k, v)
        pass

    def restore_settings(self, plugin_settings, instance_settings):
        # TODO restore intrinsic configuration, usually using:
        # v = instance_settings.value(k)
        pass

    #def trigger_configuration(self):
        # Comment in to signal that the plugin has a way to configure
        # This will enable a setting button (gear icon) in each dock widget title bar
        # Usually used to open a modal configuration dialog
コード例 #3
0
Created on Sep 10, 2013
 \todo Add license information here
@author: dnad
'''
import os
import sys
import rospy
import PyQt4 as python_qt_binding
from caddy_gui import CaddyGui
from caddy_plug import CaddyGuiROS
from PyQt4 import QtGui, uic

def loadUi(file, widget):
    return 

if __name__=="__main__":
    app = QtGui.QApplication(sys.argv)
    rospy.init_node("caddy_gui")
    gui = CaddyGui()
    ros = CaddyGuiROS(gui)
    ui_file = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'resource/CaddyGui.ui')
    # Extend the widget with all attributes and children from UI file
    gui._widget = uic.loadUi(ui_file)
    gui._widget.show();
    # Give QObjects reasonable names
    gui._widget.setObjectName('CaddyGui')
    gui.setup()
    ros.setup()
    
    sys.exit(app.exec_())