def item_changed(self, current: QtGui.QListWidgetItem, previous: QtGui.QListWidgetItem): previous_index = self.tests_list.row(previous) current_index = self.tests_list.row(current) if current_index == self._current_row: return widget = self.tests_widget.widget(previous_index) errs = widget.errors if widget is not None else [] if not self.just_deleted_a_test and errs: locs = ", ".join(tab_repr(i) for i in errs) QtGui.QMessageBox.warning( self, "Cannot Change The Current Test.", "Test `{}` has some errors so you can't leave it. See the {} tab{}." .format(previous.text(), locs, 's' if len(errs) > 1 else '')) QtCore.QTimer.singleShot( 0, lambda: self.tests_list.setCurrentRow(self._current_row)) return else: self.just_deleted_a_test = False self._current_row = self.tests_list.row(current) self.tests_widget.setCurrentIndex(current_index) self.update_status_bar()
def update_listEdges(self): '''is used to update QListWidget when unit cell is changed''' self.initialization = True # block QListWidget valuechanged callback self.listEdges.clear() defaultListItem = QListWidgetItem('') self.listEdges_idToItem = {None: defaultListItem} self.listEdges_ItemToId = {defaultListItem.text(): None} for key, edge in self.gee.UC.edges.items(): newItem = QListWidgetItem(str(edge)) self.listEdges.addItem(newItem) self.listEdges_idToItem[key] = newItem self.listEdges_ItemToId[newItem.text()] = key self.listEdges.addItem(defaultListItem) self.listEdges.setCurrentItem(defaultListItem) self.initialization = False # relieze QListWidget valuechanged callback
def onItemActivated(self, item:QListWidgetItem): self.config.log.info("Selected project: %s", item.text()) self.config.set_project(item.text())