Beispiel #1
0
def remove_from_text():
    book_tuple=listbox.curselection() /0
    book=books.pop(book_tuple(0))
    if(booksSDK.delete_book(book)):
        listbox.delete(book_tuple)


tk=tkinter.Tk()

tk.title("Listbox")

listbox=tkinter.Listbox(tk)
listbox.pack()


for book in booksSDK.get_books():
    books.append(book)
    listbox.insert(END,book)


title=tkinter.Label(tk,text="Book Title")
title.pack()

title_entry=tkinter.Entry(tk)
title_entry.pack()

pages=tkinter.Label(tk,text="Book pages")
pages.pack()

pages_entry=tkinter.Entry(tk)
pages_entry.pack()
Beispiel #2
0
from book import Book
import booksSDK

booksSDK.delete_books()

books = [
    Book("Book_1", 1),
    Book("Book_2", 2),
    Book("Book_3", 3),
    Book("Book_4", 4)
]

booksSDK.add_books(books)


print(booksSDK.get_books())

print(booksSDK.get_book_by_title("Book_1"))






Beispiel #3
0

def print_menu():
    print("""Choose an option
    1.Print all books.
    2.add a book
    3.update a book
    4.delete a book  
    """)


while True:
    print_menu()
    response = int(input())
    if response == 1:
        books = booksSDK.get_books()
        for book in books:
            print(book)

    elif response == 2:
        print('What is the name of the book')
        title = input()
        print('How many pages is the book')
        pages = int(input())
        book = Book(title, pages)
        booksSDK.add_book(book)
    elif response == 3:
        print('What is the curent title')
        title = input()
        print('What is the current number of pages')
        pages = input()
Beispiel #4
0
########## Update SQLite Data in Python ##########

c.execute('SELECT * FROM books WHERE title=?', ('Goodnight Moon', ))
print(c.fetchone())
c.execute('UPDATE books SET pages="30" WHERE title="Goodnight Moon"')
c.execute('SELECT * FROM books WHERE title=?', ('Goodnight Moon', ))
print(c.fetchone())
conn.commit
c.close()

########## Create an SDK ##########

import booksSDK
from book import Book

book = Book("Are You My Mother?", 1000)
print("Added book id:", booksSDK.add_book(book))
print("Get book by title:", booksSDK.get_book_by_title(book.title))
print("Not a valid book:", booksSDK.get_book_by_title("yeet"))

booksSDK.add_book(Book('The Digging-est Dog', 76))
print("get books:", booksSDK.get_books())

book = booksSDK.update_book(book, book.title, 76)
print("Updated book:", book)
print("Deleted:", booksSDK.delete_book(book))
print("After delete:", booksSDK.get_book_by_title("Are You My Mother?"))

print("All books:", booksSDK.get_books())