from tkinter import *

global clicked

clicked = 0

class The_Guide(Frame):

def __init__(self,master):

self.var = StringVar()

Frame.__init__(self, master)

self.grid()

self.Opening()

def Opening(self):

global clicked

clicked = 0

self.DontPanic = Label(self, bg= 'yellow', text = "Don't Panic", font=("Arial",10,"bold"))

self.DontPanic.pack(ipady=4,fill=BOTH, side=TOP)

self.Space1 = Label(self, bg = 'yellow', text=" ")

self.Space1.pack(ipady= 14, fill=BOTH)

self.SearchButton = Button(self,activeforeground="white",activebackground = "DeepPink3", bg = 'DeepPink3',fg='white', text = "Search", command = self.Searching)

self.SearchButton.pack(ipady = 3, ipadx = 16, fill=BOTH)

self.CommonSearched = Button(self,activeforeground="white",activebackground="dark orange",bg="dark orange",fg="white", text="Common", command=self.CommonSearch)

self.CommonSearched.pack(fill=BOTH, ipady=3, ipadx=9)

self.Instructions = Button(self, command=self.Instruct, text="Instructions", activeforeground="white",activebackground="blue4",bg="blue4",fg="white")

self.Instructions.pack(fill = BOTH, ipady=3)

self.TheGuide = Button(self, command=self.TheGuide, text="The Guide", activeforeground="white",activebackground="DarkOrchid4",bg="DarkOrchid4",fg="white")

self.TheGuide.pack(fill = BOTH, ipady=3)

self.CreditsButton = Button(self,activebackground="SeaGreen1",activeforeground="white",bg = "SeaGreen1",fg="white" ,text="Credits", command=self.Credits)

self.CreditsButton.pack(fill=BOTH, ipady=3, ipadx = 16)

def Instruct(self):

global stat

stat=1

self.TheGuide.pack_forget()

self.Instructions.pack_forget()

self.SearchButton.pack_forget()

self.CreditsButton.pack_forget()

self.CommonSearched.pack_forget()

self.Label3 = Label(self, bg= 'yellow', text = "After Getting to The Main Menu, click search and enter in a term, if the is a definition tied with")

self.Label4 = Label(self, bg= 'yellow', text = "it will appear in a white box, scroll through it to show the whole definition and enjoy")

self.Label3.pack(fill=BOTH)

self.Label4.pack(fill=BOTH)

self.MainMenuB = Button(self,activebackground="SeaGreen1",activeforeground="white",bg = "SeaGreen1",fg="white", text="Main Menu", command=self.packforgetcredits)

self.MainMenuB.pack(fill = X)

def TheGuide(self):

global stat

stat = 3

self.TheGuide.pack_forget()

self.Instructions.pack_forget()

self.SearchButton.pack_forget()

self.CreditsButton.pack_forget()

self.CommonSearched.pack_forget()

self.Label2 = Label(self, bg= 'yellow', text = "The Hitchhikers Guide to the Galaxy is a book, written by Douglas Adams. Within the story there is")

self.Label5 = Label(self, bg= 'yellow', text = "a book called 'The Hitchhikers Guide to the Galaxy', detailed with knoweldge of hitchhiking survival")

self.Label6 = Label(self, bg= 'yellow', text = "in the galaxy. This Program Attempts to recreate 'The Guide'.")

self.Label2.pack(fill=BOTH)

self.Label5.pack(fill=BOTH)

self.Label6.pack(fill=BOTH)

self.MainMenuB = Button(self,activebackground="SeaGreen1",activeforeground="white",bg = "SeaGreen1",fg="white", text="Main Menu", command=self.packforgetcredits)

self.MainMenuB.pack(fill = X)

def CommonSearch(self):

self.TheGuide.pack_forget()

self.Instructions.pack_forget()

self.SearchButton.pack_forget()

self.CreditsButton.pack_forget()

self.CommonSearched.pack_forget()

self.Babel = Button(self, text="Babel Fish",bg ="orange",activebackground="orange" ,command=self.Clear1)

self.Earth = Button(self, text="The Earth",bg="dodger blue", activebackground="dodger blue", command=self.Clear1)

self.Vogon = Button(self, text="Vogons", bg="dark olive green", activebackground="dark olive green",command=self.Clear1)

self.Bistromath = Button(self, text="Bistromath",bg="firebrick",activebackground="firebrick", command=self.Clear1)

self.Improbability = Button(self, text="Improbability",bg="gold",activebackground="gold", command=self.Clear1)

self.Arthur = Button(self, text="Arthur Dent",bg="khaki4",activebackground="khaki4", command=self.Clear1)

self.Babel.pack(fill=BOTH)

self.Earth.pack(fill=BOTH)

self.Vogon.pack(fill=BOTH)

self.Bistromath.pack(fill=BOTH)

self.Improbability.pack(fill=BOTH)

self.Arthur.pack(fill=BOTH)

def Clear1(self):

self.Babel.pack_forget()

self.Earth.pack_forget()

self.Vogon.pack_forget()

self.Bistromath.pack_forget()

self.Improbability.pack_forget()

self.Arthur.pack_forget()

self.Searching()

def Credits(self):

global stat

stat = 2

self.TheGuide.pack_forget()

self.Instructions.pack_forget()

self.SearchButton.pack_forget()

self.CreditsButton.pack_forget()

self.CommonSearched.pack_forget()

self.Cred1 = Label(self, text="Creator - Callan", bg="Yellow", fg="Black")

self.Cred1.pack(fill = X)

self.Cred2 = Label(self, text="Helper - Sorne", bg="Yellow", fg="Black")

self.Cred2.pack(fill = X)

self.Cred3 = Label(self, text="Author - Douglas Adam", bg="Yellow", fg="Black")

self.Cred3.pack(fill = Y)

self.MainMenuB = Button(self,activebackground="SeaGreen1",activeforeground="white",bg = "SeaGreen1",fg="white", text="Main Menu", command=self.packforgetcredits)

self.MainMenuB.pack(fill = X)

def Searching(self):

global clicked

self.TheGuide.pack_forget()

self.Instructions.pack_forget()

self.SearchButton.pack_forget()

self.CreditsButton.pack_forget()

self.CommonSearched.pack_forget()

clicked = clicked + 1

self.SearchButton2 = Button(self,activeforeground="white",activebackground = "DeepPink3", bg = 'DeepPink3',fg='white', text = "Search", command = self.Search)

self.SearchButton2.pack(ipady = 3, ipadx = 16, side=LEFT, fill = Y)

self.text = Text(self, width = 49, height =3, wrap = WORD)

if clicked == 1:

self.SearchBar = Entry(self, foreground ="white", background="Black")

self.SearchBar.pack(side=LEFT, fill=Y)

elif clicked >= 2:

self.Search()

def Search(self):

self.text.pack(fill= X, side=BOTTOM)

self.text.delete('1.0', END)

Search_Query = ""

Search_Query = self.SearchBar.get()

if Search_Query.lower() == "earth":

self.text.insert(0.0, "Mostly Harmless")

elif Search_Query.lower() == "main menu" or Search_Query.lower() == "main":

self.text.pack_forget()

self.SearchBar.pack_forget()

self.SearchButton2.pack_forget()

self.Space1.pack_forget()

self.DontPanic.pack_forget()

self.Opening()

elif Search_Query.lower() == "towel":

self.text.insert(0.0, "")

#inside Joke :P

elif Search_Query.lower() == "sorne":

self.text.insert(0.0, "The true name of the man refered to as Soren Pidgeon. An age old name, many poems have been written about him, verses include - Sorne was Torn, Fore he had a hard Task, Shall I grow Corn?, or Mow my Lawn? is what He did ask ")

def packforgetcredits(self):

global stat

if stat == 1:

self.Label4.pack_forget()

self.Label3.pack_forget()

elif stat ==2:

self.Cred1.pack_forget()

self.Cred2.pack_forget()

self.Cred3.pack_forget()

elif stat == 3:

self.Label2.pack_forget()

self.Label5.pack_forget()

self.Label6.pack_forget()

self.MainMenuB.pack_forget()

self.Space1.pack_forget()

self.DontPanic.pack_forget()

self.Opening()

root = Tk()

root.title("Hitch Hiker Guide to The Galaxy")

root.geometry("600x300")

root.configure(background='yellow')

app = The_Guide(root)