Create an step by step algorithm for this code:
import tkinter as tk
from tkinter import messagebox
from PIL import Image, ImageTk
import random
# Create the Landing interface
def submit_username():
username = username_entry.get()
root = tk.Tk()
root.title("Welcome Player")
welcome_label = tk.Label(root, text="Logo Quiz Game", font=("Helvetica", 24))
welcome_label.pack(side=tk.BOTTOM)
username_label = tk.Label(root, text="Enter your username:")
username_label.pack()
username_entry = tk.Entry(root)
username_entry.pack()
submit_button = tk.Button(
root,
text="Submit",
command=lambda: [submit_username(),
root.after(1000, root.destroy())])
submit_button.pack()
root.mainloop()
class LogoGame:
# Answer / Hint / Logo stored in array
logos = {
"Google": {
"hint": "Largest Search engine",
"image_path": "img/gogol.png"
},
"Apple": {
"hint": "Steve Jobs",
"image_path": "img/mansanas.png"
},
"Lexus": {
"hint": "Car starts at letter L",
"image_path": "img/lex.png"
},
"Instagram": {
"hint": "Common cêlêb social media",
"image_path": "img/insta.png"
},
"PlayStore": {
"hint": "Android app market",
"image_path": "img/ps.png"
},
"AppStore": {
"hint": "IOS app market",
"image_path": "img/as.png"
},
"LG": {
"hint": "Aircon, TV, Stove, Smart phone",
"image_path": "img/lg.png"
},
"Nintendo": {
"hint": "Mario game in modern",
"image_path": "img/nin.png"
},
"Zoom": {
"hint": "Virtual meeting",
"image_path": "img/zoom.png"
},
"Amazon": {
"hint": "Kalbo ang founder",
"image_path": "img/amazon.png"
},
}
#panel and game name
def init(self, master):
self.master = master
self.master.title("Guess The LOGO Game")
#scoring syntax
self.score = 0
self.current_logo = None
self.logos_list = list(LogoGame.logos.keys())
random.shuffle(self.logos_list)
self.create_widgets()
self.next_logo()
def create_widgets(self):
self.score_label = tk.Label(self.master,
text=f"Score: {self.score}",
anchor=tk.NE)
self.score_label.pack(anchor=tk.NE)
self.logo_label = tk.Label(self.master)
self.logo_label.pack()
self.answer_entry = tk.Entry(self.master)
self.answer_entry.pack()
skip_button = tk.Button(self.master, text="Skip", command=self.next_logo)
skip_button.pack(side=tk.LEFT, padx=10)
submit_button = tk.Button(self.master,
text="Submit",
command=self.check_answer)
submit_button.pack(side=tk.LEFT, padx=50)
self.hint_button = tk.Button(self.master,
text="Hint",
command=self.show_hint)
self.hint_button.pack(side=tk.RIGHT, padx=10)
def next_logo(self):
self.answer_entry.delete(0, tk.END)
if not self.logos_list:
self.master.quit()
self.current_logo = self.logos_list.pop()
# syntax to display image in tkinter and it format
image_path = LogoGame.logos[self.current_logo]["image_path"]
image = Image.open(image_path)
image.thumbnail((300, 300))
photo = ImageTk.PhotoImage(image)
self.logo_label.configure(image=photo)
self.logo_label.image = photo
#Checker syntax accepting answer dawa sadit or jejemon format
def check_answer(self):
user_answer = self.answer_entry.get().strip()
if user_answer.lower() == self.current_logo.lower():
self.score += 1
self.score_label.config(text=f"Score: {self.score}")
messagebox.showinfo("Correct", "Korekong tv!")
if len(self.logos_list) == 0:
#Ask user kung gusto mag simula muli or let go ne kimii
messagebox.showinfo(
"Congratulations!",
f"Congratulations! Your got: {self.score} correct answers.")
continue_playing = messagebox.askyesno(
"Continue Playing?", "Do you want to continue playing?")
if continue_playing:
self.score = 0
self.logos_list = list(LogoGame.logos.keys())
random.shuffle(self.logos_list)
self.score_label.config(text=f"Score: {self.score}")
self.next_logo()
else:
messagebox.showerror("Error", "Okay then bye thanks for playing")
self.master.quit()
else:
self.next_logo()
else:
messagebox.showerror("Incorrect", "Try ulit!")
def show_hint(self):
hint = LogoGame.logos[self.current_logo]["hint"]
messagebox.showinfo("Hint", hint)
if name == "main":
root = tk.Tk()
game = LogoGame(root)
root.mainloop()