def checkin_pressed(self, book): """ Connected to signal in populate_table """ dialog = ListDialog(self, "Who are you?", self.candidates_for_return(book)) def not_on_list(): name, success = QtGui.QInputDialog.getText( self, 'Return %s' % book.title, 'What is your name?') name = str(name).strip() if success and name: dialog.forced_result = name dialog.accept() dialog.button.setText("I'm not on the list!") dialog.button.pressed.connect(not_on_list) if dialog.exec_(): name = dialog.result() if name: date = datetime.now().strftime("%m/%d/%Y %I:%M%p") with open(self.config[_LOG_PATH_KEY], 'ab') as logfile: writer = csv.writer(logfile) writer.writerow([date, name, "checked in", -1, book.title]) if book in self.inventory: # Can probably remove this check book.check_in_a_copy() self.inventory.persist() else: logger.critical('Couldn\'t find book: %s' % book)