def _load_commands(self, commands, commands_list_widget): for cmd in commands: item = QListWidgetItem(str(cmd.id)) item.cmd = cmd commands_list_widget.addItem(item) if commands_list_widget.count(): commands_list_widget.setCurrentItem(commands_list_widget.item(0))
def on_operation_commands_add_clicked(self): tx_packets = dict([ (packet.name, num) for num, packet in self.instr_cfg.instrument.tx_packets.iteritems() ]) (text, ok) = QInputDialog.getItem(\ self, self.trUtf8("Add operation command"), self.trUtf8("Select command to send:"), tx_packets.keys(), 0, False) if ok and text: cmd_num = tx_packets[str(text)] command = self.instr_cfg.add_operation_command(cmd_num) item = QListWidgetItem(str(cmd_num)) item.cmd = command self.operation_commands_list.addItem(item) self.operation_commands_list.setCurrentItem(item)