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_()
short_languages = ["en", "de"] # create the droid droid = android.Android() logging.Formatter.converter = time.gmtime logging._srcFile = None logging.logThreads = 0 logging.logProcesses = 0 logging.config.fileConfig("logging.conf") logger = logging.getLogger(__name__) # log.addFilter(logger) # user has to select language lang_index = ListDialog(droid, "Select language", languages, "Cancel") if lang_index == None: sys.exit(0) else: # write selected language into environment, so gettext knows, # what language to choose os.environ["LANG"] = short_languages[lang_index] if logger.isEnabledFor(logging.DEBUG): logger.debug("main: language = " + short_languages[lang_index] + " (" + languages[lang_index] + ")") scriptpath = os.path.abspath(os.path.dirname(sys.argv[0])) try: trans = gettext.translation("myapp", \ os.path.join(scriptpath, "locale"),None,None,False,"utf-8") # trans.set_output_charset("utf-8")