table_launch_nodes.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 
00022 from roslib.packages import get_pkg_dir
00023 
00024 from python_qt_binding.QtGui import *
00025 from python_qt_binding.QtCore import *
00026 
00027 from launch_item import LaunchItem
00028 
00029 class TableLaunchNodes:
00030     
00031     def __init__(self, gui):
00032         
00033         self._gui = gui
00034         
00035         self._datamodel = QStandardItemModel(0, 3)
00036         
00037         self._gui._table_launch.setModel(self._datamodel)
00038         self._gui._table_launch.verticalHeader().setVisible(False)
00039         
00040         node_launchers_path = '/'.join([get_pkg_dir('node_launchers'),
00041                                         'launch'])
00042         
00043         self._launch_list = []
00044         
00045 #         self._gui._table_launch.horizontalHeader().setResizeMode(QHeaderView.Stretch)
00046         
00047         i=0
00048         for launch_file in os.listdir(node_launchers_path):
00049             self._add_launcher(launch_file,'/cobotgui-dev', i)
00050             i+=1
00051         
00052         self._gui._table_launch.resizeColumnsToContents()
00053         self._gui._table_launch.resizeRowsToContents()
00054     
00055     def _add_launcher(self, launch_file, machine_name, index):
00056         
00057         new_launch = LaunchItem(launch_file, machine_name)
00058         
00059         self._datamodel.setItem(index, 0, QStandardItem())
00060         
00061         qindex = self._datamodel.index(index, 0, QModelIndex())
00062         self._gui._table_launch.setIndexWidget(qindex, new_launch.launch_name)
00063         
00064         qindex = self._datamodel.index(index, 1, QModelIndex())
00065         self._gui._table_launch.setIndexWidget(qindex, new_launch.combo_machines)
00066         
00067         qindex = self._datamodel.index(index, 2, QModelIndex())
00068         self._gui._table_launch.setIndexWidget(qindex, new_launch.button_launch_widget)
00069         
00070         self._launch_list.append(new_launch)
00071         
00072     def translate(self):
00073         
00074         self._gui.launch_header_label.setText(trUtf8('Nodes launch'))
00075         
00076         header_label = [trUtf8('Name'), trUtf8('Default machine'), trUtf8('Launch')]
00077         
00078         for i in range(len(header_label)):
00079             self._datamodel.setHeaderData(i, Qt.Horizontal, header_label[i])
00080     
00081 #End of file


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