launchtree_plugin.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 import rospy
3 from rqt_gui_py.plugin import Plugin
4 
5 from python_qt_binding.QtCore import Qt
6 from python_qt_binding.QtGui import QInputDialog
7 
8 from rqt_launchtree.launchtree_widget import LaunchtreeWidget
9 
10 
12 
13  _SETTING_LASTPKG = 'last_pkg'
14  _SETTING_LASTLAUNCHFILE = 'last_launch'
15  _SETTING_LASTLAUNCHARGS = 'last_args'
16 
17  def __init__(self, context):
18  super(LaunchtreePlugin, self).__init__(context)
19 
20  self._widget = LaunchtreeWidget(context)
21  if context.serial_number() > 1:
22  self._widget.setWindowTitle(self._widget.windowTitle() +
23  (' (%d)' % context.serial_number()))
24  context.add_widget(self._widget)
25 
26  def shutdown_plugin(self):
27  self._widget.shutdown()
28 
29  def save_settings(self, plugin_settings, instance_settings):
30  instance_settings.set_value('editor', self._widget.editor)
31  _curr_pkg = self._widget.package_select.currentText()
32  rospy.logdebug('save_settings) currentIndex={}'.format(_curr_pkg))
33  instance_settings.set_value(self._SETTING_LASTPKG, _curr_pkg)
34  instance_settings.set_value(self._SETTING_LASTLAUNCHFILE, self._widget.launchfile_select.currentText())
35  instance_settings.set_value(self._SETTING_LASTLAUNCHARGS, self._widget.args_input.text())
36 
37  def restore_settings(self, plugin_settings, instance_settings):
38  self._widget.editor = instance_settings.value('editor', 'gedit')
39  self._widget.args_input.setText(instance_settings.value(self._SETTING_LASTLAUNCHARGS, ''))
40  pkg_idx = self._widget.package_select.findText(instance_settings.value(self._SETTING_LASTPKG))
41  if pkg_idx >= 0:
42  self._widget.package_select.blockSignals(True)
43  self._widget.package_select.setCurrentIndex(pkg_idx)
44  self._widget.package_select.blockSignals(False)
45  self._widget.update_launchfiles(pkg_idx)
46  # only set launch file if pkg was restored
47  launch_idx = self._widget.launchfile_select.findText(instance_settings.value(self._SETTING_LASTLAUNCHFILE))
48  if launch_idx >= 0:
49  self._widget.launchfile_select.blockSignals(True)
50  self._widget.launchfile_select.setCurrentIndex(launch_idx)
51  self._widget.launchfile_select.blockSignals(False)
52  self._widget.block_load(False)
53  self._widget.load_launchfile()
54 
56  (text, ok) = QInputDialog.getText(self._widget,
57  'Settings for %s' % self._widget.windowTitle(),
58  'Command to edit launch files (vim, gedit, ...), can accept args:',
59  text = self._widget.editor
60  )
61  if ok:
62  self._widget.editor = text
def restore_settings(self, plugin_settings, instance_settings)
def save_settings(self, plugin_settings, instance_settings)


rqt_launchtree
Author(s): Philipp Schillinger
autogenerated on Mon Jun 10 2019 14:55:27