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)
def on_switch_library_button_pressed(self): dialog = ListDialog(self, SHELF_DIALOG_LABEL_TEXT, self.goodreads().shelves()) def create_new_shelf(): name, success = QtGui.QInputDialog.getText( dialog, 'Adding a new shelf', 'What would you like to name the new shelf?') if success: self.goodreads().add_shelf(str(name)) dialog.setItems(self.goodreads().shelves()) dialog.button.pressed.connect(create_new_shelf) dialog.button.setText("Create a new shelf") def accepted(): shelf = dialog.result() if shelf: self.config[_LIBRARY_SHELF_KEY] = shelf dialog.accepted.connect(accepted) dialog.exec_()