def mergeTracks(self, unused=None): (track1Id, ok) = QInputDialog.getInteger(self.widget, "Merge two tracks", "Please enter the ID of the 1st person track you want to merge.") if not ok: return (track2Id, ok) = QInputDialog.getInteger(self.widget, "Merge two tracks", "Please enter the ID of the 2nd person track you want to merge.") if not ok: return if track1Id == track2Id: QMessageBox.critical(self.widget, "Merge two tracks", "Track IDs cannot be identical!") return if self.verifyTrackExists(track1Id) and self.verifyTrackExists(track2Id): self.editor.mergeTracks(track1Id, track2Id) self.updateTrackCount() QMessageBox.information(self.widget, "Merge two tracks", "Person tracks %d and %d have been merged!" % (track1Id, track2Id))
def _handle_generate(self, button): ''' generate a new trial config ''' trial_config = self.current_benchmark.generate() names = [] for key in self.trial_configs.keys(): names.append(key) msg = 'Select a name for this trial configuration' text = '' while True: text, ok = QInputDialog.getText(self, 'Trial name', msg) if text not in names: break QMessageBox.critical(self, "Error", "Name exists already") if ok: trial_item = QListWidgetItem(text) trial_item.setFlags(trial_item.flags() | Qt.ItemIsEditable) self.trial_list_widget.addItem(trial_item) self.trial_configs[text] = trial_config self.trial_list_widget.setCurrentItem(trial_item)
def setup(self, config_layout, results_layout, config_locked): ''' set up the layout for selecting options from the different benchmark variations ''' config_group_box_layout = QHBoxLayout() self.config_group_box = QGroupBox('Configuration') self.config_group_box.setCheckable(True) if (config_locked): self.config_group_box.setChecked(False) variations = self.config['variations'].keys() for var in variations: single_choice = True if var in self.config['multiple choice variation']: single_choice = False if isinstance(self.config['variations'][var], list): self.variation_widgets[var], scroll = self.add_config( var, self.config['variations'][var], single_choice=single_choice) config_group_box_layout.addWidget(scroll) else: path = os.path.join(self.config_path, self.config['variations'][var]) if os.path.exists(path): with open(path) as f: options = f.readlines() options = [x.strip() for x in options] self.variation_widgets[var], scroll = self.add_config( var, options, single_choice=single_choice) config_group_box_layout.addWidget(scroll) self.config['variations'][var] = options else: QMessageBox.critical(None, "Error", "File %s does not exist" % path) self.config_group_box.setLayout(config_group_box_layout) config_layout.addWidget(self.config_group_box) results_group_box = QGroupBox('Results') results_group_box_layout = QHBoxLayout() results = self.config['results'].keys() for res in results: single_choice = True if var in self.config['multiple choice result']: single_choice = False if isinstance(self.config['results'][res], list): self.result_widgets[res], scroll = self.add_config( res, self.config['results'][res], single_choice=single_choice) results_group_box_layout.addWidget(scroll) else: if self.config['results'][res] == 'text_field': widget = QWidget() text_field = QLineEdit() text_field.setReadOnly(True) txtlayout = QHBoxLayout() txtlayout.addWidget(QLabel(res)) txtlayout.addWidget(text_field) widget.setLayout(txtlayout) self.result_widgets[res] = text_field results_group_box_layout.addWidget(widget) results_group_box.setLayout(results_group_box_layout) results_layout.addWidget(results_group_box) self.notes_widget = QPlainTextEdit() self.notes_widget.setMaximumHeight(100) self.notes_widget.setPlaceholderText('Enter notes about the result...') results_layout.addWidget(self.notes_widget)
def verifyTrackExists(self, trackId): if not trackId in self.database.getTrackIds(): QMessageBox.critical(self.widget, "Wrong track ID", "Person track with ID %d does not exist!" % trackId) return False return True