Day 20: AI Weather Predictor That Doesn’t Predict The Weather

Welcome to the Day Twenty of my 21-day project series!

I have made an AI Weather Predictor That Doesn’t Predict The Weather. Yes, you read it right!!

Today’s project isn’t about being serious, functional, or a game. It’s a super simple and fun project. To remind you and me that programming can be entertaining…

I am super Excited!! Are you??

Do read the experience

Project Contents

This mini project is called An AI Weather Predictor That Doesn’t Predict The Weather.

This is a simple fun prank-like project in python. You can get plenty of such projects in python.

It uses customtkinter and pillow library.

It is made completely using OOP concepts.

It’s meant to be a simple fun project that says it’s getting the weather prediction but doesn’t.

Here’s how it will work:

Tell me what should I improve in AI Weather Predictor That Doesn’t Predict The Weather.

I wouldn’t get into the step-by-step explanation of the code as the article becomes super long. (And I guess boring too.)

But I would post an explanatory article for it soon.

Full Source Code

Here’s the full source code of AI Weather Predictor That Doesn’t Predict The Weather:

from customtkinter import *
from PIL import Image

class Fooled(CTkToplevel):
    """A custom Tkinter Toplevel window to display a text label and a GIF image of Jerry from the 'Tom and Jerry' cartoon."""
    def __init__(self):
        """Initialize the Fooled Toplevel window."""
        super().__init__()
        self.title("")
        set_appearance_mode("light")
        self.geometry("250x250")
        
        self.label = CTkLabel(self, text="Idk, just look outside🤣")
        self.label.pack()
        self.forward_img = CTkImage(light_image=Image.open("images\\jerry.gif"), size=(199,199))
        self.front = CTkLabel(self, text="", image=self.forward_img)
        self.front.pack()


class ShowWhether(CTkToplevel):
    """A custom Tkinter Toplevel window that simulates a weather forecast process with text labels and a progress bar."""
    def __init__(self):
        """Initialize the ShowWhether Toplevel window."""
        super().__init__()
        self.title("AI weather forecast")
        set_appearance_mode("light")
        self.geometry("300x140")

        self.label = CTkLabel(self, text="Searching Location...")
        self.label.grid(row=0, padx=20, pady=20)

        self.label.after(1000, self.on_after)
        self.pb = CTkProgressBar(self, orientation="horizontal", mode="determinate")
        self.pb.grid(row=1, padx=20, pady=20)
        self.pb.set(0)
    def on_after(self):
        """Update the label text and progress bar after a delay."""
        self.label = CTkLabel(self, text="Analyzing the clouds...")
        self.label.grid(row=0, padx=20, pady=20)
        self.label.after(1000, self.on_after1)
        self.pb.set(0.25)

    def on_after1(self):
        """Update the label text and progress bar after a delay."""
        self.label = CTkLabel(self, text="Looking outside your window...")
        self.label.grid(row=0, padx=20, pady=20)
        self.label.after(1000, self.on_after2)
        self.pb.set(0.50)

    def on_after2(self):
        """Update the label text and progress bar after a delay."""
        self.label = CTkLabel(self, text="Gathering last the information...")
        self.label.grid(row=0, padx=20, pady=20)
        self.label.after(1000, self.last)
        self.pb.set(0.75)

    def last(self):
        """Finalize the weather forecast process and display the Fooled Toplevel window."""
        self.pb.set(1)
        show = Fooled()
        show.mainloop()


class Get_City(CTk):
    """A custom Tkinter main application class to get the user's location and initiate the weather forecast."""
    def __init__(self):
        """Initialize the Get_City application."""
        super().__init__()
        set_appearance_mode("light")
        self.title("AI weather forecast")

        self.geometry("400x175")
        self.label = CTkLabel(self, text="Enter your Location: ")
        self.label.pack(padx=20, pady=15)
        self.city = CTkEntry(self, placeholder_text="Enter Your city ")
        self.city.pack(padx=20, pady=10)

        self.check_weather = CTkButton(self, text="Check weather", command=self.weather)
        self.check_weather.pack(padx=20, pady=10)

    def weather(self):
        """Check if the city input is valid and initiate the weather forecast process."""
        if self.city.get() == "":
            print("Enter a city First")
        else:
            show = ShowWhether()
            show.mainloop()
if __name__ == "__main__":
    app = Get_City()
    app.mainloop()

AI Weather Predictor That Doesn’t Predict The Weather is well documented and well written it would be easy to understand. Here are the links to topics within the mini-project.

You can check them if you have any doubts or confusion:

Possible Improvements (That I’ll add after 21 days)

Here are some possible improvements in the AI Weather Predictor That Doesn’t Predict The Weather

  1. Animated Weather Icons
  2. Randomized Weather Messages
  3. Weather-Related Jokes
  4. Weather Prediction Mini-Game
  5. Multiple Locations
  6. Game Replay

And a lot more…

Experience of the day

In case you don’t know this project is a part of the brand new series that I have started—#21days21projects in python. To read more about it you can check out this page.

And for those who already know here’s my experience of the day.

So, today I was thinking about what to make. There were a few ideas on my mind like a spell checker or an autosuggest.

As I haven’t made any AI projects in this series.

And then I came across a reel on Instagram (I hardly scroll reels) and got this simply cute and fun project.

I was so obsessed with it that I had to make it anyhow.

It was fun and small with no real burdens on my head.

Even a kid could have coded it. I had fun making it. Yes, if it’s about learning I didn’t pretty much learn anything while making this.

Except for the fact that I should keep stuff light and fun at times…

About my mood state. Its plain. Like you know sometimes you don’t feel or think anything. You are just plainly blank in head and you just watch stuff going on around.

That’s how I am feeling…

Hope you all guys have come this far with me (and it was a good experience to do so!)…

Do let me know whether you liked this AI Weather Predictor That Doesn’t Predict The Weather. Also, let me know if there are any suggestions.

And most importantly how was your DAY 20?

Plain?

Well, I hope it was fun. And remember it’s perfectly awesome if you missed out. Continue to work from tomorrow.

And today just write one line of code as simple as making a variable or printing something.

Your suggestions are welcomed!

Happy coding…

And wait, if you have some ideas for the upcoming projects do let me know that too. Even when the series ends do let me know what you like…

Leave a Reply