Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sqlite3
- from guizero import App, PushButton, ListBox, TextBox, Text
- from typing import List
- myconnection = sqlite3.connect("movie.db")
- mycursor = myconnection.cursor()
- app = App(title="Movie Selector",layout="grid", bg="light blue")
- def commit(genreinput, yearinput):
- mycursor.execute("""
- SELECT film.title,genre.genreName,film.releaseYear
- FROM film
- INNER JOIN filmgenre ON film.filmID = filmgenre.filmID
- INNER JOIN genre ON filmgenre.genreID = genre.genreID
- WHERE genre.genreName = ? AND film.releaseYear = ?""",
- (genreinput.value,yearinput.value))
- movielist = ListBox(app, items=([x[0] for x in mycursor.fetchall()]),grid=[5,5])
- genreinput = TextBox(app, text="", grid=[1,1])
- askgenre = Text(app, text="What genre of movie would you like?: ",grid=[0,1])
- yearinput = TextBox(app, text="",grid=[1,2])
- askyear = Text(app, text="What's the year of movies you would like to see?: ",grid=[0,2])
- submit = PushButton(app, text="Generate Movies!", command=commit, args=[genreinput,yearinput],grid=[0,3])
- def highlight():
- quitApp.bg = "red"
- def lowlight():
- quitApp.bg = "light blue"
- quitApp = PushButton(app, command=quit, text="Quit App",grid=[0,5])
- quitApp.when_mouse_enters = highlight
- quitApp.when_mouse_leaves = lowlight
- app.display()
Advertisement
Add Comment
Please, Sign In to add comment