text_filter_widget.py
Go to the documentation of this file.
1 # Software License Agreement (BSD License)
2 #
3 # Copyright (c) 2012, Willow Garage, Inc.
4 # All rights reserved.
5 #
6 # Redistribution and use in source and binary forms, with or without
7 # modification, are permitted provided that the following conditions
8 # are met:
9 #
10 # * Redistributions of source code must retain the above copyright
11 # notice, this list of conditions and the following disclaimer.
12 # * Redistributions in binary form must reproduce the above
13 # copyright notice, this list of conditions and the following
14 # disclaimer in the documentation and/or other materials provided
15 # with the distribution.
16 # * Neither the name of Willow Garage, Inc. nor the names of its
17 # contributors may be used to endorse or promote products derived
18 # from this software without specific prior written permission.
19 #
20 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23 # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24 # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26 # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30 # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 # POSSIBILITY OF SUCH DAMAGE.
32 
33 import os
34 
35 from python_qt_binding import loadUi
36 from python_qt_binding.QtWidgets import QWidget
37 
38 
39 class TextFilterWidget(QWidget):
40  """
41  Taken from rqt_console.TextFilterWidget. Only modification from it is .ui
42  file in use that takes more generic form (only textfiedl).
43  """
44 
45  def __init__(self, parentfilter, rospack, display_list_args=None):
46  """
47  Widget for displaying interactive data related to text filtering.
48 
49  Taken from rqt_console and simplified to be usable in broader
50  situations.
51 
52  :type parentfilter: BaseFilter
53  :param parentfilter: buddy filter were data is stored, ''TimeFilter''
54  :param display_list_args: empty list, ''list''
55  """
56  super(TextFilterWidget, self).__init__()
57  ui_file = os.path.join(
58  rospack.get_path('rqt_reconfigure'), 'resource',
59  'text_filter_widget.ui'
60  )
61  loadUi(ui_file, self)
62  self.setObjectName('TextFilterWidget')
63  # When data is changed it is stored in the parent filter
64  self._parentfilter = parentfilter
65 
66  self.text_edit.textChanged.connect(self.handle_text_changed)
67 
68  self.handle_text_changed()
69 
70  def set_text(self, text):
71  """
72  Setter for the text edit widget
73  :param text: text to be placed in text_edit, ''str''
74  """
75  self.text_edit.setText(text)
76 
78  self._parentfilter.set_text(self.text_edit.text())
79 
80  def repopulate(self):
81  """
82  Stub function.
83  If the widget had any dynamically adjustable data it would requery it
84  in this function.
85  """
86  pass
87 
88  def save_settings(self, settings):
89  settings.set_value('text', self._parentfilter._text)
90 
91  def restore_settings(self, settings):
92  text = settings.value('text', '')
93  self.set_text(text)
94  self.handle_text_changed()
def __init__(self, parentfilter, rospack, display_list_args=None)


rqt_reconfigure
Author(s): Isaac Saito, Ze'ev Klapow
autogenerated on Wed Jul 10 2019 04:02:40