Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions resource/editor_drop_down_list.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>_widget_top</class>
<widget class="QWidget" name="_widget_top">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>393</width>
<height>50</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>300</width>
<height>20</height>
</size>
</property>
<property name="windowTitle">
<string>param drop down list</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="margin">
<number>0</number>
</property>
<item>
<layout class="QHBoxLayout" name="_layout_h" stretch="0,0,1,0,0">
<item>
<widget class="QLabel" name="_paramname_label">
<property name="text">
<string>param_name</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="_paramval_drop_down_list"/>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
data_files=[
('share/' + package_name + '/resource', [
'resource/editor_bool.ui',
'resource/editor_drop_down_list.ui',
'resource/editor_enum.ui',
'resource/editor_number.ui',
'resource/editor_string.ui',
Expand Down
14 changes: 11 additions & 3 deletions src/rqt_reconfigure/param_client_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,10 +245,18 @@ def add_editor_widgets(self, parameters, descriptors):
for parameter, descriptor in zip(parameters, descriptors):
if Parameter.Type(descriptor.type) not in EDITOR_TYPES:
continue

if len(descriptor.additional_constraints) > 0 and descriptor.additional_constraints[0] == "\n":
editor_widget = EDITOR_TYPES["DROP_DOWN_LIST"](
self._param_client, parameter, descriptor
)

else:
editor_widget = EDITOR_TYPES[parameter.type_](
self._param_client, parameter, descriptor
)

logging.debug('Adding editor widget for {}'.format(parameter.name))
editor_widget = EDITOR_TYPES[Parameter.Type(descriptor.type)](
self._param_client, parameter, descriptor
)
self._editor_widgets[parameter.name] = editor_widget
editor_widget.display(self.grid)

Expand Down
41 changes: 35 additions & 6 deletions src/rqt_reconfigure/param_editors.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,39 @@ def update_local(self, value):
self._update_signal.emit(value)


class DropDownListEditor(EditorWidget):
_update_signal = Signal(int)

def __init__(self, *args, **kwargs):
super(DropDownListEditor, self).__init__(*args, **kwargs)
ui_ddl = os.path.join(
package_path, 'share', 'rqt_reconfigure', 'resource',
'editor_drop_down_list.ui'
)
loadUi(ui_ddl, self)

self.contraints = self.descriptor.additional_constraints.split("\n")[1:]
self.drop_down_items = []

for item in self.contraints:
t = item.split(",")
self.drop_down_items.append(t[1])

self._paramval_drop_down_list.addItems(self.drop_down_items)
self._paramval_drop_down_list.setCurrentIndex(self.parameter.value)

self._update_signal.connect(self._paramval_drop_down_list.setCurrentIndex)

self._paramval_drop_down_list.currentIndexChanged.connect(self.index_changed)

def index_changed(self, index):
self.update(int(index))

def update_local(self, value):
super(DropDownListEditor, self).update_local(value)
self._update_signal.emit(value)


class StringEditor(EditorWidget):
_update_signal = Signal(str)

Expand Down Expand Up @@ -310,7 +343,7 @@ def __init__(self, *args, **kwargs):
)
loadUi(ui_num, self)

if len(self.descriptor.floating_point_range) > 0:
if(len(self.descriptor.floating_point_range) > 0):
# Handle unbounded doubles nicely
self._min = float(self.descriptor.floating_point_range[0].from_value)
self._min_val_label.setText(str(self._min))
Expand Down Expand Up @@ -514,9 +547,5 @@ def _set_to_empty(self):
Parameter.Type.INTEGER: IntegerEditor,
Parameter.Type.DOUBLE: DoubleEditor,
Parameter.Type.STRING: StringEditor,
Parameter.Type.BOOL_ARRAY: ArrayEditor,
Parameter.Type.BYTE_ARRAY: ArrayEditor,
Parameter.Type.INTEGER_ARRAY: ArrayEditor,
Parameter.Type.DOUBLE_ARRAY: ArrayEditor,
Parameter.Type.STRING_ARRAY: ArrayEditor,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why delete ARRAY type here?
i have tried directly adding DROP_DOWN_LIST, it works.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you see this comment @himaj47 ?

"DROP_DOWN_LIST": DropDownListEditor,
}