33 from __future__
import division
36 from python_qt_binding
import loadUi
37 from python_qt_binding.QtCore
import Signal, Slot
38 from python_qt_binding.QtGui
import QIcon
39 from python_qt_binding.QtWidgets
import QWidget
48 from .publisher_tree_widget
import PublisherTreeWidget
53 add_publisher = Signal(str, str, float, bool)
54 change_publisher = Signal(int, str, str, str, object)
55 publish_once = Signal(int)
56 remove_publisher = Signal(int)
57 clean_up_publishers = Signal()
60 super(PublisherWidget, self).
__init__(parent)
65 ui_file = os.path.join(self._rospack.get_path(
'rqt_publisher'),
'resource',
'Publisher.ui')
67 {
'ExtendedComboBox': ExtendedComboBox,
'PublisherTreeWidget': PublisherTreeWidget})
68 self.refresh_button.setIcon(QIcon.fromTheme(
'view-refresh'))
70 self.add_publisher_button.setIcon(QIcon.fromTheme(
'list-add'))
71 self.remove_publisher_button.setIcon(QIcon.fromTheme(
'list-remove'))
72 self.clear_button.setIcon(QIcon.fromTheme(
'edit-clear'))
76 self.publisher_tree_widget.model().item_value_changed.connect(self.
change_publisher)
78 self.publisher_tree_widget.publish_once.connect(self.
publish_once)
79 self.remove_publisher_button.clicked.connect(
80 self.publisher_tree_widget.remove_selected_publishers)
84 self._update_thread.kill()
88 self._update_thread.kill()
89 self.type_combo_box.setEnabled(
False)
90 self.topic_combo_box.setEnabled(
False)
91 self.type_combo_box.setEditText(
'updating...')
92 self.topic_combo_box.setEditText(
'updating...')
93 self._update_thread.start()
98 message_type_names = []
102 [pkg_tuple[0]
for pkg_tuple
in 103 rosmsg.iterate_packages(self.
_rospack, rosmsg.MODE_MSG)])
106 packages = sorted(rosmsg.list_packages())
107 for package
in packages:
108 for base_type_str
in rosmsg.list_msgs(package, rospack=self.
_rospack):
109 message_class = roslib.message.get_message_class(base_type_str)
110 if message_class
is not None:
111 message_type_names.append(base_type_str)
113 self.type_combo_box.setItems.emit(sorted(message_type_names))
116 _, _, topic_types = rospy.get_master().getTopicTypes()
118 self.topic_combo_box.setItems.emit(sorted(self._topic_dict.keys()))
122 self.type_combo_box.setEnabled(
True)
123 self.topic_combo_box.setEnabled(
True)
128 self.type_combo_box.setEditText(self.
_topic_dict[topic_name])
132 topic_name = str(self.topic_combo_box.currentText())
133 type_name = str(self.type_combo_box.currentText())
134 rate = float(self.frequency_combo_box.currentText())
136 self.add_publisher.emit(topic_name, type_name, rate, enabled)