Python Magic 8-Ball

This simple and no-cost alternative to the 8-Ball is fun to use. It does have it's bugs though (the cancel button does not work). Keep in mind that this is a work in progress. Have fun!

import tkinter as tk
from tkinter import messagebox
from tkinter import simpledialog
from random import randint
# Create the main window
root = tk.Tk()
root.geometry("300x200")
# Function to display a message box
def show_message():
question = simpledialog.askstring("Question", "What is your question?")
random = ["Yes", "No", "Maybe", "It's Definite!", "For Sure!", "NO", "Ummm.... No"]
randinteger = randint(0, 6)
messagebox.showinfo("8-Ball's Verdict", random[randinteger])
# Button to trigger the message box
show_message()
# Run the application
root.mainloop()
view raw 8-Ball.py hosted with ❤ by GitHub

Leave a Reply

Your email address will not be published. Required fields are marked *