Personal Movie Assistant in Python

STEP-1

Install the package of wikipedia and wolframalpha.

You have To Install Python 3 at first in your PC.

Press (windows+R) -- Type ' cmd ' and click OK.
In Command line write the command -----

    1)  pip install wikipedia

after that 

    2) pip install wolframalpha


STEP-2

Now open the python editor or any other editor that u use 

At first we have to import packages-----

code---      import wikipedia

                  import wolframalpha

                  from tkinter import *


STEP-3


Build the GUI

code----  

class MainGUI():
    def __init__(self):
        self.mainGUI = Tk()
        self.mainGUI.title("Personal Assistant")
        self.mainGUI.resizable(width=True, height=True)
        self.mainGUI.geometry('500x200')

        self.introLabel = Label(self.mainGUI, text="Welcome to your personal Movie assistant. You can ask any Movie Title?", wraplength=500)
        self.introLabel.pack()

        self.questionLabel = Label(self.mainGUI, text="Please Enter a Movie Name : ") 
        self.questionLabel.pack( side = LEFT)

        self.questionInput = Entry(self.mainGUI) 
        self.questionInput.pack( side = LEFT)

        self.answerButton = Button(self.mainGUI, text="GET DETAILS", command=self.findMyAnswer) 
        self.answerButton.pack( side = LEFT)

        self.mainGUI.mainloop()



#NOW YOU HAVE TO KNOW THE PYTHON LANGUAGE TO UNDERSTAND THE CODE :)




STEP-4

Code for The main Function-----


def findMyAnswer(self):
        input = self.questionInput.get()
        try:
            #wolframalpha
            wolframalpha_appId = "*********" 

            client = wolframalpha.Client(wolframalpha_appId) 
            res = client.query(input)
            answer = next(res.results).text

            answerWindow = Toplevel(self.mainGUI)
            answerWindow.geometry('600x400')
            answerWindow.title("Result")

            answerText = Text(answerWindow) 
            answerText.insert(INSERT, input + " " + answer)
            answerText.pack()

        except:
            #wikipedia
            answer = wikipedia.summary(input)
            answerWindow = Toplevel(self.mainGUI) 

            answerWindow.geometry('600x400')
            answerWindow.title("Result")

            answerText = Text(answerWindow) 
            answerText.insert(INSERT, input + " " + answer)
            answerText.pack()

if __name__ == "__main__":
        MainGUI()




STEP-5


NOW you can Run the Code and Enjoy Your Personal Movie Assistant








Comments

Post a Comment