launch_item.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 #
00003 # Copyright 2015 Airbus
00004 # Copyright 2017 Fraunhofer Institute for Manufacturing Engineering and Automation (IPA)
00005 #
00006 # Licensed under the Apache License, Version 2.0 (the "License");
00007 # you may not use this file except in compliance with the License.
00008 # You may obtain a copy of the License at
00009 #
00010 #   http://www.apache.org/licenses/LICENSE-2.0
00011 #
00012 # Unless required by applicable law or agreed to in writing, software
00013 # distributed under the License is distributed on an "AS IS" BASIS,
00014 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00015 # See the License for the specific language governing permissions and
00016 # limitations under the License.
00017 
00018 import rospy
00019 import time
00020 import os
00021 import roslaunch
00022 import subprocess
00023 
00024 from roslib.packages import get_pkg_dir
00025 
00026 from python_qt_binding.QtGui import *
00027 from python_qt_binding.QtCore import *
00028 
00029 def widget_creator(obj_ui):
00030     
00031     widget = QWidget()
00032     
00033     layout = QHBoxLayout(widget)
00034     layout.setSpacing(6)
00035     layout.setContentsMargins(0, 0, 0, 0)
00036     spacer_left = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
00037     spacer_right = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
00038     
00039     layout.addItem(spacer_left)
00040     layout.addWidget(obj_ui)
00041     layout.addItem(spacer_right)
00042     
00043     return widget
00044 
00045 class LaunchItem:
00046     
00047     def __init__(self, launch, machine):
00048         
00049         self.launch_name = QLabel(launch)
00050         self.launch_name.setContentsMargins(0,0,10,0)
00051         self.launch_name.setMinimumHeight(40)
00052         
00053         
00054         self.combo_machines = QComboBox()
00055         self.combo_machines.setMinimumHeight(40)
00056         self.combo_machines.addItem('cobotgui-dev:127.0.0.1')
00057         self.combo_machines.addItem('cobot:192.168.0.1')
00058         
00059         rsc = os.path.join(get_pkg_dir('airbus_plugin_node_manager'),'resources')
00060         icon_launch = QIcon(rsc+'/launch.png')
00061         
00062         self.button_launch = QPushButton()
00063         self.button_launch.setIcon(icon_launch)
00064         self.button_launch.setIconSize(QSize(30,30))
00065         self.button_launch.setFixedSize(QSize(100,40))
00066         self.button_launch.clicked.connect(self._launch_node_slot)
00067         
00068         self.button_launch_widget = widget_creator(self.button_launch)
00069         
00070     def _launch_node_slot(self):
00071         
00072         rospy.loginfo('%s::_launch_node()'%self.launch_name.text())
00073         
00074         subprocess.Popen(['roslaunch',
00075                           'node_launchers',
00076                           self.launch_name.text()])
00077         
00078 #End of file


airbus_plugin_node_manager
Author(s): Matignon Martin
autogenerated on Thu Jun 6 2019 17:59:23