Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The /question_dialog service now includes a new type, LIST_QUESTION #88

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
18 changes: 16 additions & 2 deletions segbot_gui/src/segbot_gui/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from qt_gui.plugin import Plugin
from python_qt_binding.QtGui import QFont, QHBoxLayout, QLabel, QLineEdit, \
QPushButton, QTextBrowser, QVBoxLayout, \
QWidget
QWidget, QComboBox
from python_qt_binding.QtCore import SIGNAL

class QuestionDialogPlugin(Plugin):
Expand Down Expand Up @@ -91,7 +91,16 @@ def update(self):
self.text_input = QLineEdit(self._widget)
self.text_input.editingFinished.connect(self.handle_text)
self._button_layout.addWidget(self.text_input)

elif req.type == QuestionDialogRequest.LIST_QUESTION:
combo = QComboBox()
for index, options in enumerate(req.options):
combo.addItem(options)
self._button_layout.addWidget(combo)
button = QPushButton("Select", self._widget)
button.clicked.connect(partial(self.handle_list, combo))
self._button_layout.addWidget(button)
self.buttons.append(button)

def timeout(self):
self._text_browser.setText("Oh no! The request timed out.")
self.clean()
Expand All @@ -116,6 +125,11 @@ def handle_text(self):
self.clean()
self.response_ready = True

def handle_list(self, combo):
self.response = QuestionDialogResponse(combo.currentIndex(), str(combo.currentText()))
self.clean()
self.response_ready = True

def save_settings(self, plugin_settings, instance_settings):
# TODO save intrinsic configuration, usually using:
# instance_settings.set_value(k, v)
Expand Down