def get(self): db = getUtility(IRelationalDatabase) cr = db.cursor() barcode = self.book.barcode if barcode: cr.execute("""SELECT id, barcode, author, title FROM books WHERE barcode = ?""", (barcode,)) else: cr.execute("""SELECT id, barcode, author, title FROM books""") rst = cr.fetchall() cr.close() books = [] for record in rst: id = record['id'] barcode = record['barcode'] author = record['author'] title = record['title'] book = Book() book.id = id book.barcode = barcode book.author = author book.title = title books.append(book) return books
def get(self): db = getUtility(IRelationalDatabase) cr = db.cursor() barcode = self.book.barcode if barcode: cr.execute( """SELECT id, barcode, author, title FROM books WHERE barcode = ?""", (barcode, )) else: cr.execute("""SELECT id, barcode, author, title FROM books""") rst = cr.fetchall() cr.close() books = [] for record in rst: id = record['id'] barcode = record['barcode'] author = record['author'] title = record['title'] book = Book() book.id = id book.barcode = barcode book.author = author book.title = title books.append(book) return books
def on_add_clicked(self, *args): barcode = self.ui.barcode.get_text() author = self.ui.author.get_text() title = self.ui.title.get_text() book = Book() book.barcode = barcode book.author = author book.title = title self.add(book) self.ui.list_store.append((book, barcode, author, title))
def initialize_lists(self): cm=Gtk.ListStore(object, str, str, str) self.ui.catalog=cm self.ui.catalog_view.set_model(cm) for _ in range(3): b=Book() b.title="Brotherhood of the ring" b.author="J.R.R.Tolkien" b.barcode="123-1232" self.append_book(b) mm=Gtk.ListStore(object, int, str) self.ui.members=mm self.ui.member_view.set_model(mm) for _ in range(3): m=Member() m.name="Jim Carry" m.number=123 self.append_member(m)
def initialize_lists(self): cm = Gtk.ListStore(object, str, str, str) self.ui.catalog = cm self.ui.catalog_view.set_model(cm) for _ in range(3): b = Book() b.title = "Brotherhood of the ring" b.author = "J.R.R.Tolkien" b.barcode = "123-1232" self.append_book(b) mm = Gtk.ListStore(object, int, str) self.ui.members = mm self.ui.member_view.set_model(mm) for _ in range(3): m = Member() m.name = "Jim Carry" m.number = 123 self.append_member(m)