diff --git a/pylot/core/util/widgets.py b/pylot/core/util/widgets.py index 13e7f74f..1d0b1844 100644 --- a/pylot/core/util/widgets.py +++ b/pylot/core/util/widgets.py @@ -227,6 +227,8 @@ class AddMetadataWidget(QWidget): self.list_model = QtGui.QStandardItemModel(self.list_view) self.list_view.setModel(self.list_model) self.list_layout.insertWidget(1, self.list_view, 1) + self.sel_model = self.list_view.selectionModel() + self.sel_model.selectionChanged.connect(self.on_clicked) def init_accept_cancel_buttons(self): self.accept_cancel_layout = QHBoxLayout() @@ -265,6 +267,18 @@ class AddMetadataWidget(QWidget): return return fninv + def on_clicked(self): + #for index in self.list_view.selectionModel().selectedIndexes(): + # item = self.list_model.itemData(index) + # inventory_path = item[0] + indices = self.list_view.selectionModel().selectedIndexes() + try: + item = self.list_model.itemData(indices[-1]) + inventory_path = item[0] + except IndexError: + inventory_path = "" + self.selection_box.setText(inventory_path) + def add_item_from_lineedit(self): """ checks if the inventory path is already in the list and if it leads to a directory;